fixes eslint

This commit is contained in:
zmagod 2017-08-07 09:31:24 +02:00
parent d707057aa4
commit 0a7c6300b0
8 changed files with 121 additions and 18 deletions

2
.eslintignore Normal file
View file

@ -0,0 +1,2 @@
node_modules/
public/

View file

@ -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

View file

@ -10,6 +10,9 @@ export default {
modal_title: "Activities",
no_data: "No Data",
more_activities: "More Activities"
},
global_team_switch: {
new_team: "New team"
}
}
};

View file

@ -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 (
<RootCloseWrapper
onRootClose={this.handleRootClose}
event={rootCloseEvent}
>
<NavDropdown
noCaret
title={<span className="glyphicon glyphicon-search" />}
id="team-switch"
>
<MenuItem
onSelect={this.triggerSearch}
eventKey="search"
key="navSearchInput"
>
<input
type="text"
placeholder="Search"
value={this.state.searchTerm}
onChange={this.handleSearchTermChange}
/>
</MenuItem>
</NavDropdown>
</RootCloseWrapper>
);
}
}
export default SearchDropdown;

View file

@ -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 (
<MenuItem href="/users/settings/teams/new" key="addNewTeam">
<span className="glyphicon glyphicon-plus" />
<FormattedMessage id="global_team_switch.new_team" />
</MenuItem>
);
}
render() {
return (
<NavDropdown
noCaret
eventKey={this.props.eventKey}
title={this.props.current_team.name}
id="team-switch"
>
{this.displayTeams()}
{this.newTeamLink()}
</NavDropdown>
);
}
@ -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,

View file

@ -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 {
</Nav>
<Nav pullRight>
<TeamSwitch eventKey={5} />
<NavItem eventKey={6} href="#">
Link Right
</NavItem>
<SearchDropdown />
<NavItem eventKey={7} href="#">
Link Right
</NavItem>
@ -112,8 +111,8 @@ class Navigation extends Component {
Navigation.propTypes = {
fetchActivities: PropTypes.func.isRequired,
getTeamsList: PropTypes.func.isRequired,
}
getTeamsList: PropTypes.func.isRequired
};
// Map the fetch activity action to component
const mapDispatchToProps = dispatch => ({

View file

@ -20,6 +20,7 @@
"lint": "eslint ."
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "^3.7.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-google": "^0.5.0",
@ -62,6 +63,7 @@
"react": "^15.6.1",
"react-bootstrap": "^0.31.1",
"react-dom": "^15.6.1",
"react-dropdown-input": "^0.1.11",
"react-intl": "^2.3.0",
"react-intl-redux": "^0.6.0",
"react-redux": "^5.0.5",

View file

@ -335,6 +335,15 @@ babel-core@^6.24.1, babel-core@^6.25.0:
slash "^1.0.0"
source-map "^0.5.0"
babel-eslint@^7.2.3:
version "7.2.3"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827"
dependencies:
babel-code-frame "^6.22.0"
babel-traverse "^6.23.1"
babel-types "^6.23.0"
babylon "^6.17.0"
babel-generator@^6.25.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc"
@ -853,7 +862,7 @@ babel-template@^6.24.1, babel-template@^6.25.0:
babylon "^6.17.2"
lodash "^4.2.0"
babel-traverse@^6.24.1, babel-traverse@^6.25.0:
babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.25.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1"
dependencies:
@ -867,7 +876,7 @@ babel-traverse@^6.24.1, babel-traverse@^6.25.0:
invariant "^2.2.0"
lodash "^4.2.0"
babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0:
babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.25.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e"
dependencies:
@ -876,7 +885,7 @@ babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"
babylon@^6.17.2:
babylon@^6.17.0, babylon@^6.17.2:
version "6.17.4"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a"
@ -1175,7 +1184,7 @@ clap@^1.0.9:
dependencies:
chalk "^1.1.3"
classnames@^2.2.5:
classnames@>=1.1.4, classnames@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
@ -4549,6 +4558,22 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-bootstrap@>=0.18.0:
version "0.31.2"
resolved "https://registry.yarnpkg.com/react-bootstrap/-/react-bootstrap-0.31.2.tgz#f59184676ecedfc4c572d29ffdd6f9126ea8fe6a"
dependencies:
babel-runtime "^6.11.6"
classnames "^2.2.5"
dom-helpers "^3.2.0"
invariant "^2.2.1"
keycode "^2.1.2"
prop-types "^15.5.10"
prop-types-extra "^1.0.1"
react-overlays "^0.7.0"
react-prop-types "^0.4.0"
uncontrollable "^4.1.0"
warning "^3.0.0"
react-bootstrap@^0.31.1:
version "0.31.1"
resolved "https://registry.yarnpkg.com/react-bootstrap/-/react-bootstrap-0.31.1.tgz#679c9f73ae77ff207867d536496207291f3a3ed7"
@ -4574,6 +4599,14 @@ react-dom@^15.6.1:
object-assign "^4.1.0"
prop-types "^15.5.10"
react-dropdown-input@^0.1.11:
version "0.1.11"
resolved "https://registry.yarnpkg.com/react-dropdown-input/-/react-dropdown-input-0.1.11.tgz#2162e86bc3fa0626d476178dc38ccd80199b7c3f"
dependencies:
classnames ">=1.1.4"
react ">=0.12"
react-bootstrap ">=0.18.0"
react-intl-redux@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/react-intl-redux/-/react-intl-redux-0.6.0.tgz#398589c56c3f19d27628015f8e490e610be19202"
@ -4645,7 +4678,7 @@ react-router@^4.1.1:
prop-types "^15.5.4"
warning "^3.0.0"
react@^15.6.1:
react@>=0.12, react@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
dependencies: