2019-11-05 05:09:50 +00:00
|
|
|
import * as React from "react";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
|
2019-11-05 05:09:50 +00:00
|
|
|
import "@uppy/core/dist/style.css";
|
|
|
|
|
import "@uppy/dashboard/dist/style.css";
|
|
|
|
|
import "@uppy/webcam/dist/style.css";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { BaseButton } from "components/designSystems/blueprint/ButtonComponent";
|
2019-11-05 05:09:50 +00:00
|
|
|
|
|
|
|
|
class FilePickerComponent extends React.Component<
|
|
|
|
|
FilePickerComponentProps,
|
|
|
|
|
FilePickerComponentState
|
|
|
|
|
> {
|
|
|
|
|
constructor(props: FilePickerComponentProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
isOpen: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openModal = () => {
|
2021-07-23 09:12:51 +00:00
|
|
|
if (!this.props.isDisabled) {
|
|
|
|
|
this.props.uppy.getPlugin("Dashboard").openModal();
|
|
|
|
|
}
|
2019-11-05 05:09:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2020-03-11 08:17:21 +00:00
|
|
|
let label = this.props.label;
|
2020-03-06 09:45:21 +00:00
|
|
|
if (this.props.files && this.props.files.length) {
|
|
|
|
|
label = `${this.props.files.length} files selected`;
|
|
|
|
|
}
|
2019-11-05 05:09:50 +00:00
|
|
|
return (
|
2021-04-28 10:28:39 +00:00
|
|
|
<BaseButton
|
2021-08-24 13:53:15 +00:00
|
|
|
buttonStyle="PRIMARY"
|
2021-04-28 10:28:39 +00:00
|
|
|
disabled={this.props.isDisabled}
|
|
|
|
|
loading={this.props.isLoading}
|
|
|
|
|
onClick={this.openModal}
|
|
|
|
|
text={label}
|
|
|
|
|
/>
|
2019-11-05 05:09:50 +00:00
|
|
|
);
|
|
|
|
|
}
|
2020-02-21 13:17:52 +00:00
|
|
|
|
|
|
|
|
public closeModal() {
|
2020-02-22 01:39:28 +00:00
|
|
|
this.props.uppy.getPlugin("Dashboard").closeModal();
|
2020-02-21 13:17:52 +00:00
|
|
|
}
|
2019-11-05 05:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface FilePickerComponentState {
|
|
|
|
|
isOpen: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface FilePickerComponentProps extends ComponentProps {
|
|
|
|
|
label: string;
|
|
|
|
|
uppy: any;
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading: boolean;
|
2020-03-06 09:45:21 +00:00
|
|
|
files?: any[];
|
2019-11-05 05:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default FilePickerComponent;
|