Propagate thumbnail errors to PublishFormData
Thumbnail errors were just being used in `selectThumbnail`. The form doesn't know about it and was using allowing invalid thumbnails like 'helloworld' to pass through.
This commit is contained in:
parent
1911a5132b
commit
364db9dafa
6 changed files with 21 additions and 18 deletions
1
flow-typed/publish.js
vendored
1
flow-typed/publish.js
vendored
|
@ -11,6 +11,7 @@ declare type UpdatePublishFormData = {
|
||||||
thumbnail_url?: string,
|
thumbnail_url?: string,
|
||||||
uploadThumbnailStatus?: string,
|
uploadThumbnailStatus?: string,
|
||||||
thumbnailPath?: string,
|
thumbnailPath?: string,
|
||||||
|
thumbnailError?: boolean,
|
||||||
description?: string,
|
description?: string,
|
||||||
language?: string,
|
language?: string,
|
||||||
channel?: string,
|
channel?: string,
|
||||||
|
|
|
@ -310,6 +310,9 @@
|
||||||
"upload": "upload",
|
"upload": "upload",
|
||||||
"Uploading thumbnail": "Uploading thumbnail",
|
"Uploading thumbnail": "Uploading thumbnail",
|
||||||
"Please wait for thumbnail to finish uploading": "Please wait for thumbnail to finish uploading",
|
"Please wait for thumbnail to finish uploading": "Please wait for thumbnail to finish uploading",
|
||||||
|
"A thumbnail is required. Please upload or provide an image URL above.": "A thumbnail is required. Please upload or provide an image URL above.",
|
||||||
|
"Thumbnail is invalid.": "Thumbnail is invalid.",
|
||||||
|
"Please reselect a file after changing the LBRY URL": "Please reselect a file after changing the LBRY URL",
|
||||||
"API connection string": "API connection string",
|
"API connection string": "API connection string",
|
||||||
"Method": "Method",
|
"Method": "Method",
|
||||||
"Parameters": "Parameters",
|
"Parameters": "Parameters",
|
||||||
|
|
|
@ -46,6 +46,7 @@ type Props = {
|
||||||
editingURI: ?string,
|
editingURI: ?string,
|
||||||
title: ?string,
|
title: ?string,
|
||||||
thumbnail: ?string,
|
thumbnail: ?string,
|
||||||
|
thumbnailError: ?boolean,
|
||||||
uploadThumbnailStatus: ?string,
|
uploadThumbnailStatus: ?string,
|
||||||
thumbnailPath: ?string,
|
thumbnailPath: ?string,
|
||||||
description: ?string,
|
description: ?string,
|
||||||
|
@ -95,6 +96,7 @@ function PublishForm(props: Props) {
|
||||||
// Detect upload type from query in URL
|
// Detect upload type from query in URL
|
||||||
const {
|
const {
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
thumbnailError,
|
||||||
name,
|
name,
|
||||||
editingURI,
|
editingURI,
|
||||||
myClaimForUri,
|
myClaimForUri,
|
||||||
|
@ -227,6 +229,7 @@ function PublishForm(props: Props) {
|
||||||
thumbnail &&
|
thumbnail &&
|
||||||
!bidError &&
|
!bidError &&
|
||||||
!emptyPostError &&
|
!emptyPostError &&
|
||||||
|
!thumbnailError &&
|
||||||
!(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS);
|
!(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS);
|
||||||
|
|
||||||
const isOverwritingExistingClaim = !editingURI && myClaimForUri;
|
const isOverwritingExistingClaim = !editingURI && myClaimForUri;
|
||||||
|
|
|
@ -10,6 +10,7 @@ const select = (state) => ({
|
||||||
editingURI: makeSelectPublishFormValue('editingURI')(state),
|
editingURI: makeSelectPublishFormValue('editingURI')(state),
|
||||||
uploadThumbnailStatus: makeSelectPublishFormValue('uploadThumbnailStatus')(state),
|
uploadThumbnailStatus: makeSelectPublishFormValue('uploadThumbnailStatus')(state),
|
||||||
thumbnail: makeSelectPublishFormValue('thumbnail')(state),
|
thumbnail: makeSelectPublishFormValue('thumbnail')(state),
|
||||||
|
thumbnailError: makeSelectPublishFormValue('thumbnailError')(state),
|
||||||
isStillEditing: selectIsStillEditing(state),
|
isStillEditing: selectIsStillEditing(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ type Props = {
|
||||||
isStillEditing: boolean,
|
isStillEditing: boolean,
|
||||||
uploadThumbnailStatus: string,
|
uploadThumbnailStatus: string,
|
||||||
thumbnail: string,
|
thumbnail: string,
|
||||||
|
thumbnailError: boolean,
|
||||||
waitForFile: boolean,
|
waitForFile: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ function PublishFormErrors(props: Props) {
|
||||||
isStillEditing,
|
isStillEditing,
|
||||||
uploadThumbnailStatus,
|
uploadThumbnailStatus,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
|
thumbnailError,
|
||||||
waitForFile,
|
waitForFile,
|
||||||
} = props;
|
} = props;
|
||||||
// These are extra help
|
// These are extra help
|
||||||
|
@ -46,6 +48,7 @@ function PublishFormErrors(props: Props) {
|
||||||
{!isUploadingThumbnail && !thumbnail && (
|
{!isUploadingThumbnail && !thumbnail && (
|
||||||
<div>{__('A thumbnail is required. Please upload or provide an image URL above.')}</div>
|
<div>{__('A thumbnail is required. Please upload or provide an image URL above.')}</div>
|
||||||
)}
|
)}
|
||||||
|
{thumbnailError && <div>{__('Thumbnail is invalid.')}</div>}
|
||||||
{editingURI && !isStillEditing && !filePath && (
|
{editingURI && !isStillEditing && !filePath && (
|
||||||
<div>{__('Please reselect a file after changing the LBRY URL')}</div>
|
<div>{__('Please reselect a file after changing the LBRY URL')}</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -17,23 +17,15 @@ type Props = {
|
||||||
formDisabled: boolean,
|
formDisabled: boolean,
|
||||||
uploadThumbnailStatus: string,
|
uploadThumbnailStatus: string,
|
||||||
thumbnailPath: ?string,
|
thumbnailPath: ?string,
|
||||||
|
thumbnailError: ?string,
|
||||||
openModal: (id: string, {}) => void,
|
openModal: (id: string, {}) => void,
|
||||||
updatePublishForm: ({}) => void,
|
updatePublishForm: ({}) => void,
|
||||||
resetThumbnailStatus: () => void,
|
resetThumbnailStatus: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
class SelectThumbnail extends React.PureComponent<Props> {
|
||||||
thumbnailError: boolean,
|
|
||||||
};
|
|
||||||
|
|
||||||
class SelectThumbnail extends React.PureComponent<Props, State> {
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.state = {
|
|
||||||
thumbnailError: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
(this: any).handleThumbnailChange = this.handleThumbnailChange.bind(this);
|
(this: any).handleThumbnailChange = this.handleThumbnailChange.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +33,10 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
|
||||||
const { updatePublishForm } = this.props;
|
const { updatePublishForm } = this.props;
|
||||||
const newThumbnail = e.target.value.replace(' ', '');
|
const newThumbnail = e.target.value.replace(' ', '');
|
||||||
|
|
||||||
updatePublishForm({ thumbnail: newThumbnail });
|
updatePublishForm({
|
||||||
this.setState({ thumbnailError: false });
|
thumbnail: newThumbnail,
|
||||||
|
thumbnailError: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -56,10 +50,10 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
|
||||||
openModal,
|
openModal,
|
||||||
updatePublishForm,
|
updatePublishForm,
|
||||||
thumbnailPath,
|
thumbnailPath,
|
||||||
|
thumbnailError,
|
||||||
resetThumbnailStatus,
|
resetThumbnailStatus,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const { thumbnailError } = this.state;
|
|
||||||
const accept = '.png, .jpg, .jpeg, .gif';
|
const accept = '.png, .jpg, .jpeg, .gif';
|
||||||
|
|
||||||
const outpoint = myClaimForUri ? `${myClaimForUri.txid}:${myClaimForUri.nout}` : undefined;
|
const outpoint = myClaimForUri ? `${myClaimForUri.txid}:${myClaimForUri.nout}` : undefined;
|
||||||
|
@ -99,10 +93,8 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
|
||||||
style={{ display: 'none' }}
|
style={{ display: 'none' }}
|
||||||
src={thumbnailSrc}
|
src={thumbnailSrc}
|
||||||
alt={__('Thumbnail Preview')}
|
alt={__('Thumbnail Preview')}
|
||||||
onError={e => {
|
onError={(e) => {
|
||||||
this.setState({
|
updatePublishForm({ thumbnailError: true });
|
||||||
thumbnailError: true,
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -133,7 +125,7 @@ class SelectThumbnail extends React.PureComponent<Props, State> {
|
||||||
label={__('Thumbnail')}
|
label={__('Thumbnail')}
|
||||||
placeholder={__('Choose a thumbnail')}
|
placeholder={__('Choose a thumbnail')}
|
||||||
accept={accept}
|
accept={accept}
|
||||||
onFileChosen={file => openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, { file })}
|
onFileChosen={(file) => openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, { file })}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{status === THUMBNAIL_STATUSES.COMPLETE && thumbnail && (
|
{status === THUMBNAIL_STATUSES.COMPLETE && thumbnail && (
|
||||||
|
|
Loading…
Reference in a new issue