2019-06-28 09:27:55 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2019-07-24 20:21:34 +02:00
|
|
|
import { THUMBNAIL_STATUSES, isNameValid } from 'lbry-redux';
|
2019-10-03 23:40:54 +02:00
|
|
|
import { INVALID_NAME_ERROR } from 'constants/claim';
|
2020-07-28 04:19:00 +02:00
|
|
|
import * as PUBLISH_MODES from 'constants/publish_types';
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
type Props = {
|
2020-07-28 04:19:00 +02:00
|
|
|
mode: ?string,
|
2019-06-28 09:27:55 +02:00
|
|
|
title: ?string,
|
|
|
|
name: ?string,
|
|
|
|
bid: ?string,
|
2020-03-02 18:11:14 +01:00
|
|
|
bidError: ?string,
|
2019-06-28 09:27:55 +02:00
|
|
|
editingURI: ?string,
|
|
|
|
filePath: ?string,
|
2020-07-28 04:19:00 +02:00
|
|
|
fileText: ?string,
|
2019-06-28 09:27:55 +02:00
|
|
|
isStillEditing: boolean,
|
|
|
|
uploadThumbnailStatus: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
function PublishFormErrors(props: Props) {
|
2020-07-28 04:19:00 +02:00
|
|
|
const {
|
|
|
|
name,
|
|
|
|
mode,
|
|
|
|
title,
|
|
|
|
bid,
|
|
|
|
bidError,
|
|
|
|
editingURI,
|
|
|
|
filePath,
|
|
|
|
fileText,
|
|
|
|
isStillEditing,
|
|
|
|
uploadThumbnailStatus,
|
|
|
|
} = props;
|
|
|
|
const emptyStoryError = mode === PUBLISH_MODES.STORY && (!fileText || fileText.trim() === '');
|
2019-06-28 09:27:55 +02:00
|
|
|
// These are extra help
|
|
|
|
// If there is an error it will be presented as an inline error as well
|
|
|
|
return (
|
2020-04-13 21:16:07 +02:00
|
|
|
<div className="error__text">
|
2019-06-28 09:27:55 +02:00
|
|
|
{!title && <div>{__('A title is required')}</div>}
|
|
|
|
{!name && <div>{__('A URL is required')}</div>}
|
2019-10-03 23:40:54 +02:00
|
|
|
{!isNameValid(name, false) && INVALID_NAME_ERROR}
|
2019-06-28 09:27:55 +02:00
|
|
|
{!bid && <div>{__('A deposit amount is required')}</div>}
|
2020-03-02 18:11:14 +01:00
|
|
|
{bidError && <div>{__('Please check your deposit amount.')}</div>}
|
2020-07-28 04:19:00 +02:00
|
|
|
{emptyStoryError && <div>{__("Can't publish an empty story")}</div>}
|
2019-06-28 09:27:55 +02:00
|
|
|
{uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS && (
|
|
|
|
<div>{__('Please wait for thumbnail to finish uploading')}</div>
|
|
|
|
)}
|
|
|
|
{!!editingURI && !isStillEditing && !filePath && (
|
|
|
|
<div>{__('Please reselect a file after changing the LBRY URL')}</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PublishFormErrors;
|