2017-12-28 20:51:03 +01:00
import React from 'react' ;
2018-01-04 23:14:03 +01:00
import PreviewDropzone from './previewDropzone.jsx' ;
import TitleInput from './titleInput.jsx' ;
import ChannelSelector from './channelSelector.jsx' ;
2018-01-05 03:34:17 +01:00
import UrlChooser from './urlChooser.jsx' ;
2018-01-04 23:14:03 +01:00
import ThumbnailInput from './thumbnailInput.jsx' ;
import MetadataInputs from './metadataInputs.jsx' ;
2017-12-28 20:51:03 +01:00
2018-01-05 01:10:25 +01:00
class AnonymousOrChannelSelect extends React . Component {
2018-01-03 02:12:57 +01:00
constructor ( props ) {
super ( props ) ;
2018-01-05 01:10:25 +01:00
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 (
< div className = "row row--padded row--short row--wide" >
< div className = "column column--10" >
< form >
< div className = "column column--3 column--med-10" >
< input type = "radio" name = "anonymous-or-channel" id = "anonymous-radio" className = "input-radio" value = "anonymous" checked = { ! this . props . publishToChannel } onChange = { this . toggleAnonymousPublish } / >
< label className = "label label--pointer" htmlFor = "anonymous-radio" > Anonymous < / label >
< / div >
< div className = "column column--7 column--med-10" >
< input type = "radio" name = "anonymous-or-channel" id = "channel-radio" className = "input-radio" value = "in a channel" checked = { this . props . publishToChannel } onChange = { this . toggleAnonymousPublish } / >
< label className = "label label--pointer" htmlFor = "channel-radio" > In a channel < / label >
< / div >
< / form >
< / div >
< / div >
) ;
}
}
class PublishForm extends React . Component {
constructor ( props ) {
super ( props ) ;
2018-01-03 02:12:57 +01:00
// set defaults
this . updateUploaderState = this . updateUploaderState . bind ( this ) ;
2018-01-04 19:39:51 +01:00
this . clearUploaderState = this . clearUploaderState . bind ( this ) ;
2018-01-04 23:00:02 +01:00
this . publish = this . publish . bind ( this ) ;
2018-01-03 02:12:57 +01:00
}
updateUploaderState ( name , value ) {
this . props . updateUploaderState ( name , value ) ;
}
2018-01-04 23:00:02 +01:00
clearUploaderState ( ) {
this . props . clearUploaderState ( ) ;
2018-01-03 02:12:57 +01:00
}
publish ( ) {
// publish the asset
}
2017-12-28 20:51:03 +01:00
render ( ) {
return (
2018-01-04 20:05:16 +01:00
< div className = "row row--no-bottom" >
2018-01-03 02:12:57 +01:00
< div className = "column column--10" >
2018-01-04 23:14:03 +01:00
< TitleInput title = { this . props . title } updateUploaderState = { this . updateUploaderState } / >
2018-01-03 02:12:57 +01:00
< / div >
< div className = "column column--5 column--sml-10" >
< div className = "row row--padded" >
2018-01-04 23:14:03 +01:00
< PreviewDropzone
2018-01-03 02:12:57 +01:00
file = { this . props . file }
/ >
2018-01-05 22:59:25 +01:00
{ ( this . props . file . type === 'video/mp4' ) && < ThumbnailInput thumbnail = { this . props . thumbnail } / > }
2017-12-28 20:51:03 +01:00
< / div >
2018-01-03 02:12:57 +01:00
< / div >
< div className = "column column--5 column--sml-10 align-content-top" >
< div id = "publish-active-area" className = "row row--padded" >
2018-01-04 23:14:03 +01:00
2018-01-05 03:34:17 +01:00
< UrlChooser
fileName = { this . props . file . name }
claim = { this . props . claim }
publishToChannel = { this . props . publishToChannel }
loggedInChannelName = { this . props . loggedInChannelName }
loggedInChannelShortId = { this . props . loggedInChannelShortId }
2018-01-05 22:59:25 +01:00
cleanseInput = { this . props . cleanseInput }
2018-01-05 03:34:17 +01:00
updateUploaderState = { this . updateUploaderState }
makeGetRequest = { this . props . makeGetRequest }
/ >
2018-01-05 19:31:49 +01:00
< AnonymousOrChannelSelect
publishToChannel = { this . props . publishToChannel }
updateUploaderState = { this . props . updateUploaderState }
/ >
2018-01-05 01:10:25 +01:00
< ChannelSelector
2018-01-05 20:09:32 +01:00
loggedInChannelName = { this . props . loggedInChannelName }
2018-01-05 01:10:25 +01:00
publishToChannel = { this . props . publishToChannel }
2018-01-05 22:59:25 +01:00
cleanseInput = { this . props . cleanseInput }
2018-01-05 01:10:25 +01:00
updateUploaderState = { this . updateUploaderState }
2018-01-05 22:59:25 +01:00
makeGetRequest = { this . props . makeGetRequest }
2018-01-06 00:11:45 +01:00
makePostRequest = { this . props . makePostRequest }
updateUploaderState = { this . props . updateUploaderState }
2018-01-05 01:10:25 +01:00
/ >
2018-01-04 23:14:03 +01:00
< MetadataInputs / >
2018-01-03 02:12:57 +01:00
< div className = "row row--padded row--wide" >
< div className = "input-error" id = "input-error-publish-submit" hidden = "true" > { this . props . inputError } < / div >
2018-01-06 01:47:55 +01:00
< button id = "publish-submit" className = "button--primary button--large" onClick = { this . publish } > Publish < / button >
2017-12-28 20:51:03 +01:00
< / div >
2018-01-03 02:12:57 +01:00
< div className = "row row--short align-content-center" >
2018-01-04 20:05:16 +01:00
< button className = "button--cancel" onClick = { this . clearUploaderState } > Cancel < / button >
2018-01-03 02:12:57 +01:00
< / div >
< div className = "row row--short align-content-center" >
< p className = "fine-print" > By clicking 'Upload' , you affirm that you have the rights to publish this content to the LBRY network , and that you understand the properties of publishing it to a decentralized , user - controlled network . < a className = "link--primary" target = "_blank" href = "https://lbry.io/learn" > Read more . < / a > < / p >
2017-12-28 20:51:03 +01:00
< / div >
2018-01-04 23:14:03 +01:00
2017-12-28 20:51:03 +01:00
< / div >
< / div >
< / div >
) ;
}
} ;
2018-01-05 01:10:25 +01:00
module . exports = PublishForm ;