Skip to content

Commit

Permalink
Fleet UI: Add support for .rpm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelElysia committed Sep 27, 2024
1 parent 348d381 commit 1a403fc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions changes/20537-rpm-fe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add support for .rpm files in add/edit software
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface IPackageFormProps {
defaultSelfService?: boolean;
}

const ACCEPTED_EXTENSIONS = ".pkg,.msi,.exe,.deb";
const ACCEPTED_EXTENSIONS = ".pkg,.msi,.exe,.deb,.rpm";

const PackageForm = ({
isUploading,
Expand Down Expand Up @@ -173,7 +173,7 @@ const PackageForm = ({
canEdit={isEditingSoftware}
graphicName={"file-pkg"}
accept={ACCEPTED_EXTENSIONS}
message=".pkg, .msi, .exe, or .deb"
message=".pkg, .msi, .exe, .deb, or .rpm"
onFileUpload={onFileSelect}
buttonMessage="Choose file"
buttonType="link"
Expand Down
23 changes: 15 additions & 8 deletions frontend/utilities/file/fileUtils.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ import { getPlatformDisplayName } from "./fileUtils";

describe("fileUtils", () => {
describe("getPlatformDisplayName", () => {
it("should return the correct platform display name depending on the file extension", () => {
const file = new File([""], "test.pkg");
expect(getPlatformDisplayName(file)).toEqual("macOS");
const testCases = [
{ extension: "pkg", platform: "macOS" },
{ extension: "json", platform: "macOS" },
{ extension: "mobileconfig", platform: "macOS" },
{ extension: "exe", platform: "Windows" },
{ extension: "msi", platform: "Windows" },
{ extension: "xml", platform: "Windows" },
{ extension: "deb", platform: "Linux" },
{ extension: "rpm", platform: "Linux" },
];

const file2 = new File([""], "test.exe");
expect(getPlatformDisplayName(file2)).toEqual("Windows");

const file3 = new File([""], "test.deb");
expect(getPlatformDisplayName(file3)).toEqual("linux");
testCases.forEach(({ extension, platform }) => {
it(`should return ${platform} for .${extension} files`, () => {
const file = new File([""], `test.${extension}`);
expect(getPlatformDisplayName(file)).toEqual(platform);
});
});
});
});
5 changes: 3 additions & 2 deletions frontend/utilities/file/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type IPlatformDisplayName = "macOS" | "Windows" | "linux";
type IPlatformDisplayName = "macOS" | "Windows" | "Linux";

const getFileExtension = (file: File) => {
const nameParts = file.name.split(".");
Expand All @@ -15,7 +15,8 @@ export const FILE_EXTENSIONS_TO_PLATFORM_DISPLAY_NAME: Record<
exe: "Windows",
msi: "Windows",
xml: "Windows",
deb: "linux",
deb: "Linux",
rpm: "Linux",
};

/**
Expand Down

0 comments on commit 1a403fc

Please sign in to comment.