lbry-desktop/src/renderer/component/selectThumbnail/view.jsx

89 lines
2.4 KiB
React
Raw Normal View History

2018-04-02 18:39:00 +02:00
// @flow
import * as modals from 'constants/modal_types';
import * as statuses from 'constants/thumbnail_upload_statuses';
import React from 'react';
import { FormField } from 'component/common/form';
import FileSelector from 'component/common/file-selector';
type Props = {
thumbnail: ?string,
formDisabled: boolean,
uploadThumbnailStatus: string,
openModal: (string, any) => void,
updatePublishForm: ({}) => void,
};
class SelectThumbnail extends React.PureComponent<Props> {
render() {
const {
thumbnail,
formDisabled,
uploadThumbnailStatus: status,
openModal,
updatePublishForm,
} = this.props;
return (
<div>
{(status === statuses.READY || status === statuses.IN_PROGRESS) && (
<div>
<span className="form-field__label">{__('Thumbnail')}</span>
<FileSelector
fileLabel={__('Choose Thumbnail')}
onFileChosen={path => openModal(modals.CONFIRM_THUMBNAIL_UPLOAD, { path })}
/>
</div>
)}
{(status === statuses.API_DOWN || status === statuses.MANUAL) && (
<FormField
stretch
type="text"
name="content_thumbnail"
label={__('Thumbnail')}
placeholder="http://spee.ch/mylogo"
value={thumbnail}
disabled={formDisabled}
onChange={e => updatePublishForm({ thumbnail: e.target.value })}
/>
)}
{status === statuses.READY && (
2018-04-02 19:19:21 +02:00
<p>
2018-04-02 18:39:00 +02:00
<a
className="link"
onClick={() => updatePublishForm({ uploadThumbnailStatus: statuses.MANUAL })}
>
Enter URL Manually
</a>
2018-04-02 19:19:21 +02:00
</p>
2018-04-02 18:39:00 +02:00
)}
{status === statuses.MANUAL && (
2018-04-02 19:19:21 +02:00
<p>
2018-04-02 18:39:00 +02:00
<a
className="link"
onClick={() => updatePublishForm({ uploadThumbnailStatus: statuses.READY })}
>
Upload Thumbnail
</a>
2018-04-02 19:19:21 +02:00
</p>
2018-04-02 18:39:00 +02:00
)}
2018-04-02 19:33:17 +02:00
{status === statuses.IN_PROGRESS && <p>uploading...</p>}
2018-04-02 18:39:00 +02:00
{status === statuses.COMPLETE && (
<div>
<p className="form-field__label">{__('Thumbnail')}</p>
<p>
Upload Complete<br />URL: {thumbnail}
</p>
</div>
)}
</div>
);
}
}
export default SelectThumbnail;