329d434c83
* Allow only images in modal image uploader. * Set file path and mime in file selector. * Refactor WebFile. * Update get-file-from-path to work with folders; fix file-list component. * Get rid of File | string for filePath property in components. * Show instant preview while updating channel thumbnail. * Fix publish. * Add jpeg and svg to image filter.
35 lines
933 B
JavaScript
35 lines
933 B
JavaScript
// @flow
|
|
import React from 'react';
|
|
import { Modal } from 'modal/modal';
|
|
import SelectAsset from 'component/selectAsset';
|
|
|
|
type Props = {
|
|
closeModal: () => void,
|
|
currentValue: string,
|
|
title: string,
|
|
helpText: string,
|
|
onUpdate: (string, boolean, ?string) => void,
|
|
assetName: string,
|
|
};
|
|
|
|
function ModalImageUpload(props: Props) {
|
|
const { closeModal, currentValue, title, assetName, helpText, onUpdate } = props;
|
|
const filters = React.useMemo(() => [{ name: 'Images', extensions: ['jpg', 'jpeg', 'png', 'gif', 'svg'] }]);
|
|
|
|
return (
|
|
<Modal isOpen type="card" onAborted={closeModal} contentLabel={title}>
|
|
<SelectAsset
|
|
filters={filters}
|
|
type="openFile"
|
|
onUpdate={onUpdate}
|
|
currentValue={currentValue}
|
|
assetName={assetName}
|
|
recommended={helpText}
|
|
onDone={closeModal}
|
|
buildImagePreview
|
|
/>
|
|
</Modal>
|
|
);
|
|
}
|
|
|
|
export default ModalImageUpload;
|