Files
redash/client/app/components/dynamic-form/fields/FileField.jsx
2020-08-25 14:24:15 -03:00

19 lines
594 B
JavaScript

import React from "react";
import Button from "antd/lib/button";
import Upload from "antd/lib/upload";
import UploadOutlinedIcon from "@ant-design/icons/UploadOutlined";
export default function FileField({ form, field, ...otherProps }) {
const { name, initialValue } = field;
const { getFieldValue } = form;
const disabled = getFieldValue(name) !== undefined && getFieldValue(name) !== initialValue;
return (
<Upload {...otherProps} beforeUpload={() => false}>
<Button disabled={disabled}>
<UploadOutlinedIcon /> Click to upload
</Button>
</Upload>
);
}