2016-11-22 21:19:08 +01:00
|
|
|
import React from 'react';
|
|
|
|
import lbry from '../lbry.js';
|
2017-04-11 03:45:41 +02:00
|
|
|
import uri from '../uri.js';
|
2017-04-10 14:32:40 +02:00
|
|
|
import {FormField, FormRow} from '../component/form.js';
|
2016-11-22 21:19:08 +01:00
|
|
|
import {Link} from '../component/link.js';
|
2017-04-12 22:23:20 +02:00
|
|
|
import rewards from '../rewards.js';
|
2017-04-13 20:52:26 +02:00
|
|
|
import lbryio from '../lbryio.js';
|
2016-11-22 21:19:08 +01:00
|
|
|
import Modal from '../component/modal.js';
|
|
|
|
|
2016-05-23 17:14:21 +02:00
|
|
|
var PublishPage = React.createClass({
|
2017-04-14 01:39:59 +02:00
|
|
|
_requiredFields: ['meta_title', 'name', 'bid', 'tos_agree'],
|
2016-07-26 12:09:09 +02:00
|
|
|
|
2017-04-10 10:06:15 +02:00
|
|
|
_updateChannelList: function(channel) {
|
|
|
|
// Calls API to update displayed list of channels. If a channel name is provided, will select
|
|
|
|
// that channel at the same time (used immediately after creating a channel)
|
|
|
|
lbry.channel_list_mine().then((channels) => {
|
2017-04-15 00:23:42 +02:00
|
|
|
rewards.claimReward(rewards.TYPE_FIRST_CHANNEL).then(() => {}, () => {})
|
2017-04-10 10:06:15 +02:00
|
|
|
this.setState({
|
|
|
|
channels: channels,
|
|
|
|
... channel ? {channel} : {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2016-10-19 08:36:42 +02:00
|
|
|
handleSubmit: function(event) {
|
|
|
|
if (typeof event !== 'undefined') {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
2016-07-21 08:58:06 +02:00
|
|
|
this.setState({
|
|
|
|
submitting: true,
|
|
|
|
});
|
|
|
|
|
2017-04-12 16:55:19 +02:00
|
|
|
let checkFields = this._requiredFields;
|
2016-09-17 07:45:42 +02:00
|
|
|
if (!this.state.myClaimExists) {
|
2017-04-12 16:55:19 +02:00
|
|
|
checkFields.unshift('file');
|
2016-08-08 11:53:41 +02:00
|
|
|
}
|
|
|
|
|
2017-04-12 16:55:19 +02:00
|
|
|
let missingFieldFound = false;
|
2016-08-08 11:53:41 +02:00
|
|
|
for (let fieldName of checkFields) {
|
2017-04-12 16:55:19 +02:00
|
|
|
const field = this.refs[fieldName];
|
|
|
|
if (field) {
|
|
|
|
if (field.getValue() === '' || field.getValue() === false) {
|
|
|
|
field.showRequiredError();
|
|
|
|
if (!missingFieldFound) {
|
|
|
|
field.focus();
|
|
|
|
missingFieldFound = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
field.clearError();
|
2016-07-26 12:09:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-08 20:11:58 +01:00
|
|
|
if (missingFieldFound) {
|
2016-07-26 12:09:09 +02:00
|
|
|
this.setState({
|
|
|
|
submitting: false,
|
|
|
|
});
|
2016-07-27 13:46:48 +02:00
|
|
|
return;
|
2016-07-26 12:09:09 +02:00
|
|
|
}
|
2016-07-20 08:25:22 +02:00
|
|
|
|
2016-08-23 07:03:03 +02:00
|
|
|
if (this.state.nameIsMine) {
|
|
|
|
// Pre-populate with existing metadata
|
2016-09-17 07:45:42 +02:00
|
|
|
var metadata = Object.assign({}, this.state.myClaimMetadata);
|
2016-08-23 07:03:03 +02:00
|
|
|
if (this.refs.file.getValue() !== '') {
|
|
|
|
delete metadata.sources;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var metadata = {};
|
|
|
|
}
|
2016-08-27 08:18:19 +02:00
|
|
|
|
2017-04-13 22:40:29 +02:00
|
|
|
for (let metaField of ['title', 'description', 'thumbnail', 'license', 'license_url', 'language']) {
|
2016-07-27 17:57:18 +02:00
|
|
|
var value = this.refs['meta_' + metaField].getValue();
|
2016-07-27 19:54:25 +02:00
|
|
|
if (value !== '') {
|
2016-07-26 12:09:09 +02:00
|
|
|
metadata[metaField] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 22:40:29 +02:00
|
|
|
metadata.nsfw = Boolean(parseInt(!!this.refs.meta_nsfw.getValue()));
|
|
|
|
|
|
|
|
const licenseUrl = this.refs.meta_license_url.getValue();
|
2016-07-27 17:57:18 +02:00
|
|
|
if (licenseUrl) {
|
|
|
|
metadata.license_url = licenseUrl;
|
|
|
|
}
|
2016-07-20 08:25:22 +02:00
|
|
|
|
2016-07-21 08:58:06 +02:00
|
|
|
var doPublish = () => {
|
2016-08-08 11:53:41 +02:00
|
|
|
var publishArgs = {
|
|
|
|
name: this.state.name,
|
2016-07-21 08:58:06 +02:00
|
|
|
bid: parseFloat(this.state.bid),
|
|
|
|
metadata: metadata,
|
2017-04-10 10:07:48 +02:00
|
|
|
... this.state.channel != 'new' && this.state.channel != 'anonymous' ? {channel_name: this.state.channel} : {},
|
2016-08-08 11:53:41 +02:00
|
|
|
};
|
|
|
|
|
2016-08-23 07:03:03 +02:00
|
|
|
if (this.refs.file.getValue() !== '') {
|
2017-04-12 18:59:43 +02:00
|
|
|
publishArgs.file_path = this.refs.file.getValue();
|
2016-08-08 11:53:41 +02:00
|
|
|
}
|
2017-04-10 14:32:40 +02:00
|
|
|
|
2016-08-08 11:53:41 +02:00
|
|
|
lbry.publish(publishArgs, (message) => {
|
2016-09-16 17:23:39 +02:00
|
|
|
this.handlePublishStarted();
|
|
|
|
}, null, (error) => {
|
2016-07-21 08:58:06 +02:00
|
|
|
this.handlePublishError(error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-07-20 08:25:22 +02:00
|
|
|
if (this.state.isFee) {
|
2017-04-10 19:44:54 +02:00
|
|
|
lbry.getUnusedAddress((address) => {
|
2016-07-30 07:47:37 +02:00
|
|
|
metadata.fee = {};
|
|
|
|
metadata.fee[this.state.feeCurrency] = {
|
|
|
|
amount: parseFloat(this.state.feeAmount),
|
|
|
|
address: address,
|
2016-07-21 08:58:06 +02:00
|
|
|
};
|
2016-07-20 08:25:22 +02:00
|
|
|
|
2016-07-21 08:58:06 +02:00
|
|
|
doPublish();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
doPublish();
|
|
|
|
}
|
2016-05-23 17:14:21 +02:00
|
|
|
},
|
2016-07-15 14:04:47 +02:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2017-04-08 14:30:17 +02:00
|
|
|
channels: null,
|
2016-11-18 09:49:16 +01:00
|
|
|
rawName: '',
|
2016-07-15 14:04:47 +02:00
|
|
|
name: '',
|
2017-04-12 18:59:43 +02:00
|
|
|
bid: 1,
|
2017-04-10 20:12:07 +02:00
|
|
|
hasFile: false,
|
2016-07-30 07:47:37 +02:00
|
|
|
feeAmount: '',
|
2016-08-08 11:47:20 +02:00
|
|
|
feeCurrency: 'USD',
|
2017-04-10 10:07:48 +02:00
|
|
|
channel: 'anonymous',
|
2017-04-08 14:30:17 +02:00
|
|
|
newChannelName: '@',
|
2017-04-12 18:59:43 +02:00
|
|
|
newChannelBid: 10,
|
2017-04-14 19:44:06 +02:00
|
|
|
nameResolved: null,
|
|
|
|
myClaimExists: null,
|
2016-09-17 07:45:42 +02:00
|
|
|
topClaimValue: 0.0,
|
|
|
|
myClaimValue: 0.0,
|
|
|
|
myClaimMetadata: null,
|
2016-09-20 12:40:24 +02:00
|
|
|
copyrightNotice: '',
|
|
|
|
otherLicenseDescription: '',
|
|
|
|
otherLicenseUrl: '',
|
2016-07-20 08:25:22 +02:00
|
|
|
uploadProgress: 0.0,
|
|
|
|
uploaded: false,
|
2016-10-21 09:56:37 +02:00
|
|
|
errorMessage: null,
|
2016-07-21 08:58:06 +02:00
|
|
|
submitting: false,
|
2017-04-08 14:30:17 +02:00
|
|
|
creatingChannel: false,
|
2016-10-21 09:56:37 +02:00
|
|
|
modal: null,
|
2016-07-15 14:04:47 +02:00
|
|
|
};
|
|
|
|
},
|
2016-09-16 17:23:39 +02:00
|
|
|
handlePublishStarted: function() {
|
2016-10-21 09:56:37 +02:00
|
|
|
this.setState({
|
|
|
|
modal: 'publishStarted',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handlePublishStartedConfirmed: function() {
|
2016-09-23 11:19:39 +02:00
|
|
|
window.location = "?published";
|
2016-07-21 08:58:06 +02:00
|
|
|
},
|
|
|
|
handlePublishError: function(error) {
|
2016-10-21 09:56:37 +02:00
|
|
|
this.setState({
|
|
|
|
submitting: false,
|
|
|
|
modal: 'error',
|
|
|
|
errorMessage: error.message,
|
|
|
|
});
|
2016-07-21 08:58:06 +02:00
|
|
|
},
|
2016-07-15 14:04:47 +02:00
|
|
|
handleNameChange: function(event) {
|
2016-09-01 09:30:12 +02:00
|
|
|
var rawName = event.target.value;
|
2016-07-15 14:04:47 +02:00
|
|
|
|
2016-09-01 09:30:12 +02:00
|
|
|
if (!rawName) {
|
2016-07-15 14:04:47 +02:00
|
|
|
this.setState({
|
2016-11-18 09:49:16 +01:00
|
|
|
rawName: '',
|
2016-07-15 14:04:47 +02:00
|
|
|
name: '',
|
|
|
|
nameResolved: false,
|
2016-07-20 08:25:22 +02:00
|
|
|
});
|
2016-07-15 14:04:47 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-18 10:01:25 +01:00
|
|
|
if (!lbry.nameIsValid(rawName, false)) {
|
2017-04-09 17:06:23 +02:00
|
|
|
this.refs.name.showError('LBRY names must contain only letters, numbers and dashes.');
|
2016-11-18 10:01:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-14 19:44:06 +02:00
|
|
|
const name = rawName.toLowerCase();
|
2016-11-18 09:49:16 +01:00
|
|
|
this.setState({
|
|
|
|
rawName: rawName,
|
2017-04-14 19:44:06 +02:00
|
|
|
name: name,
|
|
|
|
nameResolved: null,
|
|
|
|
myClaimExists: null,
|
2016-11-18 09:49:16 +01:00
|
|
|
});
|
|
|
|
|
2017-04-11 06:12:34 +02:00
|
|
|
lbry.getMyClaim(name, (myClaimInfo) => {
|
2017-04-14 19:44:06 +02:00
|
|
|
if (name != this.state.name) {
|
2016-09-01 09:30:12 +02:00
|
|
|
// A new name has been typed already, so bail
|
2016-08-10 09:05:17 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-04-14 19:44:06 +02:00
|
|
|
|
|
|
|
this.setState({
|
|
|
|
myClaimExists: !!myClaimInfo,
|
|
|
|
});
|
2017-04-11 06:12:34 +02:00
|
|
|
lbry.resolve({uri: name}).then((claimInfo) => {
|
2017-04-14 19:44:06 +02:00
|
|
|
if (name != this.state.name) {
|
2017-04-11 06:12:34 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-04-11 03:45:41 +02:00
|
|
|
|
2017-04-11 06:12:34 +02:00
|
|
|
if (!claimInfo) {
|
|
|
|
this.setState({
|
|
|
|
nameResolved: false,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
|
2017-04-11 03:45:41 +02:00
|
|
|
const newState = {
|
|
|
|
nameResolved: true,
|
2017-04-11 06:12:34 +02:00
|
|
|
topClaimValue: parseFloat(claimInfo.claim.amount),
|
2017-04-11 03:45:41 +02:00
|
|
|
myClaimExists: !!myClaimInfo,
|
2017-04-11 06:12:34 +02:00
|
|
|
myClaimValue: myClaimInfo ? parseFloat(myClaimInfo.claim.amount) : null,
|
2017-04-11 03:45:41 +02:00
|
|
|
myClaimMetadata: myClaimInfo ? myClaimInfo.value : null,
|
|
|
|
topClaimIsMine: topClaimIsMine,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (topClaimIsMine) {
|
2017-04-11 06:12:34 +02:00
|
|
|
newState.bid = myClaimInfo.claim.amount;
|
2017-04-11 03:45:41 +02:00
|
|
|
} else if (this.state.myClaimMetadata) {
|
|
|
|
// Just changed away from a name we have a claim on, so clear pre-fill
|
|
|
|
newState.bid = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState(newState);
|
2017-04-11 06:12:34 +02:00
|
|
|
}
|
|
|
|
}, () => { // Assume an error means the name is available
|
|
|
|
this.setState({
|
|
|
|
name: name,
|
|
|
|
nameResolved: false,
|
|
|
|
myClaimExists: false,
|
2016-07-15 14:04:47 +02:00
|
|
|
});
|
2017-04-11 03:45:41 +02:00
|
|
|
});
|
2016-07-15 14:04:47 +02:00
|
|
|
});
|
|
|
|
},
|
2016-07-20 08:25:22 +02:00
|
|
|
handleBidChange: function(event) {
|
2016-07-15 14:04:47 +02:00
|
|
|
this.setState({
|
2016-07-20 08:25:22 +02:00
|
|
|
bid: event.target.value,
|
2016-07-15 14:04:47 +02:00
|
|
|
});
|
|
|
|
},
|
2016-07-30 07:47:37 +02:00
|
|
|
handleFeeAmountChange: function(event) {
|
2016-07-15 14:04:47 +02:00
|
|
|
this.setState({
|
2016-07-30 07:47:37 +02:00
|
|
|
feeAmount: event.target.value,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleFeeCurrencyChange: function(event) {
|
|
|
|
this.setState({
|
|
|
|
feeCurrency: event.target.value,
|
2016-07-20 08:25:22 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
handleFeePrefChange: function(feeEnabled) {
|
|
|
|
this.setState({
|
|
|
|
isFee: feeEnabled
|
2016-07-15 14:04:47 +02:00
|
|
|
});
|
|
|
|
},
|
2017-04-10 20:12:07 +02:00
|
|
|
handleLicenseChange: function(event) {
|
2016-09-20 12:40:24 +02:00
|
|
|
var licenseType = event.target.options[event.target.selectedIndex].getAttribute('data-license-type');
|
|
|
|
var newState = {
|
|
|
|
copyrightChosen: licenseType == 'copyright',
|
|
|
|
otherLicenseChosen: licenseType == 'other',
|
|
|
|
};
|
|
|
|
|
|
|
|
if (licenseType == 'copyright') {
|
2017-04-10 20:12:07 +02:00
|
|
|
newState.copyrightNotice = 'All rights reserved.'
|
2016-09-20 12:40:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setState(newState);
|
|
|
|
},
|
|
|
|
handleCopyrightNoticeChange: function(event) {
|
|
|
|
this.setState({
|
|
|
|
copyrightNotice: event.target.value,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleOtherLicenseDescriptionChange: function(event) {
|
|
|
|
this.setState({
|
|
|
|
otherLicenseDescription: event.target.value,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleOtherLicenseUrlChange: function(event) {
|
|
|
|
this.setState({
|
|
|
|
otherLicenseUrl: event.target.value,
|
|
|
|
});
|
|
|
|
},
|
2017-04-08 14:30:17 +02:00
|
|
|
handleChannelChange: function (event) {
|
|
|
|
const channel = event.target.value;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
channel: channel,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleNewChannelNameChange: function (event) {
|
|
|
|
const newChannelName = (event.target.value.startsWith('@') ? event.target.value : '@' + event.target.value);
|
|
|
|
|
|
|
|
if (newChannelName.length > 1 && !lbry.nameIsValid(newChannelName.substr(1), false)) {
|
2017-04-10 20:12:07 +02:00
|
|
|
this.refs.newChannelName.showError('LBRY channel names must contain only letters, numbers and dashes.');
|
2017-04-08 14:30:17 +02:00
|
|
|
return;
|
2017-04-12 16:55:19 +02:00
|
|
|
} else {
|
|
|
|
this.refs.newChannelName.clearError()
|
2017-04-08 14:30:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
newChannelName: newChannelName,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleNewChannelBidChange: function (event) {
|
|
|
|
this.setState({
|
|
|
|
newChannelBid: event.target.value,
|
|
|
|
});
|
|
|
|
},
|
2017-04-14 01:39:59 +02:00
|
|
|
handleTOSChange: function(event) {
|
|
|
|
this.setState({
|
|
|
|
TOSAgreed: event.target.checked,
|
|
|
|
});
|
|
|
|
},
|
2017-04-08 14:30:17 +02:00
|
|
|
handleCreateChannelClick: function (event) {
|
2017-04-10 10:08:43 +02:00
|
|
|
if (this.state.newChannelName.length < 5) {
|
2017-04-10 20:12:07 +02:00
|
|
|
this.refs.newChannelName.showError('LBRY channel names must be at least 4 characters in length.');
|
2017-04-10 10:08:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-08 14:30:17 +02:00
|
|
|
this.setState({
|
|
|
|
creatingChannel: true,
|
|
|
|
});
|
|
|
|
|
2017-04-10 10:06:15 +02:00
|
|
|
const newChannelName = this.state.newChannelName;
|
|
|
|
lbry.channel_new({channel_name: newChannelName, amount: parseInt(this.state.newChannelBid)}).then(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setState({
|
|
|
|
creatingChannel: false,
|
|
|
|
});
|
2017-04-08 14:30:17 +02:00
|
|
|
|
2017-04-10 10:06:15 +02:00
|
|
|
this._updateChannelList(newChannelName);
|
|
|
|
}, 5000);
|
2017-04-08 14:30:17 +02:00
|
|
|
}, (error) => {
|
2017-04-10 10:09:01 +02:00
|
|
|
// TODO: better error handling
|
2017-04-10 20:12:07 +02:00
|
|
|
this.refs.newChannelName.showError('Unable to create channel due to an internal error.');
|
2017-04-08 14:30:17 +02:00
|
|
|
this.setState({
|
|
|
|
creatingChannel: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2016-09-20 12:40:24 +02:00
|
|
|
getLicenseUrl: function() {
|
|
|
|
if (!this.refs.meta_license) {
|
|
|
|
return '';
|
|
|
|
} else if (this.state.otherLicenseChosen) {
|
|
|
|
return this.state.otherLicenseUrl;
|
|
|
|
} else {
|
2016-09-21 08:57:20 +02:00
|
|
|
return this.refs.meta_license.getSelectedElement().getAttribute('data-url') || '' ;
|
2016-09-20 12:40:24 +02:00
|
|
|
}
|
|
|
|
},
|
2017-04-08 14:30:17 +02:00
|
|
|
componentWillMount: function() {
|
2017-04-10 10:06:15 +02:00
|
|
|
this._updateChannelList();
|
2017-04-08 14:30:17 +02:00
|
|
|
},
|
2016-08-08 00:13:17 +02:00
|
|
|
componentDidMount: function() {
|
|
|
|
document.title = "Publish";
|
|
|
|
},
|
2016-07-27 17:57:18 +02:00
|
|
|
componentDidUpdate: function() {
|
|
|
|
},
|
2017-04-10 20:12:07 +02:00
|
|
|
onFileChange: function() {
|
|
|
|
if (this.refs.file.getValue()) {
|
|
|
|
this.setState({ hasFile: true })
|
|
|
|
} else {
|
|
|
|
this.setState({ hasFile: false })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getNameBidHelpText: function() {
|
|
|
|
if (!this.state.name) {
|
|
|
|
return "Select a URL for this publish.";
|
2017-04-14 19:44:06 +02:00
|
|
|
} else if (this.state.nameResolved === false) {
|
2017-04-10 20:12:07 +02:00
|
|
|
return "This URL is unused.";
|
|
|
|
} else if (this.state.myClaimExists) {
|
|
|
|
return "You have already used this URL. Publishing to it again will update your previous publish."
|
|
|
|
} else if (this.state.topClaimValue) {
|
2017-04-12 16:55:19 +02:00
|
|
|
return <span>A deposit of at least <strong>{this.state.topClaimValue}</strong> {this.state.topClaimValue == 1 ? 'credit ' : 'credits '}
|
2017-04-14 19:44:06 +02:00
|
|
|
is required to win <strong>{this.state.name}</strong>. However, you can still get a permanent URL for any amount.</span>
|
2017-04-10 20:12:07 +02:00
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
},
|
2017-04-12 16:55:19 +02:00
|
|
|
closeModal: function() {
|
|
|
|
this.setState({
|
|
|
|
modal: null,
|
|
|
|
});
|
|
|
|
},
|
2016-07-27 17:57:18 +02:00
|
|
|
render: function() {
|
2017-04-08 14:30:17 +02:00
|
|
|
if (this.state.channels === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-04-12 16:55:19 +02:00
|
|
|
const lbcInputHelp = "This LBC remains yours and the deposit can be undone at any time."
|
|
|
|
|
2016-05-23 17:14:21 +02:00
|
|
|
return (
|
2016-08-08 05:31:21 +02:00
|
|
|
<main ref="page">
|
2016-10-19 04:30:57 +02:00
|
|
|
<form onSubmit={this.handleSubmit}>
|
|
|
|
<section className="card">
|
2017-04-10 14:32:40 +02:00
|
|
|
<div className="card__title-primary">
|
2017-04-10 20:12:07 +02:00
|
|
|
<h4>Content</h4>
|
|
|
|
<div className="card__subtitle">
|
|
|
|
What are you publishing?
|
|
|
|
</div>
|
2017-04-10 14:32:40 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-04-10 20:12:07 +02:00
|
|
|
<FormRow name="file" label="File" ref="file" type="file" onChange={this.onFileChange}
|
|
|
|
helper={this.state.myClaimExists ? "If you don't choose a file, the file from your existing claim will be used." : null}/>
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
{ !this.state.hasFile ? '' :
|
2017-04-12 16:55:19 +02:00
|
|
|
<div>
|
|
|
|
<div className="card__content">
|
2017-04-12 18:59:43 +02:00
|
|
|
<FormRow label="Title" type="text" ref="meta_title" name="title" placeholder="Titular Title" />
|
2017-04-12 16:55:19 +02:00
|
|
|
</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="card__content">
|
2017-04-12 18:59:43 +02:00
|
|
|
<FormRow type="text" label="Thumbnail URL" ref="meta_thumbnail" name="thumbnail" placeholder="http://spee.ch/mylogo" />
|
2017-04-12 16:55:19 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-04-10 20:12:07 +02:00
|
|
|
<FormRow label="Description" type="textarea" ref="meta_description" name="description" placeholder="Description of your content" />
|
2017-04-12 16:55:19 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-04-10 20:12:07 +02:00
|
|
|
<FormRow label="Language" type="select" defaultValue="en" ref="meta_language" name="language">
|
|
|
|
<option value="en">English</option>
|
|
|
|
<option value="zh">Chinese</option>
|
|
|
|
<option value="fr">French</option>
|
|
|
|
<option value="de">German</option>
|
|
|
|
<option value="jp">Japanese</option>
|
|
|
|
<option value="ru">Russian</option>
|
|
|
|
<option value="es">Spanish</option>
|
|
|
|
</FormRow>
|
2017-04-12 16:55:19 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-04-10 20:12:07 +02:00
|
|
|
<FormRow type="select" label="Maturity" defaultValue="en" ref="meta_nsfw" name="nsfw">
|
2017-04-13 22:40:29 +02:00
|
|
|
{/* <option value=""></option> */}
|
2017-04-10 20:12:07 +02:00
|
|
|
<option value="0">All Ages</option>
|
|
|
|
<option value="1">Adults Only</option>
|
|
|
|
</FormRow>
|
2017-04-12 16:55:19 +02:00
|
|
|
</div>
|
|
|
|
</div>}
|
2016-10-19 04:30:57 +02:00
|
|
|
</section>
|
2016-05-23 17:14:21 +02:00
|
|
|
|
2017-04-08 14:30:17 +02:00
|
|
|
<section className="card">
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="card__title-primary">
|
|
|
|
<h4>Access</h4>
|
|
|
|
<div className="card__subtitle">
|
2017-04-14 19:44:06 +02:00
|
|
|
How much does this content cost?
|
2017-04-10 20:12:07 +02:00
|
|
|
</div>
|
2017-04-08 14:30:17 +02:00
|
|
|
</div>
|
2017-04-10 14:32:40 +02:00
|
|
|
<div className="card__content">
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="form-row__label-row">
|
|
|
|
<label className="form-row__label">Price</label>
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
2017-04-12 16:55:19 +02:00
|
|
|
<FormRow label="Free" type="radio" name="isFree" value="1" onChange={ () => { this.handleFeePrefChange(false) } } defaultChecked={!this.state.isFee} />
|
2017-04-10 20:12:07 +02:00
|
|
|
<FormField type="radio" name="isFree" label={!this.state.isFee ? 'Choose price...' : 'Price ' }
|
2017-04-12 16:55:19 +02:00
|
|
|
onChange={ () => { this.handleFeePrefChange(true) } } defaultChecked={this.state.isFee} />
|
2017-04-10 20:12:07 +02:00
|
|
|
<span className={!this.state.isFee ? 'hidden' : ''}>
|
2017-04-12 16:55:19 +02:00
|
|
|
<FormField type="number" className="form-field__input--inline" step="0.01" placeholder="1.00" onChange={this.handleFeeAmountChange} /> <FormField type="select" onChange={this.handleFeeCurrencyChange}>
|
2017-04-10 20:12:07 +02:00
|
|
|
<option value="USD">US Dollars</option>
|
|
|
|
<option value="LBC">LBRY credits</option>
|
|
|
|
</FormField>
|
|
|
|
</span>
|
|
|
|
{ this.state.isFee ?
|
2017-04-12 16:55:19 +02:00
|
|
|
<div className="form-field__helper">
|
2017-04-10 20:12:07 +02:00
|
|
|
If you choose to price this content in dollars, the number of credits charged will be adjusted based on the value of LBRY credits at the time of purchase.
|
|
|
|
</div> : '' }
|
|
|
|
<FormRow label="License" type="select" ref="meta_license" name="license" onChange={this.handleLicenseChange}>
|
2017-04-12 16:55:19 +02:00
|
|
|
<option></option>
|
|
|
|
<option>Public Domain</option>
|
2017-04-10 20:12:07 +02:00
|
|
|
<option data-url="https://creativecommons.org/licenses/by/4.0/legalcode">Creative Commons Attribution 4.0 International</option>
|
|
|
|
<option data-url="https://creativecommons.org/licenses/by-sa/4.0/legalcode">Creative Commons Attribution-ShareAlike 4.0 International</option>
|
|
|
|
<option data-url="https://creativecommons.org/licenses/by-nd/4.0/legalcode">Creative Commons Attribution-NoDerivatives 4.0 International</option>
|
|
|
|
<option data-url="https://creativecommons.org/licenses/by-nc/4.0/legalcode">Creative Commons Attribution-NonCommercial 4.0 International</option>
|
|
|
|
<option data-url="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</option>
|
|
|
|
<option data-url="https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</option>
|
|
|
|
<option data-license-type="copyright" {... this.state.copyrightChosen ? {value: this.state.copyrightNotice} : {}}>Copyrighted...</option>
|
|
|
|
<option data-license-type="other" {... this.state.otherLicenseChosen ? {value: this.state.otherLicenseDescription} : {}}>Other...</option>
|
|
|
|
</FormRow>
|
|
|
|
<FormField type="hidden" ref="meta_license_url" name="license_url" value={this.getLicenseUrl()} />
|
|
|
|
{this.state.copyrightChosen
|
|
|
|
? <FormRow label="Copyright notice" type="text" name="copyright-notice"
|
|
|
|
value={this.state.copyrightNotice} onChange={this.handleCopyrightNoticeChange} />
|
|
|
|
: null}
|
|
|
|
{this.state.otherLicenseChosen ?
|
|
|
|
<FormRow label="License description" type="text" name="other-license-description" onChange={this.handleOtherLicenseDescriptionChange} />
|
|
|
|
: null}
|
|
|
|
{this.state.otherLicenseChosen ?
|
|
|
|
<FormRow label="License URL" type="text" name="other-license-url" onChange={this.handleOtherLicenseUrlChange} />
|
|
|
|
: null}
|
2016-08-08 05:31:21 +02:00
|
|
|
</div>
|
2016-10-19 04:30:57 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section className="card">
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="card__title-primary">
|
|
|
|
<h4>Identity</h4>
|
|
|
|
<div className="card__subtitle">
|
|
|
|
Who created this content?
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
2016-08-08 05:31:21 +02:00
|
|
|
</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="card__content">
|
|
|
|
<FormRow type="select" tabIndex="1" onChange={this.handleChannelChange} value={this.state.channel}>
|
|
|
|
<option key="anonymous" value="anonymous">Anonymous</option>
|
|
|
|
{this.state.channels.map(({name}) => <option key={name} value={name}>{name}</option>)}
|
|
|
|
<option key="new" value="new">New identity...</option>
|
|
|
|
</FormRow>
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
{this.state.channel == 'new' ?
|
|
|
|
<div className="card__content">
|
|
|
|
<FormRow label="Name" type="text" onChange={this.handleNewChannelNameChange} ref={newChannelName => { this.refs.newChannelName = newChannelName }}
|
|
|
|
value={this.state.newChannelName} />
|
2017-04-12 16:55:19 +02:00
|
|
|
<FormRow label="Deposit"
|
|
|
|
postfix="LBC"
|
|
|
|
step="0.01"
|
|
|
|
type="number"
|
|
|
|
helper={lbcInputHelp}
|
|
|
|
onChange={this.handleNewChannelBidChange}
|
2017-04-12 18:59:43 +02:00
|
|
|
value={this.state.newChannelBid} />
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="form-row-submit">
|
2017-04-13 20:52:26 +02:00
|
|
|
<Link button="primary" label={!this.state.creatingChannel ? 'Create identity' : 'Creating identity...'} onClick={this.handleCreateChannelClick} disabled={this.state.creatingChannel} />
|
2017-04-10 20:12:07 +02:00
|
|
|
</div>
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
|
|
|
: null}
|
|
|
|
</section>
|
2016-07-20 08:25:22 +02:00
|
|
|
|
2016-08-07 17:27:00 +02:00
|
|
|
|
2016-10-19 04:30:57 +02:00
|
|
|
<section className="card">
|
2017-04-10 20:12:07 +02:00
|
|
|
<div className="card__title-primary">
|
|
|
|
<h4>Address</h4>
|
2017-04-12 16:55:19 +02:00
|
|
|
<div className="card__subtitle">Where should this content permanently reside? <Link label="Read more" href="https://lbry.io/faq/naming" />.</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-04-12 16:55:19 +02:00
|
|
|
<FormRow prefix="lbry://" type="text" ref="name" placeholder="myname" value={this.state.rawName} onChange={this.handleNameChange}
|
|
|
|
helper={this.getNameBidHelpText()} />
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
2017-04-10 20:12:07 +02:00
|
|
|
{ this.state.rawName ?
|
|
|
|
<div className="card__content">
|
|
|
|
<FormRow ref="bid"
|
|
|
|
type="number"
|
|
|
|
step="0.01"
|
|
|
|
label="Deposit"
|
2017-04-12 16:55:19 +02:00
|
|
|
postfix="LBC"
|
2017-04-10 20:12:07 +02:00
|
|
|
onChange={this.handleBidChange}
|
2017-04-12 18:59:43 +02:00
|
|
|
value={this.state.bid}
|
2017-04-10 20:12:07 +02:00
|
|
|
placeholder={this.state.nameResolved ? this.state.topClaimValue + 10 : 100}
|
2017-04-12 16:55:19 +02:00
|
|
|
helper={lbcInputHelp} />
|
2017-04-10 20:12:07 +02:00
|
|
|
</div> : '' }
|
2016-10-19 04:30:57 +02:00
|
|
|
</section>
|
2016-05-23 17:14:21 +02:00
|
|
|
|
2017-04-14 01:39:59 +02:00
|
|
|
<section className="card">
|
|
|
|
<div className="card__title-primary">
|
|
|
|
<h4>Terms of Service</h4>
|
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<FormRow label={
|
|
|
|
<span>I agree to the <Link href="https://www.lbry.io/termsofservice" label="LBRY terms of service" checked={this.state.TOSAgreed} /></span>
|
|
|
|
} type="checkbox" name="tos_agree" ref={(field) => { this.refs.tos_agree = field }} onChange={this.handleTOSChange} />
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
2016-10-19 04:30:57 +02:00
|
|
|
<div className="card-series-submit">
|
2017-03-01 00:23:49 +01:00
|
|
|
<Link button="primary" label={!this.state.submitting ? 'Publish' : 'Publishing...'} onClick={this.handleSubmit} disabled={this.state.submitting} />
|
|
|
|
<Link button="cancel" onClick={window.history.back} label="Cancel" />
|
|
|
|
<input type="submit" className="hidden" />
|
2016-10-19 04:30:57 +02:00
|
|
|
</div>
|
|
|
|
</form>
|
2016-10-21 09:56:37 +02:00
|
|
|
|
2017-01-13 23:05:09 +01:00
|
|
|
<Modal isOpen={this.state.modal == 'publishStarted'} contentLabel="File published"
|
|
|
|
onConfirmed={this.handlePublishStartedConfirmed}>
|
2016-10-21 09:56:37 +02:00
|
|
|
<p>Your file has been published to LBRY at the address <code>lbry://{this.state.name}</code>!</p>
|
2017-04-17 14:27:39 +02:00
|
|
|
<p>The file will take a few minutes to appear for other LBRY users. Until then it will be listed as "pending" under your published files.</p>
|
2016-10-21 09:56:37 +02:00
|
|
|
</Modal>
|
2017-01-13 23:05:09 +01:00
|
|
|
<Modal isOpen={this.state.modal == 'error'} contentLabel="Error publishing file"
|
|
|
|
onConfirmed={this.closeModal}>
|
2016-10-21 09:56:37 +02:00
|
|
|
The following error occurred when attempting to publish your file: {this.state.errorMessage}
|
|
|
|
</Modal>
|
2016-10-19 04:30:57 +02:00
|
|
|
</main>
|
2016-05-23 17:14:21 +02:00
|
|
|
);
|
|
|
|
}
|
2016-08-08 11:53:41 +02:00
|
|
|
});
|
2016-11-22 21:19:08 +01:00
|
|
|
|
|
|
|
export default PublishPage;
|