2018-04-02 18:39:00 +02:00
|
|
|
// @flow
|
2018-04-02 18:39:00 +02:00
|
|
|
import { STATUSES } from 'lbry-redux';
|
2018-04-02 19:46:24 +02:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2018-04-02 18:39:00 +02:00
|
|
|
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,
|
2018-04-02 22:27:44 +02:00
|
|
|
openModal: (string, {}) => void,
|
2018-04-02 18:39:00 +02:00
|
|
|
updatePublishForm: ({}) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
class SelectThumbnail extends React.PureComponent<Props> {
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
thumbnail,
|
|
|
|
formDisabled,
|
|
|
|
uploadThumbnailStatus: status,
|
|
|
|
openModal,
|
|
|
|
updatePublishForm,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2018-04-02 19:46:24 +02:00
|
|
|
{(status === STATUSES.READY || status === STATUSES.IN_PROGRESS) && (
|
2018-04-02 18:39:00 +02:00
|
|
|
<div>
|
|
|
|
<span className="form-field__label">{__('Thumbnail')}</span>
|
|
|
|
<FileSelector
|
|
|
|
fileLabel={__('Choose Thumbnail')}
|
2018-04-02 19:46:24 +02:00
|
|
|
onFileChosen={path => openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, { path })}
|
2018-04-02 18:39:00 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2018-04-02 19:46:24 +02:00
|
|
|
{(status === STATUSES.API_DOWN || status === STATUSES.MANUAL) && (
|
2018-04-02 18:39:00 +02:00
|
|
|
<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 })}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2018-04-02 19:46:24 +02:00
|
|
|
{status === STATUSES.READY && (
|
2018-04-02 19:19:21 +02:00
|
|
|
<p>
|
2018-04-02 18:39:00 +02:00
|
|
|
<a
|
|
|
|
className="link"
|
2018-04-02 19:46:24 +02:00
|
|
|
onClick={() => updatePublishForm({ uploadThumbnailStatus: STATUSES.MANUAL })}
|
2018-04-02 18:39:00 +02:00
|
|
|
>
|
|
|
|
Enter URL Manually
|
|
|
|
</a>
|
2018-04-02 19:19:21 +02:00
|
|
|
</p>
|
2018-04-02 18:39:00 +02:00
|
|
|
)}
|
|
|
|
|
2018-04-02 19:46:24 +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"
|
2018-04-02 19:46:24 +02:00
|
|
|
onClick={() => updatePublishForm({ uploadThumbnailStatus: STATUSES.READY })}
|
2018-04-02 18:39:00 +02:00
|
|
|
>
|
|
|
|
Upload Thumbnail
|
|
|
|
</a>
|
2018-04-02 19:19:21 +02:00
|
|
|
</p>
|
2018-04-02 18:39:00 +02:00
|
|
|
)}
|
|
|
|
|
2018-04-02 19:46:24 +02:00
|
|
|
{status === STATUSES.IN_PROGRESS && <p>uploading...</p>}
|
2018-04-02 18:39:00 +02:00
|
|
|
|
2018-04-02 19:46:24 +02:00
|
|
|
{status === STATUSES.COMPLETE && (
|
2018-04-02 18:39:00 +02:00
|
|
|
<div>
|
|
|
|
<p className="form-field__label">{__('Thumbnail')}</p>
|
|
|
|
<p>
|
|
|
|
Upload Complete<br />URL: {thumbnail}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SelectThumbnail;
|