Merge pull request #1716 from lbryio/publish-fixes

Publish fixes
This commit is contained in:
Sean Yesmunt 2018-07-02 18:36:27 -04:00 committed by GitHub
commit 9a8d48777b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 39 deletions

View file

@ -23,6 +23,7 @@ type Props = {
noPadding: ?boolean, // to remove padding and allow circular buttons noPadding: ?boolean, // to remove padding and allow circular buttons
uppercase: ?boolean, uppercase: ?boolean,
iconColor: ?string, iconColor: ?string,
tourniquet: ?boolean, // to shorten the button and ellipsis, only use for links
}; };
class Button extends React.PureComponent<Props> { class Button extends React.PureComponent<Props> {
@ -50,6 +51,7 @@ class Button extends React.PureComponent<Props> {
noPadding, noPadding,
uppercase, uppercase,
iconColor, iconColor,
tourniquet,
...otherProps ...otherProps
} = this.props; } = this.props;
@ -69,6 +71,7 @@ class Button extends React.PureComponent<Props> {
'btn--link': button === 'link', 'btn--link': button === 'link',
'btn--external-link': button === 'link' && href, 'btn--external-link': button === 'link' && href,
'btn--uppercase': uppercase, 'btn--uppercase': uppercase,
'btn--tourniquet': tourniquet,
} }
: 'btn--no-style', : 'btn--no-style',
className className

View file

@ -25,11 +25,13 @@ class BidHelpText extends React.PureComponent<Props> {
} = this.props; } = this.props;
if (!uri) { if (!uri) {
return __('Create a URL for this content'); return __('Create a URL for this content.');
} }
if (isStillEditing) { if (isStillEditing) {
return __('You are currently editing this claim'); return __(
'You are currently editing this claim. If you change the URL, you will need reselect a file.'
);
} }
if (isResolvingUri) { if (isResolvingUri) {
@ -61,10 +63,10 @@ class BidHelpText extends React.PureComponent<Props> {
<React.Fragment> <React.Fragment>
{__('A deposit greater than')} {winningBidForClaimUri} {__('is needed to win')} {__('A deposit greater than')} {winningBidForClaimUri} {__('is needed to win')}
{` ${uri}. `} {` ${uri}. `}
{__('However, you can still get this URL for any amount')} {__('However, you can still get this URL for any amount.')}
</React.Fragment> </React.Fragment>
) : ( ) : (
__('Any amount will give you the winning bid') __('Any amount will give you the winning bid.')
); );
} }
} }

View file

