2017-12-28 20:51:03 +01:00
|
|
|
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-05 01:10:25 +01:00
|
|
|
|
2018-01-10 03:49:26 +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
|
|
|
|
2018-01-05 01:10:25 +01:00
|
|
|
class PublishForm extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
2018-01-03 02:12:57 +01:00
|
|
|
// set defaults
|
2018-01-06 03:26:57 +01:00
|
|
|
this.state = {
|
|
|
|
error : null,
|
|
|
|
showMetadataInputs: false,
|
2018-01-09 02:06:31 +01:00
|
|
|
};
|
2018-01-04 23:00:02 +01:00
|
|
|
this.publish = this.publish.bind(this);
|
2018-01-03 02:12:57 +01:00
|
|
|
}
|
2018-01-10 03:25:38 +01:00
|
|
|
componentWillMount () {
|
2018-01-10 20:26:01 +01:00
|
|
|
// check for whether a channel is already logged in
|
2018-01-10 03:25:38 +01:00
|
|
|
const loggedInChannelName = getCookie('channel_name');
|
|
|
|
const loggedInChannelShortId = getCookie('short_channel_id');
|
|
|
|
const loggedInChannelLongId = getCookie('long_channel_id');
|
2018-01-10 20:26:01 +01:00
|
|
|
console.log(`channel cookies found: ${loggedInChannelName} ${loggedInChannelShortId} ${loggedInChannelLongId}`);
|
|
|
|
this.props.onChannelLogin(loggedInChannelName, loggedInChannelShortId, loggedInChannelLongId);
|
2018-01-10 03:25:38 +01:00
|
|
|
}
|
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
|
|
|
|
2018-01-09 02:46:17 +01:00
|
|
|
<PublishTitleInput />
|
2018-01-04 23:14:03 +01:00
|
|
|
|
2018-01-03 02:12:57 +01:00
|
|
|
</div>
|
|
|
|
<div className="column column--5 column--sml-10" >
|
2018-01-04 23:14:03 +01:00
|
|
|
|
2018-01-11 02:41:17 +01:00
|
|
|
<div className="row row--padded">
|
2018-01-10 03:25:38 +01:00
|
|
|
<PreviewDropzone />
|
2017-12-28 20:51:03 +01:00
|
|
|
</div>
|
2018-01-11 02:41:17 +01:00
|
|
|
|
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-10 20:26:01 +01:00
|
|
|
<div className="row row--padded row--no-top row--wide">
|
|
|
|
<PublishUrlInput />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="row row--padded row--no-top row--no-bottom row--wide">
|
|
|
|
<AnonymousOrChannelSelect />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="row row--padded row--no-top row--wide">
|
|
|
|
<ChannelSelector />
|
|
|
|
</div>
|
2018-01-04 23:14:03 +01:00
|
|
|
|
2018-01-11 02:41:17 +01:00
|
|
|
{ (this.props.fileType === 'video/mp4') && <PublishThumbnailInput /> }
|
|
|
|
|
2018-01-10 22:10:08 +01:00
|
|
|
<div className="row row--padded row--no-top row--no-bottom row--wide">
|
|
|
|
<PublishMetadataInputs />
|
|
|
|
</div>
|
2018-01-03 02:12:57 +01:00
|
|
|
|
|
|
|
<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>
|
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-09 02:06:31 +01:00
|
|
|
<button className="button--cancel" onClick={this.props.onFileClear}>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-09 02:06:31 +01:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
2018-01-11 02:41:17 +01:00
|
|
|
fileType: state.file.type,
|
|
|
|
claim : state.claim,
|
2018-01-09 02:06:31 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
onFileSelect: (file) => {
|
|
|
|
dispatch(selectFile(file));
|
|
|
|
},
|
|
|
|
onFileClear: () => {
|
|
|
|
dispatch(clearFile());
|
|
|
|
},
|
2018-01-10 20:26:01 +01:00
|
|
|
onChannelLogin: (name, shortId, longId) => {
|
2018-01-10 03:25:38 +01:00
|
|
|
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);
|