fleet/frontend/pages/ManageControlsPage/components/FileUploader/FileUploader.tsx
Jacob Shandling c34d046b11
Fix profile upload button hover/click issues (#10377)
## Addresses #10302 

## Now


https://user-images.githubusercontent.com/61553566/223589009-c1d22dd3-9432-4569-aece-d895630c1d4b.mov




# Checklist for submitter
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-03-08 09:38:51 -08:00

46 lines
1.1 KiB
TypeScript

import React, { useRef } from "react";
import Button from "components/buttons/Button";
import Icon from "components/Icon";
import { IconNames } from "components/icons";
const baseClass = "file-uploader";
interface IFileUploaderProps {
icon: IconNames;
message: string;
isLoading?: boolean;
onFileUpload: (files: FileList | null) => void;
}
const FileUploader = ({
icon,
message,
isLoading = false,
onFileUpload,
}: IFileUploaderProps) => {
const labelRef = useRef<HTMLLabelElement>(null);
const onUploadClick = () => {
labelRef.current?.click();
};
return (
<div className={baseClass}>
<Icon name={icon} />
<p>{message}</p>
<Button variant="brand" onClick={onUploadClick} isLoading={isLoading}>
<label htmlFor="upload-profile" ref={labelRef}>
Upload
</label>
</Button>
<input
accept=".mobileconfig,application/x-apple-aspen-config"
id="upload-profile"
type="file"
onChange={(e) => onFileUpload(e.target.files)}
/>
</div>
);
};
export default FileUploader;