diff --git a/ui/component/channelEdit/view.jsx b/ui/component/channelEdit/view.jsx index 61c9df69f..0ba9e4bac 100644 --- a/ui/component/channelEdit/view.jsx +++ b/ui/component/channelEdit/view.jsx @@ -22,6 +22,8 @@ import SUPPORTED_LANGUAGES from 'constants/supported_languages'; import WalletSpendableBalanceHelp from 'component/walletSpendableBalanceHelp'; import { SIMPLE_SITE } from 'config'; import { sortLanguageMap } from 'util/default-languages'; +import ThumbnailBrokenImage from 'component/selectThumbnail/thumbnail-broken.png'; +import Gerbil from 'component/channelThumbnail/gerbil.png'; const LANG_NONE = 'none'; @@ -52,7 +54,7 @@ type Props = { onDone: () => void, openModal: ( id: string, - { onUpdate: (string) => void, assetName: string, helpText: string, currentValue: string, title: string } + { onUpdate: (string, boolean) => void, assetName: string, helpText: string, currentValue: string, title: string } ) => void, uri: string, disabled: boolean, @@ -90,7 +92,9 @@ function ChannelForm(props: Props) { } = props; const [nameError, setNameError] = React.useState(undefined); const [bidError, setBidError] = React.useState(''); + const [isUpload, setIsUpload] = React.useState({ cover: false, thumbnail: false }); const [coverError, setCoverError] = React.useState(false); + const [thumbError, setThumbError] = React.useState(false); const { claim_id: claimId } = claim || {}; const [params, setParams]: [any, (any) => void] = React.useState(getChannelParams()); const { channelName } = parseURI(uri); @@ -112,10 +116,12 @@ function ChannelForm(props: Props) { creatingChannel || updatingChannel || nameError || + thumbError || + coverError || bidError || (isNewChannel && !params.name) ); - }, [isClaimingInitialRewards, creatingChannel, updatingChannel, nameError, bidError, isNewChannel, params]); + }, [isClaimingInitialRewards, creatingChannel, updatingChannel, nameError, thumbError, coverError, bidError, isNewChannel, params.name]); function getChannelParams() { // fill this in with sdk data @@ -195,12 +201,16 @@ function ChannelForm(props: Props) { setParams({ ...params, languages: langs }); } - function handleThumbnailChange(thumbnailUrl: string) { + function handleThumbnailChange(thumbnailUrl: string, uploadSelected: boolean) { setParams({ ...params, thumbnailUrl }); + setIsUpload({ ...isUpload, thumbnail: uploadSelected }); + setThumbError(false); } - function handleCoverChange(coverUrl: string) { + function handleCoverChange(coverUrl: string, uploadSelected: boolean) { setParams({ ...params, coverUrl }); + setIsUpload({ ...isUpload, cover: uploadSelected }); + setCoverError(false); } function handleSubmit() { @@ -225,6 +235,9 @@ function ChannelForm(props: Props) { if (errorMsg && errorMsg.includes(LIMIT_ERR_PARTIAL_MSG)) { errorMsg = __('Transaction limit reached. Try reducing the Description length.'); } + if ((!isUpload.thumbnail && thumbError) || (!isUpload.cover && coverError)) { + errorMsg = __('Invalid %error_type%', { error_type: (thumbError && 'thumbnail') || (coverError && 'cover image') }); + } React.useEffect(() => { let nameError; @@ -247,6 +260,17 @@ function ChannelForm(props: Props) { } }, [hasClaimedInitialRewards, claimInitialRewards]); + const coverSrc = coverError ? ThumbnailBrokenImage : params.coverUrl; + + let thumbnailPreview; + if (!params.thumbnailUrl) { + thumbnailPreview = Gerbil; + } else if (thumbError) { + thumbnailPreview = ThumbnailBrokenImage; + } else { + thumbnailPreview = params.thumbnailUrl; + } + // TODO clear and bail after submit return ( <> @@ -258,7 +282,7 @@ function ChannelForm(props: Props) { title={__('Cover')} onClick={() => openModal(MODALS.IMAGE_UPLOAD, { - onUpdate: (coverUrl) => handleCoverChange(coverUrl), + onUpdate: (coverUrl, isUpload) => handleCoverChange(coverUrl, isUpload), title: __('Edit Cover Image'), helpText: __('(6.25:1)'), assetName: __('Cover Image'), @@ -270,11 +294,16 @@ function ChannelForm(props: Props) { /> {params.coverUrl && - (coverError ? ( + (coverError && isUpload.cover ? (
{__('This will be visible in a few minutes.')}
) : ( - setCoverError(true)} /> - ))} + setCoverError(true)} + /> + ) + )}
-
{error &&
{error}
} {useUrl ? ( @@ -129,7 +90,7 @@ function SelectAsset(props: Props) { value={url} onChange={(e) => { setUrl(e.target.value); - onUpdate(e.target.value); + onUpdate(e.target.value, !useUrl); }} /> ) : ( @@ -151,6 +112,25 @@ function SelectAsset(props: Props) { /> )}
+ +
+ {onDone && ( +
); diff --git a/ui/component/selectThumbnail/view.jsx b/ui/component/selectThumbnail/view.jsx index ca8ed5a28..969821f94 100644 --- a/ui/component/selectThumbnail/view.jsx +++ b/ui/component/selectThumbnail/view.jsx @@ -93,9 +93,7 @@ class SelectThumbnail extends React.PureComponent { style={{ display: 'none' }} src={thumbnailSrc} alt={__('Thumbnail Preview')} - onError={(e) => { - updatePublishForm({ thumbnailError: true }); - }} + onError={() => updatePublishForm({ thumbnailError: true })} />
@@ -130,12 +128,7 @@ class SelectThumbnail extends React.PureComponent { )} {status === THUMBNAIL_STATUSES.COMPLETE && thumbnail && (
-
- {__('This will be visible in a few minutes.')} -
+

{__('Upload complete.')}

diff --git a/ui/modal/modalConfirmThumbnailUpload/view.jsx b/ui/modal/modalConfirmThumbnailUpload/view.jsx index f03569e39..4f2380b27 100644 --- a/ui/modal/modalConfirmThumbnailUpload/view.jsx +++ b/ui/modal/modalConfirmThumbnailUpload/view.jsx @@ -13,13 +13,16 @@ type Props = { class ModalConfirmThumbnailUpload extends React.PureComponent { upload() { const { upload, updatePublishForm, closeModal, file } = this.props; - upload(file); - updatePublishForm({ thumbnailPath: file.path }); - closeModal(); + if (file) { + upload(file); + updatePublishForm({ thumbnailPath: file.path }); + closeModal(); + } } render() { const { closeModal, file } = this.props; + const filePath = file && (file.path || file.name); return ( { > -
{file.path || file.name}
+
{filePath}
); } diff --git a/ui/modal/modalImageUpload/index.js b/ui/modal/modalImageUpload/index.js index 8a7428e4e..f44a80f8c 100644 --- a/ui/modal/modalImageUpload/index.js +++ b/ui/modal/modalImageUpload/index.js @@ -2,10 +2,8 @@ import { connect } from 'react-redux'; import { doHideModal } from 'redux/actions/app'; import ModalImageUpload from './view'; -const perform = dispatch => () => ({ - closeModal: () => { - dispatch(doHideModal()); - }, +const perform = dispatch => ({ + closeModal: () => dispatch(doHideModal()), }); export default connect(null, perform)(ModalImageUpload); diff --git a/ui/modal/modalImageUpload/view.jsx b/ui/modal/modalImageUpload/view.jsx index dc0ad52a2..c5f5e3871 100644 --- a/ui/modal/modalImageUpload/view.jsx +++ b/ui/modal/modalImageUpload/view.jsx @@ -8,7 +8,7 @@ type Props = { currentValue: string, title: string, helpText: string, - onUpdate: string => void, + onUpdate: (string, boolean) => void, assetName: string, }; @@ -18,7 +18,7 @@ function ModalImageUpload(props: Props) { return ( onUpdate(v)} + onUpdate={(a, b) => onUpdate(a, b)} currentValue={currentValue} assetName={assetName} recommended={helpText} diff --git a/ui/scss/component/_channel.scss b/ui/scss/component/_channel.scss index 00d48c7bc..28df3462a 100644 --- a/ui/scss/component/_channel.scss +++ b/ui/scss/component/_channel.scss @@ -84,7 +84,7 @@ $actions-z-index: 2; margin-right: var(--spacing-xs); } -.chanel-thumbnail--waiting { +.channel-thumbnail--waiting { background-color: var(--color-gray-5); border-radius: var(--border-radius); padding-top: 4rem;