mirror of
https://github.com/fleetdm/fleet
synced 2026-05-14 20:48:35 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #32632 # Details Resolves a couple of issues caught in QA: 1. Script uploader now shows correct icon in empty state, *nix shell script uploaded and Powershell script uploaded: <img width="640" alt="image" src="https://github.com/user-attachments/assets/7467d596-f3f9-43a3-9bfc-bb08d56e2c2b" /> <img width="640" height="360" alt="image" src="https://github.com/user-attachments/assets/6d148672-38a5-49d1-b0ca-cb9e5d992b81" /> <img width="640" height="314" alt="image" src="https://github.com/user-attachments/assets/b4dc3069-f54d-40d1-b7ef-3d1afc1a2e21" /> 2. Updated title text for profile upload from "Update configuration profile" to "Upload configuration profile" <img width="640" height="275" alt="image" src="https://github.com/user-attachments/assets/3daead86-3b40-415a-8472-6895402840bd" /> <img width="640" height="579" alt="image" src="https://github.com/user-attachments/assets/40583c0f-83a6-4800-be21-f9e6fd5304d3" /> # Checklist for submitter ## Testing - [X] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [X] Confirmed that the fix is not expected to adversely impact load test results
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import React from "react";
|
|
|
|
import FileUploader, { ISupportedGraphicNames } from "components/FileUploader";
|
|
import { getFileDetails } from "utilities/file/fileUtils";
|
|
|
|
const baseClass = "script-uploader";
|
|
|
|
interface IScriptPackageUploaderProps {
|
|
onFileSelected?: (file: File) => void;
|
|
selectedFile?: File | null;
|
|
forModal?: boolean;
|
|
onButtonClick?: () => void;
|
|
}
|
|
|
|
const ScriptPackageUploader = ({
|
|
forModal,
|
|
onFileSelected,
|
|
selectedFile,
|
|
onButtonClick,
|
|
}: IScriptPackageUploaderProps) => {
|
|
const onFileSelect = (files: FileList | null) => {
|
|
if (files && files.length > 0) {
|
|
onFileSelected?.(files[0]);
|
|
}
|
|
};
|
|
|
|
const buttonType = forModal ? "brand-inverse-icon" : undefined;
|
|
const buttonMessage = forModal ? "Choose file" : "Add script";
|
|
const extension = selectedFile?.name.match(/(sh|ps1)$/i)?.[1];
|
|
let graphicName: ISupportedGraphicNames[];
|
|
switch (extension) {
|
|
case "ps1":
|
|
graphicName = ["file-ps1"];
|
|
break;
|
|
case "sh":
|
|
graphicName = ["file-sh"];
|
|
break;
|
|
default:
|
|
graphicName = ["file-sh", "file-ps1"];
|
|
}
|
|
|
|
return (
|
|
<FileUploader
|
|
className={baseClass}
|
|
graphicName={graphicName}
|
|
message="Shell (.sh) for macOS and Linux or PowerShell (.ps1) for Windows"
|
|
title="Upload script"
|
|
accept=".sh,.ps1"
|
|
onFileUpload={onFileSelect}
|
|
fileDetails={selectedFile ? getFileDetails(selectedFile) : undefined}
|
|
buttonType={buttonType}
|
|
buttonMessage={buttonMessage}
|
|
gitopsCompatible
|
|
onButtonClick={onButtonClick}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default ScriptPackageUploader;
|