From 0a7c6300b091c2e11e2a86be504f140727c30ada Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 7 Aug 2017 09:31:24 +0200 Subject: [PATCH] fixes eslint --- .eslintignore | 2 + .eslintrc.json | 5 +- app/javascript/packs/locales/messages.js | 3 + .../navigation/components/SearchDropdown.jsx | 55 +++++++++++++++++++ .../navigation/components/TeamSwitch.jsx | 20 +++++-- .../packs/shared/navigation/index.js | 9 ++- package.json | 2 + yarn.lock | 43 +++++++++++++-- 8 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 .eslintignore create mode 100644 app/javascript/packs/shared/navigation/components/SearchDropdown.jsx diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..0a0304580 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules/ +public/ diff --git a/.eslintrc.json b/.eslintrc.json index b7d4287ee..7295ef418 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,15 +7,14 @@ }, "plugins": ["react", "prettier"], "extends": [ - "eslint:recommended", - "plugin:react/recommended", "airbnb", "prettier", "prettier/react" ], + "parser": "babel-eslint", "parserOptions": { "sourceType": "module", - "ecmaVersion": 6, + "ecmaVersion": 2016, "ecmaFeatures": { "impliedStrict": true, "jsx": true diff --git a/app/javascript/packs/locales/messages.js b/app/javascript/packs/locales/messages.js index 000d15e06..36d95ef2e 100644 --- a/app/javascript/packs/locales/messages.js +++ b/app/javascript/packs/locales/messages.js @@ -10,6 +10,9 @@ export default { modal_title: "Activities", no_data: "No Data", more_activities: "More Activities" + }, + global_team_switch: { + new_team: "New team" } } }; diff --git a/app/javascript/packs/shared/navigation/components/SearchDropdown.jsx b/app/javascript/packs/shared/navigation/components/SearchDropdown.jsx new file mode 100644 index 000000000..1e87162e6 --- /dev/null +++ b/app/javascript/packs/shared/navigation/components/SearchDropdown.jsx @@ -0,0 +1,55 @@ +import React, { Component } from "react"; +import { NavDropdown, MenuItem } from "react-bootstrap"; +import { RootCloseWrapper } from "react-overlays"; + +class SearchDropdown extends Component { + constructor(props) { + super(props); + this.state = { searchTerm: "" }; + this.handleSearchTermChange = this.handleSearchTermChange.bind(this); + this.triggerSearch = this.triggerSearch.bind(this); + } + + handleSearchTermChange(ev) { + ev.preventDefault(); + this.setState({ searchTerm: ev.target.value }); + } + + handleRootClose(ev) { + console.log(ev); + // if (ev.key !== "Enter") { + // ev.preventDefault(); + // } + // href={`/search?q=${this.state.searchTerm}`} + } + + render() { + return ( + + } + id="team-switch" + > + + + + + + ); + } +} + +export default SearchDropdown; diff --git a/app/javascript/packs/shared/navigation/components/TeamSwitch.jsx b/app/javascript/packs/shared/navigation/components/TeamSwitch.jsx index 3f6804f92..d957b503f 100644 --- a/app/javascript/packs/shared/navigation/components/TeamSwitch.jsx +++ b/app/javascript/packs/shared/navigation/components/TeamSwitch.jsx @@ -1,6 +1,7 @@ import React, { Component } from "react"; import { connect } from "react-redux"; import PropTypes from "prop-types"; +import { FormattedMessage } from "react-intl"; import { NavDropdown, MenuItem } from "react-bootstrap"; import { setCurrentUser, changeTeam } from "../../actions/TeamsActions"; @@ -9,12 +10,10 @@ class TeamSwitch extends Component { constructor(props) { super(props); this.displayTeams = this.displayTeams.bind(this); - } - changeTeam(team_id) { - console.log("clicked"); - this.props.changeTeam(team_id); + changeTeam(teamId) { + this.props.changeTeam(teamId); } displayTeams() { @@ -25,14 +24,25 @@ class TeamSwitch extends Component { ); } + newTeamLink() { + return ( + + + + + ); + } + render() { return ( {this.displayTeams()} + {this.newTeamLink()} ); } @@ -40,7 +50,7 @@ class TeamSwitch extends Component { TeamSwitch.propTypes = { eventKey: PropTypes.number.isRequired, - setCurrentUser: PropTypes.func.isRequired, + changeTeam: PropTypes.func.isRequired, all_teams: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.number.isRequired, diff --git a/app/javascript/packs/shared/navigation/index.js b/app/javascript/packs/shared/navigation/index.js index bef5cd83e..3ba23653c 100644 --- a/app/javascript/packs/shared/navigation/index.js +++ b/app/javascript/packs/shared/navigation/index.js @@ -8,6 +8,7 @@ import { getActivities } from "../actions/ActivitiesActions"; import { getTeamsList } from "../actions/TeamsActions"; import TeamSwitch from "./components/TeamSwitch"; import GlobalActivitiesModal from "./components/GlobalActivitiesModal"; +import SearchDropdown from "./components/SearchDropdown"; const StyledBrand = styled.a` background-color: ${MAIN_COLOR_BLUE}; @@ -93,9 +94,7 @@ class Navigation extends Component {