Skip to content

Commit

Permalink
fix details view links
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks committed Mar 25, 2024
1 parent e5da6a4 commit 622cba9
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
1 change: 1 addition & 0 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions assets/src/components/kubernetes/cluster/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -43,11 +43,7 @@ const colObjectNamespace = columnHelper.accessor(

return (
<InlineLink
href={getClusterResourceDetailsAbsPath(
NAMESPACES_REL_PATH,
cluster?.id,
namespace
)}
href={getResourceDetailsAbsPath(cluster?.id, 'namespace', namespace!)}
onClick={(e) => e.stopPropagation()}
>
{getValue()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -42,10 +41,10 @@ const colVolume = columnHelper.accessor((pvc) => pvc.volume, {

return (
<InlineLink
href={getStorageResourceDetailsAbsPath(
PERSISTENT_VOLUME_REL_PATH,
href={getResourceDetailsAbsPath(
cluster?.id,
getValue()
'persistentvolume',
getValue()!
)}
onClick={(e) => e.stopPropagation()}
>
Expand All @@ -65,10 +64,10 @@ const colStorageClass = columnHelper.accessor((pvc) => pvc.storageClass, {

return (
<InlineLink
href={getStorageResourceDetailsAbsPath(
STORAGE_CLASSES_REL_PATH,
href={getResourceDetailsAbsPath(
cluster?.id,
getValue()
'storageclass',
getValue()!
)}
onClick={(e) => e.stopPropagation()}
>
Expand Down
20 changes: 10 additions & 10 deletions assets/src/components/kubernetes/utils.tsx
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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<T>) {
return useMemo(
() => ({
Expand All @@ -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
Expand All @@ -50,10 +50,10 @@ export function useDefaultColumns<

return (
<InlineLink
href={getClusterResourceDetailsAbsPath(
NAMESPACES_REL_PATH,
href={getResourceDetailsAbsPath(
cluster?.id,
namespace
'namespace',
row.original.objectMeta.namespace!
)}
onClick={(e) => e.stopPropagation()}
>
Expand Down
12 changes: 3 additions & 9 deletions assets/src/components/kubernetes/workloads/Pods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PodT>()
Expand Down Expand Up @@ -52,11 +50,7 @@ const colNode = columnHelper.accessor((pod) => pod?.nodeName, {

return (
<InlineLink
href={getClusterResourceDetailsAbsPath(
NODES_REL_PATH,
cluster?.id,
getValue()
)}
href={getResourceDetailsAbsPath(cluster?.id, 'node', getValue())}
onClick={(e) => e.stopPropagation()}
>
{getValue()}
Expand Down
6 changes: 4 additions & 2 deletions assets/src/routes/kubernetesRoutesConsts.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -92,8 +94,8 @@ export function getResourceDetailsAbsPath(
namespace?: Nullable<string>
): 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(
Expand Down
8 changes: 8 additions & 0 deletions assets/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 622cba9

Please sign in to comment.