-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8a023b
commit 134a769
Showing
8 changed files
with
213 additions
and
15 deletions.
There are no files selected for viewing
76 changes: 74 additions & 2 deletions
76
assets/src/components/kubernetes/storage/PersistentVolume.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,77 @@ | ||
import { ReactElement } from 'react' | ||
import { ReactElement, useMemo } from 'react' | ||
import { useSetBreadcrumbs } from '@pluralsh/design-system' | ||
import { Outlet, useOutletContext, useParams } from 'react-router-dom' | ||
|
||
import { | ||
ConfigMapQueryVariables, | ||
Persistentvolume_PersistentVolumeDetail as PersistentVolumeT, | ||
usePersistentVolumeQuery, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { KubernetesClient } from '../../../helpers/kubernetes.client' | ||
import LoadingIndicator from '../../utils/LoadingIndicator' | ||
import { SubTitle } from '../../cluster/nodes/SubTitle' | ||
import { MetadataSidecar, useKubernetesCluster } from '../utils' | ||
import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' | ||
|
||
import ResourceDetails, { TabEntry } from '../ResourceDetails' | ||
|
||
import { getBreadcrumbs } from './PersistentVolumes' | ||
|
||
const directory: Array<TabEntry> = [ | ||
{ path: '', label: 'Info' }, | ||
{ path: 'raw', label: 'Raw' }, | ||
] as const | ||
|
||
export default function PersistentVolume(): ReactElement { | ||
return <div>PersistentVolume details</div> | ||
const cluster = useKubernetesCluster() | ||
const { clusterId, name = '' } = useParams() | ||
const { data, loading } = usePersistentVolumeQuery({ | ||
client: KubernetesClient(clusterId ?? ''), | ||
skip: !clusterId, | ||
pollInterval: 30_000, | ||
variables: { | ||
name, | ||
} as ConfigMapQueryVariables, | ||
}) | ||
|
||
const pv = data?.handleGetPersistentVolumeDetail | ||
|
||
useSetBreadcrumbs( | ||
useMemo( | ||
() => [ | ||
...getBreadcrumbs(cluster), | ||
{ | ||
label: name ?? '', | ||
url: getResourceDetailsAbsPath(clusterId, 'persistentvolume', name), | ||
}, | ||
], | ||
[cluster, clusterId, name] | ||
) | ||
) | ||
|
||
if (loading) return <LoadingIndicator /> | ||
|
||
return ( | ||
<ResourceDetails | ||
tabs={directory} | ||
sidecar={<MetadataSidecar objectMeta={pv?.objectMeta} />} | ||
> | ||
<Outlet context={pv} /> | ||
</ResourceDetails> | ||
) | ||
} | ||
|
||
export function PersistentVolumeInfo(): ReactElement { | ||
const pv = useOutletContext() as PersistentVolumeT | ||
|
||
return ( | ||
<section> | ||
<SubTitle>Info</SubTitle> | ||
{pv.status} | ||
</section> | ||
) | ||
} | ||
|
||
export function PersistentVolumeRaw(): ReactElement { | ||
return <>raw</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters