Skip to content

Commit

Permalink
add more links
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Mar 25, 2024
1 parent 4ce06d3 commit da070ae
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
28 changes: 27 additions & 1 deletion assets/src/components/kubernetes/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import {
} 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,
getResourceDetailsAbsPath,
} from '../../routes/kubernetesRoutesConsts'

export const ITEMS_PER_PAGE = 25

Expand All @@ -34,7 +39,28 @@ export function useDefaultColumns<
id: 'namespace',
header: 'Namespace',
enableSorting: true,
cell: ({ getValue }) => getValue(),
cell: ({ getValue, table }) => {
const namespace = getValue()

if (!namespace) return null

const { cluster } = table.options.meta as {
cluster?: ClusterTinyFragment
}

return (
<InlineLink
href={getResourceDetailsAbsPath(
NAMESPACES_REL_PATH,
cluster?.id,
namespace
)}
onClick={(e) => e.stopPropagation()}
>
{getValue()}
</InlineLink>
)
},
}),
colLabels: columnHelper.accessor((r) => r?.objectMeta.labels, {
id: 'labels',
Expand Down
11 changes: 9 additions & 2 deletions assets/src/components/kubernetes/workloads/Pods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
import { useDefaultColumns } from '../utils'
import { ResourceList } from '../ResourceList'
import { InlineLink } from '../../utils/typography/InlineLink'
import { getNodeAbsPath } from '../../../routes/kubernetesRoutesConsts'
import {
NODES_REL_PATH,
getResourceDetailsAbsPath,
} from '../../../routes/kubernetesRoutesConsts'
import { ClusterTinyFragment } from '../../../generated/graphql'

import { PodStatusChip, WorkloadImages } from './utils'
Expand Down Expand Up @@ -49,7 +52,11 @@ const colNode = columnHelper.accessor((pod) => pod?.nodeName, {

return (
<InlineLink
href={getNodeAbsPath(cluster?.id, getValue())}
href={getResourceDetailsAbsPath(
NODES_REL_PATH,
cluster?.id,
getValue()
)}
onClick={(e) => e.stopPropagation()}
>
{getValue()}
Expand Down
5 changes: 3 additions & 2 deletions assets/src/routes/kubernetesRoutesConsts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export function getResourceDetailsRelPath(
return namespace ? `${namespace}/${name}` : name
}

export function getNodeAbsPath(
export function getResourceDetailsAbsPath(
resourceRelPath,
clusterId: string | null | undefined,
name: string,
namespace?: Nullable<string>
): string {
return `${getClusterAbsPath(
clusterId
)}/${NODES_REL_PATH}/${getResourceDetailsRelPath(name, namespace)}`
)}/${resourceRelPath}/${getResourceDetailsRelPath(name, namespace)}`
}

0 comments on commit da070ae

Please sign in to comment.