PromucFlow_constructor/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx

68 lines
1.7 KiB
TypeScript
Raw Normal View History

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";
// import { DashboardModal } from "@uppy/react";
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 = () => {
// this.setState({ isOpen: true });
this.props.uppy.getPlugin("Dashboard").openModal();
2019-11-05 05:09:50 +00:00
};
render() {
2020-03-06 09:45:21 +00:00
let label = "Select files";
if (this.props.files && this.props.files.length) {
label = `${this.props.files.length} files selected`;
}
2019-11-05 05:09:50 +00:00
return (
<React.Fragment>
2019-12-03 04:41:10 +00:00
<BaseButton
accent="primary"
filled
2019-12-03 04:41:10 +00:00
className={this.props.isLoading ? "bp3-skeleton" : ""}
2020-03-06 09:45:21 +00:00
text={label}
2019-12-03 04:41:10 +00:00
onClick={this.openModal}
/>
{/* <DashboardModal
2019-11-05 05:09:50 +00:00
open={this.state.isOpen}
closeModalOnClickOutside={true}
// plugins={["GoogleDrive", "Url", "OneDrive", "Webcam"]}
onRequestClose={this.closeModal}
2019-11-05 05:09:50 +00:00
uppy={this.props.uppy}
/> */}
</React.Fragment>
2019-11-05 05:09:50 +00:00
);
}
public closeModal() {
// this.setState({ isOpen: false });
this.props.uppy.getPlugin("Dashboard").closeModal();
}
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;