From 234531401ce358aa02c8e560b130ee8cbae60067 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 16 Jan 2018 15:55:29 -0800 Subject: [PATCH] removed proptypes --- react/components/ChannelSelector.jsx | 6 ---- react/components/Preview.jsx | 7 ---- react/components/PublishStatus.jsx | 17 ++++------ react/containers/ChannelCreateForm.jsx | 5 --- react/containers/ChannelLoginForm.jsx | 5 --- react/containers/ChannelSelect.jsx | 10 ++---- react/containers/Dropzone.jsx | 12 ++----- react/containers/PublishForm.jsx | 39 +++++----------------- react/containers/PublishMetadataInputs.jsx | 28 ++++++++++------ react/containers/PublishThumbnailInput.jsx | 6 ---- react/containers/PublishTitleInput.jsx | 6 ---- react/containers/PublishTool.jsx | 7 ---- react/containers/PublishUrlInput.jsx | 10 ------ 13 files changed, 37 insertions(+), 121 deletions(-) diff --git a/react/components/ChannelSelector.jsx b/react/components/ChannelSelector.jsx index 1cb4eef0..9fe7e257 100644 --- a/react/components/ChannelSelector.jsx +++ b/react/components/ChannelSelector.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import ChannelLoginForm from '../containers/ChannelLoginForm.jsx'; import ChannelCreateForm from '../containers/ChannelCreateForm.jsx'; @@ -68,9 +67,4 @@ 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 32d84dc0..4ab79fdf 100644 --- a/react/components/Preview.jsx +++ b/react/components/Preview.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import PropTypes from 'prop-types'; class Preview extends React.Component { constructor (props) { @@ -40,10 +39,4 @@ 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/PublishStatus.jsx b/react/components/PublishStatus.jsx index 0ca3951a..f7ba4799 100644 --- a/react/components/PublishStatus.jsx +++ b/react/components/PublishStatus.jsx @@ -1,22 +1,17 @@ import React from 'react'; import ProgressBar from '../components/ProgressBar.jsx'; - -const LOAD_START = 'LOAD_START'; -const LOADING = 'LOADING'; -const PUBLISHING = 'PUBLISHING'; -const SUCCESS = 'SUCCESS'; -const FAILED = 'FAILED'; +import * as publishStates from '../constants/publishing_states'; function PublishStatus ({ status, message }) { return (
- {(status === LOAD_START) && + {(status === publishStates.LOAD_START) &&

File is loading to server

{message}

} - {(status === LOADING) && + {(status === publishStates.LOADING) &&

File is loading to server

@@ -24,20 +19,20 @@ function PublishStatus ({ status, message }) {
} - {(status === PUBLISHING) && + {(status === publishStates.PUBLISHING) &&

Upload complete. Your file is now being published on the blockchain...

Curious what magic is happening here? Learn more.

} - {(status === SUCCESS) && + {(status === publishStates.SUCCESS) &&

Your publish is complete! You are being redirected to it now.

If you are not automatically redirected, click here.

} - {(status === FAILED) && + {(status === publishStates.FAILED) &&

Something went wrong...

{message}

diff --git a/react/containers/ChannelCreateForm.jsx b/react/containers/ChannelCreateForm.jsx index e1a74fa8..f8a0923f 100644 --- a/react/containers/ChannelCreateForm.jsx +++ b/react/containers/ChannelCreateForm.jsx @@ -4,7 +4,6 @@ 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) { @@ -171,8 +170,4 @@ 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 2e98a61e..e60042f8 100644 --- a/react/containers/ChannelLoginForm.jsx +++ b/react/containers/ChannelLoginForm.jsx @@ -4,7 +4,6 @@ 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) { @@ -83,8 +82,4 @@ const mapDispatchToProps = dispatch => { }; }; -ChannelLoginForm.propTypes = { - onChannelLogin: PropTypes.func.isRequired, -}; - export default connect(null, mapDispatchToProps)(ChannelLoginForm); diff --git a/react/containers/ChannelSelect.jsx b/react/containers/ChannelSelect.jsx index 925f48f8..3c74b3d2 100644 --- a/react/containers/ChannelSelect.jsx +++ b/react/containers/ChannelSelect.jsx @@ -1,9 +1,8 @@ import React from 'react'; import { setPublishInChannel } from '../actions/index'; import { connect } from 'react-redux'; -import PropTypes from 'prop-types'; -class AnonymousOrChannelSelect extends React.Component { +class channelSelect extends React.Component { constructor (props) { super(props); this.toggleAnonymousPublish = this.toggleAnonymousPublish.bind(this); @@ -46,9 +45,4 @@ const mapDispatchToProps = dispatch => { }; } -AnonymousOrChannelSelect.propTypes = { - publishInChannel : PropTypes.bool.isRequired, - onPublishInChannelChange: PropTypes.func.isRequired, -}; - -export default connect(mapStateToProps, mapDispatchToProps)(AnonymousOrChannelSelect); +export default connect(mapStateToProps, mapDispatchToProps)(channelSelect); diff --git a/react/containers/Dropzone.jsx b/react/containers/Dropzone.jsx index 23d6a2c6..1998a293 100644 --- a/react/containers/Dropzone.jsx +++ b/react/containers/Dropzone.jsx @@ -1,9 +1,8 @@ import React from 'react'; -import { selectFile, updateError } from '../actions'; import { connect } from 'react-redux'; -import Preview from '../components/Preview.jsx'; +import { selectFile, updateError } from '../actions'; import { validateFile } from '../utils/file.js'; -import PropTypes from 'prop-types'; +import Preview from '../components/Preview.jsx'; class Dropzone extends React.Component { constructor (props) { @@ -160,11 +159,4 @@ const mapDispatchToProps = dispatch => { }; }; -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 cd6e3713..74c99ecd 100644 --- a/react/containers/PublishForm.jsx +++ b/react/containers/PublishForm.jsx @@ -1,4 +1,6 @@ import React from 'react'; +import { connect } from 'react-redux'; +import { getCookie } from '../utils/cookies.js'; import PreviewDropzone from './Dropzone.jsx'; import PublishTitleInput from './PublishTitleInput.jsx'; import ChannelSelector from '../components/ChannelSelector.jsx'; @@ -6,11 +8,8 @@ import PublishUrlInput from './PublishUrlInput.jsx'; import PublishThumbnailInput from './PublishThumbnailInput.jsx'; import PublishMetadataInputs from './PublishMetadataInputs.jsx'; import AnonymousOrChannelSelect from './ChannelSelect.jsx'; -import { connect } from 'react-redux'; -import PropTypes from 'prop-types'; -import { getCookie } from '../utils/cookies.js'; import {selectFile, clearFile, updateLoggedInChannel, updatePublishStatus, updateError} from '../actions'; -import * as states from '../constants/publishing_states'; +import * as publishStates from '../constants/publishing_states'; class PublishForm extends React.Component { constructor (props) { @@ -55,18 +54,18 @@ class PublishForm extends React.Component { const fd = this.appendDataToFormData(file, metadata); const that = this; xhr.upload.addEventListener('loadstart', function () { - that.props.onPublishStatusChange(states.LOAD_START, 'upload started'); + that.props.onPublishStatusChange(publishStates.LOAD_START, 'upload started'); }); xhr.upload.addEventListener('progress', function (e) { if (e.lengthComputable) { const percentage = Math.round((e.loaded * 100) / e.total); console.log('progress:', percentage); - that.props.onPublishStatusChange(states.LOADING, `${percentage}%`); + that.props.onPublishStatusChange(publishStates.LOADING, `${percentage}%`); } }, false); xhr.upload.addEventListener('load', function () { console.log('loaded 100%'); - that.props.onPublishStatusChange(states.PUBLISHING, null); + that.props.onPublishStatusChange(publishStates.PUBLISHING, null); }, false); xhr.open('POST', uri, true); xhr.onreadystatechange = function () { @@ -75,12 +74,12 @@ class PublishForm extends React.Component { if (xhr.status === 200) { console.log('publish complete!'); const url = JSON.parse(xhr.response).message.url; - that.props.onPublishStatusChange(states.SUCCESS, url); + that.props.onPublishStatusChange(publishStates.SUCCESS, url); window.location = url; } else if (xhr.status === 502) { - that.props.onPublishStatusChange(states.FAILED, 'Spee.ch was not able to get a response from the LBRY network.'); + that.props.onPublishStatusChange(publishStates.FAILED, 'Spee.ch was not able to get a response from the LBRY network.'); } else { - that.props.onPublishStatusChange(states.FAILED, JSON.parse(xhr.response).message); + that.props.onPublishStatusChange(publishStates.FAILED, JSON.parse(xhr.response).message); } } }; @@ -226,24 +225,4 @@ 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, - publishSubmitError : PropTypes.string, - onFileSelect : PropTypes.func.isRequired, - onFileClear : PropTypes.func.isRequired, - onChannelLogin : PropTypes.func.isRequired, - onPublishStatusChange: PropTypes.func.isRequired, - onPublishSubmitError : PropTypes.func.isRequired, -}; - export default connect(mapStateToProps, mapDispatchToProps)(PublishForm); diff --git a/react/containers/PublishMetadataInputs.jsx b/react/containers/PublishMetadataInputs.jsx index f4317145..41921704 100644 --- a/react/containers/PublishMetadataInputs.jsx +++ b/react/containers/PublishMetadataInputs.jsx @@ -1,7 +1,6 @@ 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'); @@ -15,12 +14,15 @@ class MetadataInputs extends React.Component { constructor (props) { super(props); this.state = { - showInputs: false, + showInputs : false, + descriptionLimit : 200, + descriptionScrollHeight: null, }; this.toggleShowInputs = this.toggleShowInputs.bind(this); this.handleInput = this.handleInput.bind(this); this.handleCheck = this.handleCheck.bind(this); this.handleSelection = this.handleSelection.bind(this); + this.setDescriptionScrollHeight = this.setDescriptionScrollHeight.bind(this); } toggleShowInputs () { this.setState({'showInputs': !this.state.showInputs}); @@ -43,6 +45,10 @@ class MetadataInputs extends React.Component { const selectedOption = event.target.selectedOptions[0].value; this.props.onMetadataChange(name, selectedOption); } + setDescriptionScrollHeight (event) { + const scrollHeight = event.target.scrollHeight; + this.setState({descriptionScrollHeight: scrollHeight}); + } render () { return (
@@ -53,7 +59,16 @@ class MetadataInputs extends React.Component {
-