spee.ch/react/components/PublishForm.jsx

127 lines
4.5 KiB
React
Raw Normal View History

import React from 'react';
2018-01-06 03:26:57 +01:00
import PreviewDropzone from './PreviewDropzone.jsx';
2018-01-08 18:39:59 +01:00
import PublishTitleInput from './PublishTitleInput.jsx';
2018-01-06 03:26:57 +01:00
import ChannelSelector from './ChannelSelector.jsx';
2018-01-08 18:39:59 +01:00
import PublishUrlInput from './PublishUrlInput.jsx';
2018-01-06 03:26:57 +01:00
import PublishThumbnailInput from './PublishThumbnailInput.jsx';
import PublishMetadataInputs from './PublishMetadataInputs.jsx';
import AnonymousOrChannelSelect from './AnonymousOrChannelSelect.jsx';
2018-01-09 02:06:31 +01:00
import { selectFile, clearFile } from '../actions';
import { connect } from 'react-redux';
class PublishForm extends React.Component {
constructor (props) {
super(props);
// set defaults
2018-01-06 03:26:57 +01:00
this.state = {
error : null,
showMetadataInputs: false,
2018-01-09 02:06:31 +01:00
};
this.publish = this.publish.bind(this);
}
publish () {
// publish the asset
}
render () {
return (
2018-01-04 20:05:16 +01:00
<div className="row row--no-bottom">
<div className="column column--10">
2018-01-04 23:14:03 +01:00
2018-01-08 18:39:59 +01:00
<PublishTitleInput
2018-01-06 03:26:57 +01:00
title={this.props.title}
2018-01-08 18:39:59 +01:00
updateUploaderState={this.props.updateUploaderState}
2018-01-06 03:26:57 +01:00
/>
2018-01-04 23:14:03 +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
file={this.props.file}
/>
2018-01-06 03:26:57 +01:00
{ (this.props.file.type === 'video/mp4') &&
<PublishThumbnailInput
thumbnail={this.props.thumbnail}
/>
}
</div>
</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-08 18:39:59 +01:00
<PublishUrlInput
2018-01-05 03:34:17 +01:00
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-06 03:26:57 +01:00
updateUploaderState={this.props.updateUploaderState}
2018-01-05 03:34:17 +01:00
makeGetRequest={this.props.makeGetRequest}
/>
2018-01-05 19:31:49 +01:00
<AnonymousOrChannelSelect
publishToChannel={this.props.publishToChannel}
updateUploaderState={this.props.updateUploaderState}
/>
<ChannelSelector
loggedInChannelName={this.props.loggedInChannelName}
publishToChannel={this.props.publishToChannel}
2018-01-05 22:59:25 +01:00
cleanseInput={this.props.cleanseInput}
2018-01-06 03:26:57 +01:00
updateUploaderState={this.props.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}
/>
2018-01-04 23:14:03 +01:00
2018-01-06 03:26:57 +01:00
<PublishMetadataInputs
updateUploaderState={this.props.updateUploaderState}
/>
<div className="row row--padded row--wide">
2018-01-06 03:26:57 +01:00
<div className="input-error" id="input-error-publish-submit" hidden="true">{this.state.error}</div>
2018-01-06 01:47:55 +01:00
<button id="publish-submit" className="button--primary button--large" onClick={this.publish}>Publish</button>
</div>
<div className="row row--short align-content-center">
2018-01-09 02:06:31 +01:00
<button className="button--cancel" onClick={this.props.onFileClear}>Cancel</button>
</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>
</div>
2018-01-04 23:14:03 +01:00
</div>
</div>
</div>
);
}
};
2018-01-09 02:06:31 +01:00
const mapStateToProps = state => {
return {
loggedInChannelName : state.loggedInChannelName,
loggedInChannelShortId: state.loggedInChannelShortId,
publishToChannel : state.publishToChannel,
file : state.file,
title : state.title,
claim : state.claim,
thumbnail : state.thumbnail,
description : state.description,
license : state.license,
nsfw : state.nsfw,
};
};
const mapDispatchToProps = dispatch => {
return {
onFileSelect: (file) => {
dispatch(selectFile(file));
},
onFileClear: () => {
dispatch(clearFile());
},
};
}
export default connect(mapStateToProps, mapDispatchToProps)(PublishForm);