@ -244,32 +244,54 @@ class PublishForm extends React.PureComponent<Props> {
} }
checkIsFormValid() { checkIsFormValid() {
const { name, nameError, title, bid, bidError, tosAccepted } = this.props; const {
return name && !nameError && title && bid && !bidError && tosAccepted; name,
nameError,
title,
bid,
bidError,
tosAccepted,
editingURI,
isStillEditing,
filePath,
} = this.props;
// If they are editing, they don't need a new file chosen
const formValidLessFile = name && !nameError && title && bid && !bidError && tosAccepted;
return editingURI && !filePath ? isStillEditing && formValidLessFile : formValidLessFile;
} }
renderFormErrors() { renderFormErrors() {
const { name, nameError, title, bid, bidError, tosAccepted } = this.props; const {
name,
nameError,
title,
bid,
bidError,
tosAccepted,
editingURI,
filePath,
isStillEditing,
} = this.props;
if (nameError || bidError) { const isFormValid = this.checkIsFormValid();
// There will be inline errors if either of these exist
// These are just extra help at the bottom of the screen
// There could be multiple bid errors, so just duplicate it at the bottom
return (
<div className="card__subtitle form-field__error">
{nameError && <div>{__('The URL you created is not valid.')}</div>}
{bidError && <div>{bidError}</div>}
</div>
);
}
// These are extra help
// If there is an error it will be presented as an inline error as well
return ( return (
<div className="card__content card__subtitle card__subtitle--block form-field__error"> !isFormValid && (
{!title && <div>{__('A title is required')}</div>} <div className="card__content card__subtitle form-field__error">
{!name && <div>{__('A URL is required')}</div>} {!title && <div>{__('A title is required')}</div>}
{!bid && <div>{__('A bid amount is required')}</div>} {!name && <div>{__('A URL is required')}</div>}
{!tosAccepted && <div>{__('You must agree to the terms of service')}</div>} {name && nameError && <div>{__('The URL you created is not valid')}</div>}
</div> {!bid && <div>{__('A bid amount is required')}</div>}
{!!bid && bidError && <div>{bidError}</div>}
{!tosAccepted && <div>{__('You must agree to the terms of service')}</div>}
{!!editingURI &&
!isStillEditing &&
!filePath && <div>{__('You need to reselect a file after changing the LBRY URL')}</div>}
</div>
)
); );
} }
@ -319,10 +341,10 @@ class PublishForm extends React.PureComponent<Props> {
return ( return (
<Form onSubmit={this.handlePublish}> <Form onSubmit={this.handlePublish}>
<section className={classnames('card card--section')}> <section className={classnames('card card--section', { 'card--disabled': publishing })}>
<div className="card__title">{__('Content')}</div> <div className="card__title">{__('Content')}</div>
<div className="card__subtitle"> <div className="card__subtitle">
{editingURI ? __('Editing a claim') : __('What are you publishing?')} {isStillEditing ? __('Editing a claim') : __('What are you publishing?')}
</div> </div>
{(filePath || !!editingURI) && ( {(filePath || !!editingURI) && (
<div className="card-media__internal-links"> <div className="card-media__internal-links">
@ -335,7 +357,7 @@ class PublishForm extends React.PureComponent<Props> {
</div> </div>
)} )}
<FileSelector currentPath={filePath} onFileChosen={this.handleFileChange} /> <FileSelector currentPath={filePath} onFileChosen={this.handleFileChange} />
{!!editingURI && ( {!!isStillEditing && (
<p className="card__content card__subtitle"> <p className="card__content card__subtitle">
{__("If you don't choose a file, the file from your existing claim")} {__("If you don't choose a file, the file from your existing claim")}
{` "${name}" `} {` "${name}" `}
@ -379,7 +401,7 @@ class PublishForm extends React.PureComponent<Props> {
) : ( ) : (
<React.Fragment> <React.Fragment>
{__( {__(
'Upload your thumbnail to spee.ch, or enter the URL manually. Learn more about spee.ch ' 'Upload your thumbnail (.png/.jpg/.gif) to spee.ch, or enter the URL manually. Learn more about spee.ch '
)} )}
<Button button="link" label={__('here')} href="https://spee.ch/about" />. <Button button="link" label={__('here')} href="https://spee.ch/about" />.
</React.Fragment> </React.Fragment>

View file

@ -72,6 +72,7 @@ class TransactionListItem extends React.PureComponent<Props> {
{name && {name &&
claimId && ( claimId && (
<Button <Button
tourniquet
button="link" button="link"
navigate="/show" navigate="/show"
navigateParams={{ uri: buildURI({ claimName: name, claimId }) }} navigateParams={{ uri: buildURI({ claimName: name, claimId }) }}

View file

@ -66,11 +66,6 @@ button:disabled {
min-width: 0; min-width: 0;
box-shadow: none; box-shadow: none;
text-align: left; text-align: left;
/*Tourniquets text over 20VW*/
max-width: 20vw;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.btn.btn--external-link { .btn.btn--external-link {
@ -81,6 +76,13 @@ button:disabled {
background-color: var(--btn-bg-secondary); background-color: var(--btn-bg-secondary);
} }
.btn.btn--tourniquet {
max-width: 20vw;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.btn.btn--no-style { .btn.btn--no-style {
font-size: inherit; font-size: inherit;
font-weight: inherit; font-weight: inherit;

View file

@ -150,10 +150,6 @@
padding-top: $spacing-vertical * 1/3; padding-top: $spacing-vertical * 1/3;
} }
.card__subtitle--block {
display: block;
}
.card__meta { .card__meta {
color: var(--color-help); color: var(--color-help);
font-size: 14px; font-size: 14px;

View file

@ -80,8 +80,8 @@ table.table--help {
font-family: 'metropolis-semibold'; font-family: 'metropolis-semibold';
min-width: 130px; min-width: 130px;
} }
td:nth-of-type(2) { td:nth-of-type(2) {
/*Tourniquets text over 20VW*/ /*Tourniquets text over 20VW*/
max-width: 20vw; max-width: 20vw;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;