diff --git a/src/components/FindBar/FindBar.js b/src/components/FindBar/FindBar.js index 0bfcac09..effda752 100644 --- a/src/components/FindBar/FindBar.js +++ b/src/components/FindBar/FindBar.js @@ -8,6 +8,16 @@ export const SEARCH = 'SEARCH'; const PLACEHOLDER = 'Search or enter a command'; class FindBar extends Component { + static propTypes = { + commands: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string.isRequired, + type: PropTypes.string.isRequired, + pattern: PropTypes.string.isRequired + })).isRequired, + defaultCommands: PropTypes.arrayOf(PropTypes.string), + runCommand: PropTypes.func.isRequired, + }; + constructor() { super(); this._compiledCommands = []; @@ -352,14 +362,4 @@ class FindBar extends Component { } } -FindBar.propTypes = { - commands: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string.isRequired, - type: PropTypes.string.isRequired, - pattern: PropTypes.string.isRequired - })).isRequired, - defaultCommands: PropTypes.arrayOf(PropTypes.string), - runCommand: PropTypes.func.isRequired, -}; - export default FindBar; diff --git a/src/components/PreviewPane.js b/src/components/PreviewPane.js index a0f8677e..7ea5d31f 100644 --- a/src/components/PreviewPane.js +++ b/src/components/PreviewPane.js @@ -6,6 +6,12 @@ import { resolveWidget } from './Widgets'; import styles from './PreviewPane.css'; class Preview extends React.Component { + static propTypes = { + collection: ImmutablePropTypes.map.isRequired, + entry: ImmutablePropTypes.map.isRequired, + getMedia: PropTypes.func.isRequired, + }; + previewFor(field) { const { entry, getMedia } = this.props; const widget = resolveWidget(field.get('widget')); @@ -26,12 +32,6 @@ class Preview extends React.Component { } } -Preview.propTypes = { - collection: ImmutablePropTypes.map.isRequired, - entry: ImmutablePropTypes.map.isRequired, - getMedia: PropTypes.func.isRequired, -}; - export default class PreviewPane extends React.Component { componentDidUpdate() { this.renderPreview(); diff --git a/src/components/UnpublishedListing.js b/src/components/UnpublishedListing.js index 09573b3b..f58a3a6b 100644 --- a/src/components/UnpublishedListing.js +++ b/src/components/UnpublishedListing.js @@ -69,6 +69,12 @@ class UnpublishedListing extends React.Component { } }; + static propTypes = { + entries: ImmutablePropTypes.orderedMap, + handleChangeStatus: PropTypes.func.isRequired, + handlePublish: PropTypes.func.isRequired, + }; + render() { const columns = this.renderColumns(this.props.entries); return ( @@ -82,10 +88,4 @@ class UnpublishedListing extends React.Component { } } -UnpublishedListing.propTypes = { - entries: ImmutablePropTypes.orderedMap, - handleChangeStatus: PropTypes.func.isRequired, - handlePublish: PropTypes.func.isRequired, -}; - export default HTML5DragDrop(UnpublishedListing); diff --git a/src/components/Widgets/MarkdownControl.js b/src/components/Widgets/MarkdownControl.js index 5f51e9d3..4d517e7e 100644 --- a/src/components/Widgets/MarkdownControl.js +++ b/src/components/Widgets/MarkdownControl.js @@ -7,6 +7,19 @@ import { connect } from 'react-redux'; import { switchVisualMode } from '../../actions/editor'; class MarkdownControl extends React.Component { + static propTypes = { + editor: PropTypes.object.isRequired, + onChange: PropTypes.func.isRequired, + onAddMedia: PropTypes.func.isRequired, + getMedia: PropTypes.func.isRequired, + switchVisualMode: PropTypes.func.isRequired, + value: PropTypes.node, + }; + + static contextTypes = { + plugins: PropTypes.object, + }; + componentWillMount() { this.useRawEditor(); processEditorPlugins(registry.getEditorComponents()); @@ -60,19 +73,6 @@ class MarkdownControl extends React.Component { } } -MarkdownControl.propTypes = { - editor: PropTypes.object.isRequired, - onChange: PropTypes.func.isRequired, - onAddMedia: PropTypes.func.isRequired, - getMedia: PropTypes.func.isRequired, - switchVisualMode: PropTypes.func.isRequired, - value: PropTypes.node, -}; - -MarkdownControl.contextTypes = { - plugins: PropTypes.object, -}; - export default connect( state => ({ editor: state.editor }), { switchVisualMode } diff --git a/src/components/Widgets/MarkdownControlElements/plugins.js b/src/components/Widgets/MarkdownControlElements/plugins.js index fa0e0d34..86c9a111 100644 --- a/src/components/Widgets/MarkdownControlElements/plugins.js +++ b/src/components/Widgets/MarkdownControlElements/plugins.js @@ -18,6 +18,14 @@ const EditorComponent = Record({ class Plugin extends Component { + static propTypes = { + children: PropTypes.element.isRequired + }; + + static childContextTypes = { + plugins: PropTypes.object + }; + getChildContext() { return { plugins: plugins }; } @@ -27,13 +35,6 @@ class Plugin extends Component { } } -Plugin.propTypes = { - children: PropTypes.element.isRequired -}; -Plugin.childContextTypes = { - plugins: PropTypes.object -}; - export function newEditorPlugin(config) { const configObj = new EditorComponent({ id: config.id || config.label.replace(/[^A-Z0-9]+/ig, '_'), diff --git a/src/containers/CollectionPage.js b/src/containers/CollectionPage.js index 26dcbf79..5e72424a 100644 --- a/src/containers/CollectionPage.js +++ b/src/containers/CollectionPage.js @@ -9,6 +9,13 @@ import styles from './CollectionPage.css'; import CollectionPageHOC from './editorialWorkflow/CollectionPageHOC'; class DashboardPage extends React.Component { + static propTypes = { + collection: ImmutablePropTypes.map.isRequired, + collections: ImmutablePropTypes.orderedMap.isRequired, + dispatch: PropTypes.func.isRequired, + entries: ImmutablePropTypes.list, + }; + componentDidMount() { const { collection, dispatch } = this.props; if (collection) { @@ -39,12 +46,6 @@ class DashboardPage extends React.Component { ; } } -DashboardPage.propTypes = { - collection: ImmutablePropTypes.map.isRequired, - collections: ImmutablePropTypes.orderedMap.isRequired, - dispatch: PropTypes.func.isRequired, - entries: ImmutablePropTypes.list, -}; /* * Instead of checking the publish mode everywhere to dispatch & render the additional editorial workflow stuff, diff --git a/src/containers/EntryPage.js b/src/containers/EntryPage.js index b3a8a483..dd79f2f0 100644 --- a/src/containers/EntryPage.js +++ b/src/containers/EntryPage.js @@ -15,6 +15,23 @@ import EntryEditor from '../components/EntryEditor'; import EntryPageHOC from './editorialWorkflow/EntryPageHOC'; class EntryPage extends React.Component { + static propTypes = { + addMedia: PropTypes.func.isRequired, + boundGetMedia: PropTypes.func.isRequired, + changeDraft: PropTypes.func.isRequired, + collection: ImmutablePropTypes.map.isRequired, + createDraftFromEntry: PropTypes.func.isRequired, + createEmptyDraft: PropTypes.func.isRequired, + discardDraft: PropTypes.func.isRequired, + entry: ImmutablePropTypes.map, + entryDraft: ImmutablePropTypes.map.isRequired, + loadEntry: PropTypes.func.isRequired, + persistEntry: PropTypes.func.isRequired, + removeMedia: PropTypes.func.isRequired, + slug: PropTypes.string, + newEntry: PropTypes.bool.isRequired, + }; + componentDidMount() { if (!this.props.newEntry) { this.props.loadEntry(this.props.collection, this.props.slug); @@ -69,23 +86,6 @@ class EntryPage extends React.Component { } } -EntryPage.propTypes = { - addMedia: PropTypes.func.isRequired, - boundGetMedia: PropTypes.func.isRequired, - changeDraft: PropTypes.func.isRequired, - collection: ImmutablePropTypes.map.isRequired, - createDraftFromEntry: PropTypes.func.isRequired, - createEmptyDraft: PropTypes.func.isRequired, - discardDraft: PropTypes.func.isRequired, - entry: ImmutablePropTypes.map, - entryDraft: ImmutablePropTypes.map.isRequired, - loadEntry: PropTypes.func.isRequired, - persistEntry: PropTypes.func.isRequired, - removeMedia: PropTypes.func.isRequired, - slug: PropTypes.string, - newEntry: PropTypes.bool.isRequired, -}; - function mapStateToProps(state, ownProps) { const { collections, entryDraft } = state; const collection = collections.get(ownProps.params.name); diff --git a/src/containers/editorialWorkflow/CollectionPageHOC.js b/src/containers/editorialWorkflow/CollectionPageHOC.js index 6aeacb71..c753451d 100644 --- a/src/containers/editorialWorkflow/CollectionPageHOC.js +++ b/src/containers/editorialWorkflow/CollectionPageHOC.js @@ -10,6 +10,11 @@ import styles from '../CollectionPage.css'; export default function CollectionPageHOC(CollectionPage) { class CollectionPageHOC extends CollectionPage { + static propTypes = { + dispatch: PropTypes.func.isRequired, + isEditorialWorkflow: PropTypes.bool.isRequired, + unpublishedEntries: ImmutablePropTypes.map, + }; componentDidMount() { const { dispatch, isEditorialWorkflow } = this.props; @@ -36,12 +41,6 @@ export default function CollectionPageHOC(CollectionPage) { } } - CollectionPageHOC.propTypes = { - dispatch: PropTypes.func.isRequired, - isEditorialWorkflow: PropTypes.bool.isRequired, - unpublishedEntries: ImmutablePropTypes.map, - }; - function mapStateToProps(state) { const publish_mode = state.config.get('publish_mode'); const isEditorialWorkflow = (publish_mode === EDITORIAL_WORKFLOW);