From ac0290ae15c95974adc92221a071412e02c35d6e Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 4 Jan 2018 16:10:25 -0800 Subject: [PATCH] added anonymous/inChannel toggles to publish form --- react/components/channelSelector.jsx | 66 ++++++++++- .../{publishDetails.jsx => publishForm.jsx} | 50 ++++++++- react/components/urlInput.jsx | 26 +++++ react/uploader.js | 32 ++++-- views/partials/publishForm-Channel.handlebars | 105 ------------------ 5 files changed, 157 insertions(+), 122 deletions(-) rename react/components/{publishDetails.jsx => publishForm.jsx} (55%) diff --git a/react/components/channelSelector.jsx b/react/components/channelSelector.jsx index 5598b0fb..e3f73c6e 100644 --- a/react/components/channelSelector.jsx +++ b/react/components/channelSelector.jsx @@ -1,10 +1,72 @@ import React from 'react'; -class ChannelSelector extends React.Component { +const LOGIN = 'login'; +const CREATE = 'create'; + +class ChannelLoginForm extends React.Component { + constructor (props) { + super(props); + } render () { return (
-

channel component

+

Channel Login Form

+
+ ); + } +} + +class ChannelCreateForm extends React.Component { + constructor (props) { + super(props); + } + render () { + return ( +
+

Create Channel Form

+
+ ); + } +} + +class ChannelSelector extends React.Component { + constructor (props) { + super(props); + this.state = { + displayCreateOrLogin: LOGIN, + }; + this.toggleCreateOrLogin = this.toggleCreateOrLogin.bind(this); + } + toggleCreateOrLogin (event) { + const selectedOption = event.target.selectedOptions[0].value; + if (selectedOption === 'login') { + this.setState({ displayCreateOrLogin: LOGIN }); + } else { + this.setState({ displayCreateOrLogin: CREATE }); + } + } + render () { + return ( +
+ { this.props.publishToChannel && ( +
+ +

{this.props.channelError}

+ +
+ +
+ +
+ + { (this.state.displayCreateOrLogin === LOGIN) ? : } + +
+ )}
); } diff --git a/react/components/publishDetails.jsx b/react/components/publishForm.jsx similarity index 55% rename from react/components/publishDetails.jsx rename to react/components/publishForm.jsx index e73f5c23..839c3c9a 100644 --- a/react/components/publishDetails.jsx +++ b/react/components/publishForm.jsx @@ -6,9 +6,45 @@ import UrlInput from './urlInput.jsx'; import ThumbnailInput from './thumbnailInput.jsx'; import MetadataInputs from './metadataInputs.jsx'; -class PublishDetails extends React.Component { +class AnonymousOrChannelSelect extends React.Component { constructor (props) { super(props); + this.toggleAnonymousPublish = this.toggleAnonymousPublish.bind(this); + } + toggleAnonymousPublish (event) { + const value = event.target.value; + if (value === 'anonymous') { + this.props.updateUploaderState('publishToChannel', false); + } else { + this.props.updateUploaderState('publishToChannel', true); + } + } + render () { + return ( +
+
+
+
+ + +
+
+ + +
+
+
+
+ ); + } +} + +class PublishForm extends React.Component { + constructor (props) { + super(props); + this.state = { + channelError: null, + } // set defaults this.updateUploaderState = this.updateUploaderState.bind(this); this.clearUploaderState = this.clearUploaderState.bind(this); @@ -43,7 +79,15 @@ class PublishDetails extends React.Component {
- + + + @@ -71,4 +115,4 @@ class PublishDetails extends React.Component { } }; -module.exports = PublishDetails; +module.exports = PublishForm; diff --git a/react/components/urlInput.jsx b/react/components/urlInput.jsx index 5edc96e4..9105b33b 100644 --- a/react/components/urlInput.jsx +++ b/react/components/urlInput.jsx @@ -1,6 +1,32 @@ import React from 'react'; class UrlInput extends React.Component { + constructor (props) { + super(props); + this.updateUrl = this.updateUrl.bind(this); + } + updateUrl (selectedOption) { + const urlChannel = document.getElementById('url-channel'); + const urlNoChannelPlaceholder = document.getElementById('url-no-channel-placeholder'); + const urlChannelPlaceholder = document.getElementById('url-channel-placeholder'); + if (selectedOption === 'new' || selectedOption === 'login' || selectedOption === ''){ + urlChannel.hidden = true; + urlNoChannelPlaceholder.hidden = true; + urlChannelPlaceholder.hidden = false; + } else if (selectedOption === 'anonymous'){ + urlChannel.hidden = true; + urlNoChannelPlaceholder.hidden = false; + urlChannelPlaceholder.hidden = true; + } else { + urlChannel.hidden = false; + // show channel and short id + const selectedChannel = getCookie('channel_name'); + const shortChannelId = getCookie('short_channel_id'); + urlChannel.innerText = `${selectedChannel}:${shortChannelId}`; + urlNoChannelPlaceholder.hidden = true; + urlChannelPlaceholder.hidden = true; + } + } render () { return (
diff --git a/react/uploader.js b/react/uploader.js index 65f06ea3..4c980d6e 100644 --- a/react/uploader.js +++ b/react/uploader.js @@ -1,23 +1,25 @@ import React from 'react'; import ReactDOM from 'react-dom'; import Dropzone from './components/dropzone.jsx'; -import PublishDetails from './components/publishDetails.jsx'; +import PublishForm from './components/publishForm.jsx'; import PublishStatus from './components/publishStatus.jsx'; const DROPZONE = 'DROPZONE'; const DETAILS = 'DETAILS'; const STATUS = 'STATUS'; const initialState = { - showComponent: DROPZONE, // DROPZONE, DETAILS, or PUBLISHING - file : null, - title : '', - channel : '', - url : '', - thumbnail : '', - description : '', - license : '', - nsfw : '', -} + showComponent : DROPZONE, // DROPZONE, DETAILS, or PUBLISHING + loggedInChannel : null, + publishToChannel: false, + file : null, + title : '', + channel : null, + url : '', + thumbnail : '', + description : '', + license : '', + nsfw : '', +}; class Uploader extends React.Component { constructor (props) { @@ -29,6 +31,10 @@ class Uploader extends React.Component { this.showComponent = this.showComponent.bind(this); this.stageFileAndShowDetails = this.stageFileAndShowDetails.bind(this); } + componentDidMount () { + // check for whether a channel is logged in + // if so, setState loggedInChannel to the channel name + } updateUploaderState (name, value) { console.log(`updateUploaderState ${name} ${value}`); this.setState({[name]: value}); @@ -53,9 +59,11 @@ class Uploader extends React.Component { } { this.state.showComponent === DETAILS && - -
-
-
-
- - -
- - -
-
-
-
- -
-
- -

- -
- -
- -
-
- -
- {{> channelLoginForm}} -
- - -
- - \ No newline at end of file