2018-04-02 18:03:12 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import { Modal } from 'modal/modal';
|
2020-07-22 17:24:51 +02:00
|
|
|
import { DOMAIN } from 'config';
|
2018-04-02 18:03:12 +02:00
|
|
|
|
|
|
|
type Props = {
|
2019-10-07 22:02:32 +02:00
|
|
|
file: WebFile,
|
2021-09-13 17:40:31 +02:00
|
|
|
upload: (WebFile, (string) => void) => void,
|
|
|
|
cb: (string) => void,
|
2018-04-02 18:03:12 +02:00
|
|
|
closeModal: () => void,
|
2018-04-02 22:27:44 +02:00
|
|
|
updatePublishForm: ({}) => void,
|
2018-04-02 18:03:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ModalConfirmThumbnailUpload extends React.PureComponent<Props> {
|
|
|
|
upload() {
|
2021-09-13 17:40:31 +02:00
|
|
|
const { upload, updatePublishForm, cb, closeModal, file } = this.props;
|
2021-08-25 02:28:23 +02:00
|
|
|
if (file) {
|
2021-09-13 17:40:31 +02:00
|
|
|
upload(file, cb);
|
2021-08-25 02:28:23 +02:00
|
|
|
updatePublishForm({ thumbnailPath: file.path });
|
|
|
|
closeModal();
|
|
|
|
}
|
2018-04-02 18:03:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-10-07 22:02:32 +02:00
|
|
|
const { closeModal, file } = this.props;
|
2021-08-25 02:28:23 +02:00
|
|
|
const filePath = file && (file.path || file.name);
|
2020-11-19 18:17:47 +01:00
|
|
|
|
2018-04-02 18:03:12 +02:00
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
isOpen
|
2020-08-26 22:28:33 +02:00
|
|
|
title={__('Upload thumbnail')}
|
2018-04-02 18:03:12 +02:00
|
|
|
contentLabel={__('Confirm Thumbnail Upload')}
|
|
|
|
type="confirm"
|
|
|
|
confirmButtonLabel={__('Upload')}
|
|
|
|
onConfirmed={() => this.upload()}
|
|
|
|
onAborted={closeModal}
|
|
|
|
>
|
2020-07-22 17:24:51 +02:00
|
|
|
<label>{__('Are you sure you want to upload this thumbnail to %domain%', { domain: DOMAIN })}?</label>
|
2019-01-11 17:34:36 +01:00
|
|
|
|
2021-08-25 02:28:23 +02:00
|
|
|
<blockquote>{filePath}</blockquote>
|
2018-04-02 18:03:12 +02:00
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ModalConfirmThumbnailUpload;
|