Skip to content

Commit

Permalink
update storage breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Mar 27, 2024
1 parent 134a769 commit 401f2d1
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ export default function PersistentVolume(): ReactElement {
export function PersistentVolumeInfo(): ReactElement {
const pv = useOutletContext() as PersistentVolumeT

return (
<section>
<SubTitle>Info</SubTitle>
{pv.status}
</section>
)
return <section>TODO</section>
}

export function PersistentVolumeRaw(): ReactElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createColumnHelper } from '@tanstack/react-table'
import { useMemo } from 'react'
import { ChipList } from '@pluralsh/design-system'
import { ChipList, useSetBreadcrumbs } from '@pluralsh/design-system'
import { Link } from 'react-router-dom'

import {
Maybe,
Persistentvolumeclaim_PersistentVolumeClaimList as PersistentVolumeClaimListT,
Persistentvolumeclaim_PersistentVolumeClaim as PersistentVolumeClaimT,
PersistentVolumeClaimsQuery,
Expand All @@ -14,10 +15,38 @@ import { useDefaultColumns } from '../utils'
import { ResourceList } from '../ResourceList'
import { ClusterTinyFragment } from '../../../generated/graphql'
import { InlineLink } from '../../utils/typography/InlineLink'
import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts'
import {
PERSISTENT_VOLUME_CLAIMS_REL_PATH,
getKubernetesAbsPath,
getResourceDetailsAbsPath,
getStorageAbsPath,
} from '../../../routes/kubernetesRoutesConsts'

import { useKubernetesContext } from '../Kubernetes'

import { PVCStatusChip } from './utils'

export const getBreadcrumbs = (cluster?: Maybe<ClusterTinyFragment>) => [
{
label: 'kubernetes',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: cluster?.name ?? '',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: 'storage',
url: getStorageAbsPath(cluster?.id),
},
{
label: 'persistent volume claims',
url: `${getStorageAbsPath(
cluster?.id
)}/${PERSISTENT_VOLUME_CLAIMS_REL_PATH}`,
},
]

const columnHelper = createColumnHelper<PersistentVolumeClaimT>()

const colStatus = columnHelper.accessor((pvc) => pvc.status, {
Expand Down Expand Up @@ -87,6 +116,10 @@ const colAccessModes = columnHelper.accessor((pvc) => pvc.accessModes, {
})

export default function PersistentVolumeClaims() {
const { cluster } = useKubernetesContext()

useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster]))

const { colName, colNamespace, colLabels, colCreationTimestamp } =
useDefaultColumns(columnHelper)
const columns = useMemo(
Expand Down
28 changes: 1 addition & 27 deletions assets/src/components/kubernetes/storage/Storage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { Outlet, useMatch } from 'react-router-dom'
import {
SubTab,
TabList,
TabPanel,
useSetBreadcrumbs,
} from '@pluralsh/design-system'
import { SubTab, TabList, TabPanel } from '@pluralsh/design-system'
import { Suspense, useMemo, useRef, useState } from 'react'

import {
PERSISTENT_VOLUMES_REL_PATH,
PERSISTENT_VOLUME_CLAIMS_REL_PATH,
STORAGE_CLASSES_REL_PATH,
getKubernetesAbsPath,
getStorageAbsPath,
} from '../../../routes/kubernetesRoutesConsts'

Expand Down Expand Up @@ -51,26 +45,6 @@ export default function Storage() {
const tab = pathMatch?.params?.tab || ''
const currentTab = directory.find(({ path }) => path === tab)

useSetBreadcrumbs(
useMemo(
() => [
{
label: 'kubernetes',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: cluster?.name ?? '',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: 'storage',
url: getStorageAbsPath(cluster?.id),
},
],
[cluster]
)
)

const headerContent = useMemo(
() => (
<TabList
Expand Down
33 changes: 32 additions & 1 deletion assets/src/components/kubernetes/storage/StorageClasses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { createColumnHelper } from '@tanstack/react-table'

import { useMemo } from 'react'

import { ChipList } from '@pluralsh/design-system'
import { ChipList, useSetBreadcrumbs } from '@pluralsh/design-system'

import {
Maybe,
Storageclass_StorageClassList as StorageClassListT,
Storageclass_StorageClass as StorageClassT,
StorageClassesQuery,
Expand All @@ -13,6 +14,32 @@ import {
} from '../../../generated/graphql-kubernetes'
import { useDefaultColumns } from '../utils'
import { ResourceList } from '../ResourceList'
import { ClusterTinyFragment } from '../../../generated/graphql'
import {
STORAGE_CLASSES_REL_PATH,
getKubernetesAbsPath,
getStorageAbsPath,
} from '../../../routes/kubernetesRoutesConsts'
import { useKubernetesContext } from '../Kubernetes'

export const getBreadcrumbs = (cluster?: Maybe<ClusterTinyFragment>) => [
{
label: 'kubernetes',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: cluster?.name ?? '',
url: getKubernetesAbsPath(cluster?.id),
},
{
label: 'storage',
url: getStorageAbsPath(cluster?.id),
},
{
label: 'storage classes',
url: `${getStorageAbsPath(cluster?.id)}/${STORAGE_CLASSES_REL_PATH}`,
},
]

const columnHelper = createColumnHelper<StorageClassT>()

Expand Down Expand Up @@ -47,6 +74,10 @@ const colParameters = columnHelper.accessor(
)

export default function StorageClasses() {
const { cluster } = useKubernetesContext()

useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster]))

const { colName, colLabels, colCreationTimestamp } =
useDefaultColumns(columnHelper)
const columns = useMemo(
Expand Down

0 comments on commit 401f2d1

Please sign in to comment.