From 9af50ed1309a93611d80bf136170af6a91ad32b2 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 12 Jan 2018 15:02:42 -0800 Subject: [PATCH] added proptypes --- react/components/ChannelSelector.jsx | 6 ++++++ react/components/Preview.jsx | 8 ++++++- react/components/PublishUrlMiddle.jsx | 7 +++++++ react/containers/AnonymousOrChannelSelect.jsx | 6 ++++++ react/containers/ChannelCreateForm.jsx | 5 +++++ react/containers/ChannelLoginForm.jsx | 5 +++++ react/containers/Dropzone.jsx | 13 +++++++++--- react/containers/PublishForm.jsx | 21 +++++++++++++++++++ react/containers/PublishMetadataInputs.jsx | 8 +++++++ react/containers/PublishThumbnailInput.jsx | 6 ++++++ react/containers/PublishTitleInput.jsx | 6 ++++++ react/containers/PublishTool.jsx | 7 +++++++ react/containers/PublishUrlInput.jsx | 12 ++++++++++- 13 files changed, 105 insertions(+), 5 deletions(-) diff --git a/react/components/ChannelSelector.jsx b/react/components/ChannelSelector.jsx index 1873c8a6..defff582 100644 --- a/react/components/ChannelSelector.jsx +++ b/react/components/ChannelSelector.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import ChannelLoginForm from '../containers/ChannelLoginForm.jsx'; import ChannelCreateForm from '../containers/ChannelCreateForm.jsx'; import { connect } from 'react-redux'; @@ -67,4 +68,9 @@ const mapStateToProps = state => { }; }; +ChannelSelector.propTypes = { + loggedInChannelName: PropTypes.string, + publishInChannel : PropTypes.bool, +}; + export default connect(mapStateToProps, null)(ChannelSelector); diff --git a/react/components/Preview.jsx b/react/components/Preview.jsx index 06e54513..32d84dc0 100644 --- a/react/components/Preview.jsx +++ b/react/components/Preview.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import {connect} from 'react-redux'; +import PropTypes from 'prop-types'; class Preview extends React.Component { constructor (props) { @@ -40,4 +40,10 @@ class Preview extends React.Component { } }; +Preview.propTypes = { + file : PropTypes.object.isRequired, + thumbnail : PropTypes.string.isRequired, + dimPreview: PropTypes.bool.isRequired, +}; + export default Preview; diff --git a/react/components/PublishUrlMiddle.jsx b/react/components/PublishUrlMiddle.jsx index 71a730c4..9e049fe1 100644 --- a/react/components/PublishUrlMiddle.jsx +++ b/react/components/PublishUrlMiddle.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; function UrlMiddle ({publishInChannel, loggedInChannelName, loggedInChannelShortId}) { if (publishInChannel) { @@ -13,4 +14,10 @@ function UrlMiddle ({publishInChannel, loggedInChannelName, loggedInChannelShort ); } +UrlMiddle.propTypes = { + publishInChannel : PropTypes.bool.isRequired, + loggedInChannelName : PropTypes.string.isRequired, + loggedInChannelShortId: PropTypes.string.isRequired, +}; + export default UrlMiddle; diff --git a/react/containers/AnonymousOrChannelSelect.jsx b/react/containers/AnonymousOrChannelSelect.jsx index ab2c2efd..925f48f8 100644 --- a/react/containers/AnonymousOrChannelSelect.jsx +++ b/react/containers/AnonymousOrChannelSelect.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { setPublishInChannel } from '../actions/index'; import { connect } from 'react-redux'; +import PropTypes from 'prop-types'; class AnonymousOrChannelSelect extends React.Component { constructor (props) { @@ -45,4 +46,9 @@ const mapDispatchToProps = dispatch => { }; } +AnonymousOrChannelSelect.propTypes = { + publishInChannel : PropTypes.bool.isRequired, + onPublishInChannelChange: PropTypes.func.isRequired, +}; + export default connect(mapStateToProps, mapDispatchToProps)(AnonymousOrChannelSelect); diff --git a/react/containers/ChannelCreateForm.jsx b/react/containers/ChannelCreateForm.jsx index f8a0923f..e1a74fa8 100644 --- a/react/containers/ChannelCreateForm.jsx +++ b/react/containers/ChannelCreateForm.jsx @@ -4,6 +4,7 @@ import {updateLoggedInChannel} from '../actions/index'; import { makeGetRequest, makePostRequest } from '../utils/xhr.js'; import { setUserCookies } from '../utils/cookies.js'; import { replaceChannelSelectionInNavBar } from '../utils/page.js'; +import PropTypes from 'prop-types'; class ChannelCreateForm extends React.Component { constructor (props) { @@ -170,4 +171,8 @@ const mapDispatchToProps = dispatch => { }; }; +ChannelCreateForm.propTypes = { + onChannelLogin: PropTypes.func.isRequired, +}; + export default connect(null, mapDispatchToProps)(ChannelCreateForm); diff --git a/react/containers/ChannelLoginForm.jsx b/react/containers/ChannelLoginForm.jsx index e60042f8..2e98a61e 100644 --- a/react/containers/ChannelLoginForm.jsx +++ b/react/containers/ChannelLoginForm.jsx @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { updateLoggedInChannel } from '../actions/index'; import { setUserCookies } from '../utils/cookies.js'; import { replaceChannelSelectionInNavBar } from '../utils/page.js'; +import PropTypes from 'prop-types'; class ChannelLoginForm extends React.Component { constructor (props) { @@ -82,4 +83,8 @@ const mapDispatchToProps = dispatch => { }; }; +ChannelLoginForm.propTypes = { + onChannelLogin: PropTypes.func.isRequired, +}; + export default connect(null, mapDispatchToProps)(ChannelLoginForm); diff --git a/react/containers/Dropzone.jsx b/react/containers/Dropzone.jsx index 5f477625..59dc8a16 100644 --- a/react/containers/Dropzone.jsx +++ b/react/containers/Dropzone.jsx @@ -1,9 +1,9 @@ import React from 'react'; -// import PropTypes from 'prop-types'; import { selectFile, updateError } from '../actions'; import { connect } from 'react-redux'; import Preview from '../components/Preview.jsx'; import { validateFile } from '../utils/file.js'; +import PropTypes from 'prop-types'; class Dropzone extends React.Component { constructor (props) { @@ -12,7 +12,7 @@ class Dropzone extends React.Component { dragOver : false, mouseOver : false, dimPreview: false, - } + }; this.handleDrop = this.handleDrop.bind(this); this.handleDragOver = this.handleDragOver.bind(this); this.handleDragEnd = this.handleDragEnd.bind(this); @@ -157,6 +157,13 @@ const mapDispatchToProps = dispatch => { dispatch(updateError('file', value)); }, }; -} +}; + +Dropzone.propTypes = { + file : PropTypes.object, + thumbnail : PropTypes.string.isRequired, + fileError : PropTypes.string, + onFileError: PropTypes.func.isRequired, +}; export default connect(mapStateToProps, mapDispatchToProps)(Dropzone); diff --git a/react/containers/PublishForm.jsx b/react/containers/PublishForm.jsx index 6926484c..cfb5cad2 100644 --- a/react/containers/PublishForm.jsx +++ b/react/containers/PublishForm.jsx @@ -9,6 +9,7 @@ import AnonymousOrChannelSelect from './AnonymousOrChannelSelect.jsx'; import { connect } from 'react-redux'; import { getCookie } from '../utils/cookies.js'; import {selectFile, clearFile, updateLoggedInChannel, updatePublishStatus, updateError} from '../actions'; +import PropTypes from 'prop-types'; const LOAD_START = 'LOAD_START'; const LOADING = 'LOADING'; @@ -230,4 +231,24 @@ const mapDispatchToProps = dispatch => { }; }; +PublishForm.propTypes = { + file : PropTypes.object.isRequired, + claim : PropTypes.string.isRequired, + title : PropTypes.string.isRequired, + thumbnail : PropTypes.string.isRequired, + description : PropTypes.string.isRequired, + license : PropTypes.string.isRequired, + nsfw : PropTypes.bool.isRequired, + loggedInChannel : PropTypes.object.isRequired, + publishInChannel : PropTypes.bool.isRequired, + fileError : PropTypes.string, + urlError : PropTypes.string, + publishRequestError : PropTypes.string, + onFileSelect : PropTypes.func.isRequired, + onFileClear : PropTypes.func.isRequired, + onChannelLogin : PropTypes.func.isRequired, + onPublishStatusChange: PropTypes.func.isRequired, + onPublishRequestError: PropTypes.func.isRequired, +}; + export default connect(mapStateToProps, mapDispatchToProps)(PublishForm); diff --git a/react/containers/PublishMetadataInputs.jsx b/react/containers/PublishMetadataInputs.jsx index 238e3d3d..d2ed7934 100644 --- a/react/containers/PublishMetadataInputs.jsx +++ b/react/containers/PublishMetadataInputs.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { updateMetadata } from '../actions/index'; +import PropTypes from 'prop-types'; /* const textarea = document.getElementById('publish-description'); @@ -101,4 +102,11 @@ const mapDispatchToProps = dispatch => { }; }; +MetadataInputs.propTypes = { + description : PropTypes.string.isRequired, + license : PropTypes.string.isRequired, + nsfw : PropTypes.bool.isRequired, + onMetadataChange: PropTypes.func.isRequired, +}; + export default connect(mapStateToProps, mapDispatchToProps)(MetadataInputs); diff --git a/react/containers/PublishThumbnailInput.jsx b/react/containers/PublishThumbnailInput.jsx index ee29a8db..3969a67b 100644 --- a/react/containers/PublishThumbnailInput.jsx +++ b/react/containers/PublishThumbnailInput.jsx @@ -1,6 +1,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { updateMetadata } from '../actions/index'; +import PropTypes from 'prop-types'; class ThumbnailInput extends React.Component { constructor (props) { @@ -83,4 +84,9 @@ const mapDispatchToProps = dispatch => { }; }; +ThumbnailInput.propTypes = { + thumbnail : PropTypes.string.isRequired, + onThumbnailChange: PropTypes.func.isRequired, +}; + export default connect(mapStateToProps, mapDispatchToProps)(ThumbnailInput); diff --git a/react/containers/PublishTitleInput.jsx b/react/containers/PublishTitleInput.jsx index 9a259064..e14b2418 100644 --- a/react/containers/PublishTitleInput.jsx +++ b/react/containers/PublishTitleInput.jsx @@ -1,6 +1,7 @@ import React from 'react'; import {updateMetadata} from '../actions/index'; import {connect} from 'react-redux'; +import PropTypes from 'prop-types'; class TitleInput extends React.Component { constructor (props) { @@ -34,4 +35,9 @@ const mapDispatchToProps = dispatch => { }; } +TitleInput.propTypes = { + title : PropTypes.string.isRequired, + onMetadataChange: PropTypes.func.isRequired, +}; + export default connect(mapStateToProps, mapDispatchToProps)(TitleInput); diff --git a/react/containers/PublishTool.jsx b/react/containers/PublishTool.jsx index 3b44ba4e..6f5175bf 100644 --- a/react/containers/PublishTool.jsx +++ b/react/containers/PublishTool.jsx @@ -3,6 +3,7 @@ import Dropzone from './Dropzone.jsx'; import PublishForm from './PublishForm.jsx'; import PublishStatus from '../components/PublishStatus.jsx'; import {connect} from 'react-redux'; +import PropTypes from 'prop-types'; class PublishTool extends React.Component { render () { @@ -31,4 +32,10 @@ const mapStateToProps = state => { }; }; +PublishTool.propTypes = { + file : PropTypes.object, + status : PropTypes.string, + message: PropTypes.string, +}; + export default connect(mapStateToProps, null)(PublishTool); diff --git a/react/containers/PublishUrlInput.jsx b/react/containers/PublishUrlInput.jsx index 9f9fd844..b207b065 100644 --- a/react/containers/PublishUrlInput.jsx +++ b/react/containers/PublishUrlInput.jsx @@ -4,6 +4,7 @@ import { connect } from 'react-redux'; import { makeGetRequest } from '../utils/xhr.js'; import UrlMiddle from '../components/PublishUrlMiddle.jsx'; import {updateError} from '../actions'; +import PropTypes from 'prop-types'; class UrlChooser extends React.Component { constructor (props) { @@ -101,6 +102,15 @@ const mapDispatchToProps = dispatch => { dispatch(updateError('url', value)); }, }; -} +}; + +UrlChooser.propTypes = { + fileName : PropTypes.string.isRequired, + loggedInChannelName : PropTypes.string.isRequired, + loggedInChannelShortId: PropTypes.string.isRequired, + publishInChannel : PropTypes.bool.isRequired, + claim : PropTypes.string.isRequired, + urlError : PropTypes.string, +}; export default connect(mapStateToProps, mapDispatchToProps)(UrlChooser);