Change wording on Publish page for claims user already controls
This commit is contained in:
parent
6677769ded
commit
7a5f478b4d
1 changed files with 37 additions and 17 deletions
|
@ -10,15 +10,20 @@ var publishNumberStyle = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var PublishPage = React.createClass({
|
var PublishPage = React.createClass({
|
||||||
_requiredFields: ['name', 'file', 'bid', 'meta_title', 'meta_author', 'meta_license', 'meta_description'],
|
_requiredFields: ['name', 'bid', 'meta_title', 'meta_author', 'meta_license', 'meta_description'],
|
||||||
|
|
||||||
handleSubmit: function() {
|
handleSubmit: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
submitting: true,
|
submitting: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var checkFields = this._requiredFields.slice();
|
||||||
|
if (!this.state.nameIsMine) {
|
||||||
|
checkFields.push('file');
|
||||||
|
}
|
||||||
|
|
||||||
var missingFieldFound = false;
|
var missingFieldFound = false;
|
||||||
for (let fieldName of this._requiredFields) {
|
for (let fieldName of checkFields) {
|
||||||
var field = this.refs[fieldName];
|
var field = this.refs[fieldName];
|
||||||
if (field.getValue() === '') {
|
if (field.getValue() === '') {
|
||||||
field.warnRequired();
|
field.warnRequired();
|
||||||
|
@ -60,17 +65,18 @@ var PublishPage = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
var doPublish = () => {
|
var doPublish = () => {
|
||||||
console.log({name: this.state.name,
|
var publishArgs = {
|
||||||
file_path: this._tempFilePath,
|
name: this.state.name,
|
||||||
bid: parseFloat(this.state.bid),
|
bid: parseFloat(this.state.bid),
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
});
|
};
|
||||||
lbry.publish({
|
|
||||||
name: this.refs.name.getValue(),
|
if (this.refs.file.getValue() !== '') {
|
||||||
file_path: this._tempFilePath,
|
publishArgs.file_path = this._tempFilePath;
|
||||||
bid: parseFloat(this.state.bid),
|
}
|
||||||
metadata: metadata,
|
|
||||||
}, (message) => {
|
console.log(publishArgs);
|
||||||
|
lbry.publish(publishArgs, (message) => {
|
||||||
this.handlePublishSuccess();
|
this.handlePublishSuccess();
|
||||||
this.setState({
|
this.setState({
|
||||||
submitting: false,
|
submitting: false,
|
||||||
|
@ -106,6 +112,7 @@ var PublishPage = React.createClass({
|
||||||
feeAmount: '',
|
feeAmount: '',
|
||||||
feeCurrency: 'USD',
|
feeCurrency: 'USD',
|
||||||
nameResolved: false,
|
nameResolved: false,
|
||||||
|
nameIsMine: false,
|
||||||
claimValue: 0.0,
|
claimValue: 0.0,
|
||||||
fileInfo: null,
|
fileInfo: null,
|
||||||
uploadProgress: 0.0,
|
uploadProgress: 0.0,
|
||||||
|
@ -143,11 +150,21 @@ var PublishPage = React.createClass({
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
lbry.getClaimInfo(name, (claimInfo) => {
|
lbry.getClaimInfo(name, (claimInfo) => {
|
||||||
this.setState({
|
var newState = {
|
||||||
name: name,
|
name: name,
|
||||||
nameResolved: true,
|
nameResolved: true,
|
||||||
|
nameIsMine: claimInfo.is_mine,
|
||||||
claimValue: parseFloat(claimInfo.amount),
|
claimValue: parseFloat(claimInfo.amount),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (claimInfo.is_mine) {
|
||||||
|
newState.bid = claimInfo.amount;
|
||||||
|
} else if (this.state.nameIsMine && !claimInfo.name_is_mine) {
|
||||||
|
// Just changed away from a name we control, so clear pre-fill
|
||||||
|
newState.bid = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState(newState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -247,8 +264,9 @@ var PublishPage = React.createClass({
|
||||||
lbry://<FormField type="text" ref="name" onChange={this.handleNameChange} />
|
lbry://<FormField type="text" ref="name" onChange={this.handleNameChange} />
|
||||||
{
|
{
|
||||||
(!this.state.name ? '' :
|
(!this.state.name ? '' :
|
||||||
(this.state.nameResolved ? <em> This name is currently claimed for <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits</em>
|
(! this.state.nameResolved ? <em> This name is available</em>
|
||||||
: <em> This name is available</em>))
|
: (this.state.nameIsMine ? <em> You already control this name. You can use this page to update your claim.</em>
|
||||||
|
: <em> This name is currently claimed for <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits.</em>)))
|
||||||
}
|
}
|
||||||
<div className="help">What LBRY name would you like to claim for this file?</div>
|
<div className="help">What LBRY name would you like to claim for this file?</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -264,6 +282,7 @@ var PublishPage = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
: <div>File ready for publishing!</div>) }
|
: <div>File ready for publishing!</div>) }
|
||||||
</form>
|
</form>
|
||||||
|
{ this.state.nameIsMine ? <div className="help">If you don't choose a file, the file from your existing claim will be used.</div> : null }
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="section-block">
|
<section className="section-block">
|
||||||
|
@ -271,7 +290,8 @@ var PublishPage = React.createClass({
|
||||||
Credits <FormField ref="bid" style={publishNumberStyle} type="text" onChange={this.handleBidChange} value={this.state.bid} placeholder={this.state.nameResolved ? lbry.formatCredits(this.state.claimValue + 10) : 100} />
|
Credits <FormField ref="bid" style={publishNumberStyle} type="text" onChange={this.handleBidChange} value={this.state.bid} placeholder={this.state.nameResolved ? lbry.formatCredits(this.state.claimValue + 10) : 100} />
|
||||||
<div className="help">How much would you like to bid for this name?
|
<div className="help">How much would you like to bid for this name?
|
||||||
{ !this.state.nameResolved ? <span> Since this name is not currently resolved, you may bid as low as you want, but higher bids help prevent others from claiming your name.</span>
|
{ !this.state.nameResolved ? <span> Since this name is not currently resolved, you may bid as low as you want, but higher bids help prevent others from claiming your name.</span>
|
||||||
: <span> You must bid over <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits to claim this name.</span> }
|
: (this.state.nameIsMine ? <span> Your current bid is <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits.</span>
|
||||||
|
: <span> You must bid over <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits to claim this name.</span>) }
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -335,4 +355,4 @@ var PublishPage = React.createClass({
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue