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
|
|
|
import { DashboardModal } from "@uppy/react";
|
|
|
|
|
|
|
|
|
|
class FilePickerComponent extends React.Component<
|
|
|
|
|
FilePickerComponentProps,
|
|
|
|
|
FilePickerComponentState
|
|
|
|
|
> {
|
|
|
|
|
constructor(props: FilePickerComponentProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
isOpen: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openModal = () => {
|
|
|
|
|
this.setState({ isOpen: true });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2019-11-13 07:00:25 +00:00
|
|
|
<React.Fragment>
|
2019-12-03 04:41:10 +00:00
|
|
|
<BaseButton
|
2020-02-21 13:17:52 +00:00
|
|
|
accent={"primary"}
|
2019-12-03 04:41:10 +00:00
|
|
|
className={this.props.isLoading ? "bp3-skeleton" : ""}
|
2020-02-21 13:17:52 +00:00
|
|
|
text={
|
|
|
|
|
this.props.files && this.props.files.length === 0
|
|
|
|
|
? "Select files"
|
|
|
|
|
: this.props.files.length + " Files Selected"
|
|
|
|
|
}
|
2019-12-03 04:41:10 +00:00
|
|
|
onClick={this.openModal}
|
|
|
|
|
/>
|
2019-11-05 05:09:50 +00:00
|
|
|
<DashboardModal
|
|
|
|
|
open={this.state.isOpen}
|
|
|
|
|
target={document.body}
|
|
|
|
|
closeModalOnClickOutside={true}
|
2020-02-21 13:17:52 +00:00
|
|
|
// plugins={["GoogleDrive", "Url", "OneDrive", "Webcam"]}
|
|
|
|
|
onRequestClose={this.closeModal}
|
2019-11-05 05:09:50 +00:00
|
|
|
uppy={this.props.uppy}
|
|
|
|
|
/>
|
2019-11-13 07:00:25 +00:00
|
|
|
</React.Fragment>
|
2019-11-05 05:09:50 +00:00
|
|
|
);
|
|
|
|
|
}
|
2020-02-21 13:17:52 +00:00
|
|
|
|
|
|
|
|
public closeModal() {
|
|
|
|
|
this.setState({ isOpen: false });
|
|
|
|
|
}
|
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-02-21 13:17:52 +00:00
|
|
|
files: any[];
|
2019-11-05 05:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default FilePickerComponent;
|