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

58 lines
1.3 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
class FilePickerComponent extends React.Component<
FilePickerComponentProps,
FilePickerComponentState
> {
constructor(props: FilePickerComponentProps) {
super(props);
this.state = {
isOpen: false,
};
}
openModal = () => {
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 (
<BaseButton
buttonStyle="PRIMARY"
disabled={this.props.isDisabled}
loading={this.props.isLoading}
onClick={this.openModal}
text={label}
/>
2019-11-05 05:09:50 +00:00
);
}
public closeModal() {
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;