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 { IndexLink } from 'react-router';
import { Menu, MenuItem } from 'react-toolbox';
@ -8,11 +9,20 @@ import styles from './AppHeader.css';
export default class AppHeader extends React.Component {
state = {
createMenuActive: false
static propTypes = {
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;
if (onCreateEntryClick) {
onCreateEntryClick(collectionName);
@ -21,13 +31,13 @@ export default class AppHeader extends React.Component {
handleCreateButtonClick = () => {
this.setState({
createMenuActive: true
createMenuActive: true,
});
};
handleCreateMenuHide = () => {
this.setState({
createMenuActive: false
createMenuActive: false,
});
};
@ -37,7 +47,7 @@ export default class AppHeader extends React.Component {
commands,
defaultCommands,
runCommand,
toggleNavDrawer
toggleNavDrawer,
} = this.props;
const { createMenuActive } = this.state;
@ -69,7 +79,7 @@ export default class AppHeader extends React.Component {
<MenuItem
key={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)}
/>
)