Skip to content

Commit

Permalink
docs: add nil guards to render pack versions DOC-1583 (#5366)
Browse files Browse the repository at this point in the history
* docs: add nil guards to render pack versions DOC-1583

* ci: auto-formatting prettier issues

---------

Co-authored-by: addetz <[email protected]>
  • Loading branch information
addetz and addetz authored Jan 10, 2025
1 parent 75135c1 commit d501037
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
24 changes: 17 additions & 7 deletions src/components/PacksReadme/PacksReadme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,29 @@ function compareVersions(v1: string, v2: string): number {
return 0;
}

function sortChildren(tagVersion: Version) {
const children = tagVersion.children || [];
return children
.sort((a, b) => compareVersions(a.title, b.title))
.map((child) => ({
value: `${child.title}===${child.packUid}`,
title: <span>{child.title}</span>,
}));
}

function renderVersionOptions(packData: PackData) {
return packData.versions
// If there are no versions, we exit immediately
const versions = packData.versions;
if (versions === undefined) {
return;
}
return versions
.sort((a, b) => compareVersions(a.title, b.title))
.map((tagVersion) => ({
value: tagVersion.title,
title: tagVersion.title,
selectable: false,
children: tagVersion.children
.sort((a, b) => compareVersions(a.title, b.title))
.map((child) => ({
value: `${child.title}===${child.packUid}`,
title: <span>{child.title}</span>,
})),
children: sortChildren(tagVersion),
}));
}

Expand Down
2 changes: 0 additions & 2 deletions src/constants/packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const cloudProviderTypes = [
{ name: "aks", displayName: "Azure AKS" },
{ name: "gcp", displayName: "GCP IaaS" },
{ name: "gke", displayName: "GCP GKE" },
{ name: "tke", displayName: "TKE" },
{ name: "vsphere", displayName: "VMware" },
{ name: "openstack", displayName: "OpenStack" },
{ name: "maas", displayName: "MAAS" },
Expand Down Expand Up @@ -76,7 +75,6 @@ export const cloudDisplayNames = {
vsphere: "VMware",
openstack: "OpenStack",
maas: "MAAS",
tke: "Tencent",
"edge-native": "Edge",
custom: "Custom",
} as const;
5 changes: 4 additions & 1 deletion static/packs-data/exclude_packs.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"edge-os",
"spectro-zen-of-k8s",
"spectro-mgmt",
"virtual-machine-orchestrator"
"csi-tke",
"kubernetes-tke",
"tke-managed-os",
"cni-tke-global-router"
]

0 comments on commit d501037

Please sign in to comment.