spee.ch/react/components/PublishForm.jsx

115 lines
4 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-10 03:25:38 +01:00
import {selectFile, clearFile, updateLoggedInChannel} from '../actions';
2018-01-09 02:06:31 +01:00
import { connect } from 'react-redux';
2018-01-10 03:25:38 +01:00
import { getCookie } from '../utils/cookies.js';
2018-01-09 02:06:31 +01:00
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);
}
2018-01-10 03:25:38 +01:00
componentWillMount () {
// check for whether a channel is logged in
// if so, set the loggedInChannel to the channel name
const loggedInChannelName = getCookie('channel_name');
const loggedInChannelShortId = getCookie('short_channel_id');
const loggedInChannelLongId = getCookie('long_channel_id');
this.props.onChannelUpdate(loggedInChannelName, loggedInChannelShortId, loggedInChannelLongId);
}
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
<PublishTitleInput />
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
2018-01-10 03:25:38 +01:00
<PreviewDropzone />
{ (this.props.fileType === 'video/mp4') && <PublishThumbnailInput /> }
</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-10 03:25:38 +01:00
<PublishUrlInput />
<AnonymousOrChannelSelect />
<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 {
2018-01-10 03:25:38 +01:00
fileType : state.file.type,
claim : state.claim,
thumbnail : state.thumbnail,
description: state.description,
license : state.license,
nsfw : state.nsfw,
2018-01-09 02:06:31 +01:00
};
};
const mapDispatchToProps = dispatch => {
return {
onFileSelect: (file) => {
dispatch(selectFile(file));
},
onFileClear: () => {
dispatch(clearFile());
},
2018-01-10 03:25:38 +01:00
onChannelUpdate: (name, shortId, longId) => {
dispatch(updateLoggedInChannel(name, shortId, longId));
},
2018-01-09 02:06:31 +01:00
};
2018-01-10 03:25:38 +01:00
};
2018-01-09 02:06:31 +01:00
export default connect(mapStateToProps, mapDispatchToProps)(PublishForm);