diff --git a/assets/package.json b/assets/package.json index 346c99116c..17fff264a2 100644 --- a/assets/package.json +++ b/assets/package.json @@ -78,6 +78,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "phoenix": "1.7.3", + "pluralize": "8.0.0", "pluralsh-absinthe-socket-apollo-link": "0.2.0", "query-string": "8.1.0", "randomcolor": "0.6.2", diff --git a/assets/src/components/kubernetes/cluster/Events.tsx b/assets/src/components/kubernetes/cluster/Events.tsx index 994502c2ba..f84c7ac6e5 100644 --- a/assets/src/components/kubernetes/cluster/Events.tsx +++ b/assets/src/components/kubernetes/cluster/Events.tsx @@ -14,7 +14,7 @@ import { ClusterTinyFragment } from '../../../generated/graphql' import { InlineLink } from '../../utils/typography/InlineLink' import { NAMESPACES_REL_PATH, - getClusterResourceDetailsAbsPath, + getResourceDetailsAbsPath, } from '../../../routes/kubernetesRoutesConsts' import { EventTypeChip } from './utils' @@ -43,11 +43,7 @@ const colObjectNamespace = columnHelper.accessor( return ( e.stopPropagation()} > {getValue()} diff --git a/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx b/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx index 3bb5f385a7..bcefa6ce57 100644 --- a/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx +++ b/assets/src/components/kubernetes/storage/PersistentVolumeClaims.tsx @@ -16,9 +16,8 @@ import { ResourceList } from '../ResourceList' import { ClusterTinyFragment } from '../../../generated/graphql' import { InlineLink } from '../../utils/typography/InlineLink' import { - PERSISTENT_VOLUME_REL_PATH, STORAGE_CLASSES_REL_PATH, - getClusterResourceDetailsAbsPath, + getResourceDetailsAbsPath, getStorageResourceDetailsAbsPath, } from '../../../routes/kubernetesRoutesConsts' @@ -42,10 +41,10 @@ const colVolume = columnHelper.accessor((pvc) => pvc.volume, { return ( e.stopPropagation()} > @@ -65,10 +64,10 @@ const colStorageClass = columnHelper.accessor((pvc) => pvc.storageClass, { return ( e.stopPropagation()} > diff --git a/assets/src/components/kubernetes/utils.tsx b/assets/src/components/kubernetes/utils.tsx index bba6b1409c..32ca2f6f01 100644 --- a/assets/src/components/kubernetes/utils.tsx +++ b/assets/src/components/kubernetes/utils.tsx @@ -1,20 +1,17 @@ import uniqWith from 'lodash/uniqWith' import { useMemo, useState } from 'react' import { ColumnHelper, SortingState, TableOptions } from '@tanstack/react-table' - import { ChipList } from '@pluralsh/design-system' import { Types_ListMeta as ListMetaT, Types_ObjectMeta as ObjectMetaT, + Types_TypeMeta as TypeMetaT, } from '../../generated/graphql-kubernetes' import { DateTimeCol } from '../utils/table/DateTimeCol' import { ClusterTinyFragment } from '../../generated/graphql' import { InlineLink } from '../utils/typography/InlineLink' -import { - NAMESPACES_REL_PATH, - getClusterResourceDetailsAbsPath, -} from '../../routes/kubernetesRoutesConsts' +import { getResourceDetailsAbsPath } from '../../routes/kubernetesRoutesConsts' export const ITEMS_PER_PAGE = 25 @@ -24,7 +21,10 @@ export const DEFAULT_DATA_SELECT = { } export function useDefaultColumns< - T extends { objectMeta: ObjectMetaT } = { objectMeta: ObjectMetaT }, + T extends { objectMeta: ObjectMetaT; typeMeta: TypeMetaT } = { + objectMeta: ObjectMetaT + typeMeta: TypeMetaT + }, >(columnHelper: ColumnHelper) { return useMemo( () => ({ @@ -39,7 +39,7 @@ export function useDefaultColumns< id: 'namespace', header: 'Namespace', enableSorting: true, - cell: ({ getValue, table }) => { + cell: ({ getValue, table, row }) => { const namespace = getValue() if (!namespace) return null @@ -50,10 +50,10 @@ export function useDefaultColumns< return ( e.stopPropagation()} > diff --git a/assets/src/components/kubernetes/workloads/Pods.tsx b/assets/src/components/kubernetes/workloads/Pods.tsx index 08c399caf9..92b7315eda 100644 --- a/assets/src/components/kubernetes/workloads/Pods.tsx +++ b/assets/src/components/kubernetes/workloads/Pods.tsx @@ -11,12 +11,10 @@ import { import { useDefaultColumns } from '../utils' import { ResourceList } from '../ResourceList' import { InlineLink } from '../../utils/typography/InlineLink' -import { - NODES_REL_PATH, - getClusterResourceDetailsAbsPath, -} from '../../../routes/kubernetesRoutesConsts' import { ClusterTinyFragment } from '../../../generated/graphql' +import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' + import { PodStatusChip, WorkloadImages } from './utils' const columnHelper = createColumnHelper() @@ -52,11 +50,7 @@ const colNode = columnHelper.accessor((pod) => pod?.nodeName, { return ( e.stopPropagation()} > {getValue()} diff --git a/assets/src/routes/kubernetesRoutesConsts.tsx b/assets/src/routes/kubernetesRoutesConsts.tsx index 15c4ab82ef..efbdf2c4d6 100644 --- a/assets/src/routes/kubernetesRoutesConsts.tsx +++ b/assets/src/routes/kubernetesRoutesConsts.tsx @@ -1,3 +1,5 @@ +import * as pluralize from 'pluralize' + export const KUBERNETES_OPTIONAL_PARAM_CLUSTER = ':clusterId?' export const KUBERNETES_ABS_PATH = getKubernetesAbsPath( KUBERNETES_OPTIONAL_PARAM_CLUSTER @@ -92,8 +94,8 @@ export function getResourceDetailsAbsPath( namespace?: Nullable ): string { return namespace - ? `/kubernetes/${clusterId}/${kind}s/${namespace}/${name}` - : `/kubernetes/${clusterId}/${kind}s/${name}` + ? `/kubernetes/${clusterId}/${pluralize(kind)}/${namespace}/${name}` + : `/kubernetes/${clusterId}/${pluralize(kind)}/${name}` } export function getStorageResourceDetailsAbsPath( diff --git a/assets/yarn.lock b/assets/yarn.lock index e831bbc9fc..373f8d005f 100644 --- a/assets/yarn.lock +++ b/assets/yarn.lock @@ -9574,6 +9574,7 @@ __metadata: moment-timezone: 0.5.43 npm-run-all: 4.1.5 phoenix: 1.7.3 + pluralize: 8.0.0 pluralsh-absinthe-socket-apollo-link: 0.2.0 prettier: 3.0.3 query-string: 8.1.0 @@ -16274,6 +16275,13 @@ __metadata: languageName: node linkType: hard +"pluralize@npm:8.0.0": + version: 8.0.0 + resolution: "pluralize@npm:8.0.0" + checksum: 08931d4a6a4a5561a7f94f67a31c17e6632cb21e459ab3ff4f6f629d9a822984cf8afef2311d2005fbea5d7ef26016ebb090db008e2d8bce39d0a9a9d218736e + languageName: node + linkType: hard + "pluralsh-absinthe-socket-apollo-link@npm:0.2.0": version: 0.2.0 resolution: "pluralsh-absinthe-socket-apollo-link@npm:0.2.0"