Skip to content

Commit

Permalink
chore: add cloud types column to deprecated packs list (DOC-903) (#1731)
Browse files Browse the repository at this point in the history
* chore: add cloud types column to deprecated packs list

* Update src/components/PacksTable/PacksTable.tsx

Co-authored-by: Karl Cardenas <[email protected]>

---------

Co-authored-by: Lenny Chen <[email protected]>
Co-authored-by: Karl Cardenas <[email protected]>
  • Loading branch information
3 people committed Nov 1, 2023
1 parent ec9fda2 commit 4102fda
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/PacksTable/PackTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,21 @@ describe("FilteredTable Tests", () => {
expect(screen.getByText("Failed to load Deprecated Packs")).toBeInTheDocument();
});
});

it("should properly format cloud types", async () => {
const customMockPacks = [
{
...mockPacks[0],
cloudTypesFormatted: "eks,vsphere"
}
];

fetchMock.mockResponseOnce(JSON.stringify({ dateCreated: "2022-08-25", Packs: customMockPacks }));
render(<FilteredTable />);

await waitFor(() => screen.getByText("Alpine"));

expect(screen.getByText("EKS, vSphere")).toBeInTheDocument();
});

});
39 changes: 39 additions & 0 deletions src/components/PacksTable/PacksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,37 @@ const statusClassNames: Record<string, string> = {
disabled: styles.disabled,
};


// Format the cloud type strings so they display properly
const formatCloudType = (type: string): string => {
const cloudTypeMapping: Record<string, string> = {
"aws": "AWS",
"eks": "EKS",
"vsphere": "vSphere",
"maas": "MaaS",
"gcp": "GCP",
"libvirt": "libvirt",
"openstack": "OpenStack",
"edge-native": "Edge",
"tke": "TKE",
"aks": "AKS",
"coxedge": "Cox Edge",
"gke": "GKE",
"all": "All",
"azure": "Azure"
// ... add other special cases as needed
};

return type.split(',')
.map(part => cloudTypeMapping[part.trim()] || capitalizeWord(part))
.join(', ');
}

// Capitalize the word as a default option
const capitalizeWord = (string: string): string => {
return string.toUpperCase();
}

interface PacksColumn {
title: string;
dataIndex: keyof Pack;
Expand All @@ -44,6 +75,14 @@ const columns: PacksColumn[] = [
sorter: (a: Pack, b: Pack) => a.displayName.localeCompare(b.displayName),
width: 200,
},
{
title: "Cloud Types",
dataIndex: "cloudTypesFormatted",
key: "cloudTypesFormatted",
sorter: (a: Pack, b: Pack) => a.cloudTypesFormatted.localeCompare(b.cloudTypesFormatted),
render: (value: string) => formatCloudType(value),
width: 200,
},
{
title: "Version",
dataIndex: "version",
Expand Down

0 comments on commit 4102fda

Please sign in to comment.