From 7c96bad8bf338f0d24b30a53ca5e059e6c627ae6 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Mon, 2 Jul 2018 12:37:07 -0400 Subject: [PATCH] improve publish error messaging for edits --- .../publishForm/internal/bid-help-text.jsx | 10 ++-- src/renderer/component/publishForm/view.jsx | 56 ++++++++++++++----- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/renderer/component/publishForm/internal/bid-help-text.jsx b/src/renderer/component/publishForm/internal/bid-help-text.jsx index 9686020d1..baf45d2ff 100644 --- a/src/renderer/component/publishForm/internal/bid-help-text.jsx +++ b/src/renderer/component/publishForm/internal/bid-help-text.jsx @@ -25,11 +25,13 @@ class BidHelpText extends React.PureComponent { } = this.props; if (!uri) { - return __('Create a URL for this content'); + return __('Create a URL for this content.'); } 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) { @@ -61,10 +63,10 @@ class BidHelpText extends React.PureComponent { {__('A deposit greater than')} {winningBidForClaimUri} {__('is needed to win')} {` ${uri}. `} - {__('However, you can still get this URL for any amount')} + {__('However, you can still get this URL for any amount.')} ) : ( - __('Any amount will give you the winning bid') + __('Any amount will give you the winning bid.') ); } } diff --git a/src/renderer/component/publishForm/view.jsx b/src/renderer/component/publishForm/view.jsx index 7e6f5e5a1..f91bb0a26 100644 --- a/src/renderer/component/publishForm/view.jsx +++ b/src/renderer/component/publishForm/view.jsx @@ -244,24 +244,54 @@ class PublishForm extends React.PureComponent { } checkIsFormValid() { - const { name, nameError, title, bid, bidError, tosAccepted } = this.props; - return name && !nameError && title && bid && !bidError && tosAccepted; + const { + 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() { - const { name, nameError, title, bid, bidError, tosAccepted } = this.props; + const { + name, + nameError, + title, + bid, + bidError, + tosAccepted, + editingURI, + filePath, + isStillEditing, + } = this.props; + + const isFormValid = this.checkIsFormValid(); // These are extra help // If there is an error it will be presented as an inline error as well return ( -
- {!title &&
{__('A title is required')}
} - {!name &&
{__('A URL is required')}
} - {name && nameError &&
{__('The URL you created is not valid.')}
} - {!bid &&
{__('A bid amount is required')}
} - {bid && bidError &&
{bidError}
} - {!tosAccepted &&
{__('You must agree to the terms of service')}
} -
+ !isFormValid && ( +
+ {!title &&
{__('A title is required')}
} + {!name &&
{__('A URL is required')}
} + {name && nameError &&
{__('The URL you created is not valid')}
} + {!bid &&
{__('A bid amount is required')}
} + {!!bid && bidError &&
{bidError}
} + {!tosAccepted &&
{__('You must agree to the terms of service')}
} + {!!editingURI && + !isStillEditing && + !filePath &&
{__('You need to reselect a file after changing the LBRY URL')}
} +
+ ) ); } @@ -314,7 +344,7 @@ class PublishForm extends React.PureComponent {
{__('Content')}
- {editingURI ? __('Editing a claim') : __('What are you publishing?')} + {isStillEditing ? __('Editing a claim') : __('What are you publishing?')}
{(filePath || !!editingURI) && (
@@ -327,7 +357,7 @@ class PublishForm extends React.PureComponent {
)} - {!!editingURI && ( + {!!isStillEditing && (

{__("If you don't choose a file, the file from your existing claim")} {` "${name}" `}