PromucFlow_constructor/app/client/src/components/designSystems/appsmith/FilePickerComponent.tsx
Satish Gandham 7f7f6f666b
Development: Add eslint rules for code consistency (#4083)
Co-authored-by: Satish Gandham <satish@appsmith.com>
Co-authored-by: Abhinav Jha <abhinav@appsmith.com>
2021-04-28 15:58:39 +05:30

57 lines
1.3 KiB
TypeScript

import * as React from "react";
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
import "@uppy/core/dist/style.css";
import "@uppy/dashboard/dist/style.css";
import "@uppy/webcam/dist/style.css";
import { BaseButton } from "components/designSystems/blueprint/ButtonComponent";
class FilePickerComponent extends React.Component<
FilePickerComponentProps,
FilePickerComponentState
> {
constructor(props: FilePickerComponentProps) {
super(props);
this.state = {
isOpen: false,
};
}
openModal = () => {
this.props.uppy.getPlugin("Dashboard").openModal();
};
render() {
let label = this.props.label;
if (this.props.files && this.props.files.length) {
label = `${this.props.files.length} files selected`;
}
return (
<BaseButton
accent="primary"
disabled={this.props.isDisabled}
filled
loading={this.props.isLoading}
onClick={this.openModal}
text={label}
/>
);
}
public closeModal() {
this.props.uppy.getPlugin("Dashboard").closeModal();
}
}
export interface FilePickerComponentState {
isOpen: boolean;
}
export interface FilePickerComponentProps extends ComponentProps {
label: string;
uppy: any;
isLoading: boolean;
files?: any[];
}
export default FilePickerComponent;