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

66 lines
1.6 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";
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 (
<React.Fragment>
2019-12-03 04:41:10 +00:00
<BaseButton
accent={"primary"}
2019-12-03 04:41:10 +00:00
className={this.props.isLoading ? "bp3-skeleton" : ""}
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}
// 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 });
}
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;
files: any[];
2019-11-05 05:09:50 +00:00
}
export default FilePickerComponent;