Added propTypes to AppHeader and fixed ESLint errors.

This commit is contained in:
Andrey Okonetchnikov 2016-10-11 10:46:24 +02:00
parent e0160af9c6
commit 4da6c9708a

View File

@ -1,4 +1,5 @@
import React from 'react'; import React, { PropTypes } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import pluralize from 'pluralize'; import pluralize from 'pluralize';
import { IndexLink } from 'react-router'; import { IndexLink } from 'react-router';
import { Menu, MenuItem } from 'react-toolbox'; import { Menu, MenuItem } from 'react-toolbox';
@ -8,11 +9,20 @@ import styles from './AppHeader.css';
export default class AppHeader extends React.Component { export default class AppHeader extends React.Component {
state = { static propTypes = {
createMenuActive: false collections: ImmutablePropTypes.list.isRequired,
commands: PropTypes.array.isRequired, // eslint-disable-line
defaultCommands: PropTypes.array.isRequired, // eslint-disable-line
runCommand: PropTypes.func.isRequired,
toggleNavDrawer: PropTypes.func.isRequired,
onCreateEntryClick: PropTypes.func.isRequired,
}; };
handleCreatePostClick = collectionName => { state = {
createMenuActive: false,
};
handleCreatePostClick = (collectionName) => {
const { onCreateEntryClick } = this.props; const { onCreateEntryClick } = this.props;
if (onCreateEntryClick) { if (onCreateEntryClick) {
onCreateEntryClick(collectionName); onCreateEntryClick(collectionName);
@ -21,13 +31,13 @@ export default class AppHeader extends React.Component {
handleCreateButtonClick = () => { handleCreateButtonClick = () => {
this.setState({ this.setState({
createMenuActive: true createMenuActive: true,
}); });
}; };
handleCreateMenuHide = () => { handleCreateMenuHide = () => {
this.setState({ this.setState({
createMenuActive: false createMenuActive: false,
}); });
}; };
@ -37,7 +47,7 @@ export default class AppHeader extends React.Component {
commands, commands,
defaultCommands, defaultCommands,
runCommand, runCommand,
toggleNavDrawer toggleNavDrawer,
} = this.props; } = this.props;
const { createMenuActive } = this.state; const { createMenuActive } = this.state;
@ -69,7 +79,7 @@ export default class AppHeader extends React.Component {
<MenuItem <MenuItem
key={collection.get('name')} key={collection.get('name')}
value={collection.get('name')} value={collection.get('name')}
onClick={this.handleCreatePostClick.bind(this, collection.get('name'))} onClick={this.handleCreatePostClick.bind(this, collection.get('name'))} // eslint-disable-line
caption={pluralize(collection.get('label'), 1)} caption={pluralize(collection.get('label'), 1)}
/> />
) )