-
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
f0afbfd
commit 722a9eb
Showing
6 changed files
with
433 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,106 @@ | ||
import { ReactElement } from 'react' | ||
import { ReactElement, useMemo } from 'react' | ||
import { SidecarItem, useSetBreadcrumbs } from '@pluralsh/design-system' | ||
import { Outlet, useOutletContext, useParams } from 'react-router-dom' | ||
|
||
import { | ||
Common_EventList as EventListT, | ||
Common_Event as EventT, | ||
NamespaceEventsQuery, | ||
NamespaceEventsQueryVariables, | ||
NamespaceQueryVariables, | ||
Namespace_Namespace as NamespaceT, | ||
useNamespaceEventsQuery, | ||
useNamespaceQuery, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { KubernetesClient } from '../../../helpers/kubernetes.client' | ||
import LoadingIndicator from '../../utils/LoadingIndicator' | ||
import { MetadataSidecar, useKubernetesCluster } from '../utils' | ||
import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' | ||
|
||
import ResourceDetails, { TabEntry } from '../ResourceDetails' | ||
|
||
import { ResourceList } from '../ResourceList' | ||
|
||
import { getBreadcrumbs } from './Namespaces' | ||
import { NamespacePhaseChip } from './utils' | ||
import { COLUMNS } from './Events' | ||
|
||
const directory: Array<TabEntry> = [ | ||
{ path: '', label: 'Info' }, | ||
{ path: 'events', label: 'Events' }, | ||
{ path: 'raw', label: 'Raw' }, | ||
] as const | ||
|
||
export default function Namespace(): ReactElement { | ||
return <div>Namespace details</div> | ||
const cluster = useKubernetesCluster() | ||
const { clusterId, name = '' } = useParams() | ||
const { data, loading } = useNamespaceQuery({ | ||
client: KubernetesClient(clusterId ?? ''), | ||
skip: !clusterId, | ||
pollInterval: 30_000, | ||
variables: { | ||
name, | ||
} as NamespaceQueryVariables, | ||
}) | ||
|
||
const namespace = data?.handleGetNamespaceDetail | ||
|
||
useSetBreadcrumbs( | ||
useMemo( | ||
() => [ | ||
...getBreadcrumbs(cluster), | ||
{ | ||
label: name ?? '', | ||
url: getResourceDetailsAbsPath(clusterId, 'namespace', name), | ||
}, | ||
], | ||
[cluster, clusterId, name] | ||
) | ||
) | ||
|
||
if (loading) return <LoadingIndicator /> | ||
|
||
return ( | ||
<ResourceDetails | ||
tabs={directory} | ||
sidecar={ | ||
<MetadataSidecar resource={namespace}> | ||
<SidecarItem heading="Phase"> | ||
<NamespacePhaseChip phase={namespace?.phase} /> | ||
</SidecarItem> | ||
</MetadataSidecar> | ||
} | ||
> | ||
<Outlet context={namespace} /> | ||
</ResourceDetails> | ||
) | ||
} | ||
|
||
export function NamespaceInfo(): ReactElement { | ||
const namespace = useOutletContext() as NamespaceT | ||
|
||
return <section>TODO</section> | ||
} | ||
|
||
export function NamespaceEvents(): ReactElement { | ||
const { name } = useParams() | ||
|
||
return ( | ||
<ResourceList< | ||
EventListT, | ||
EventT, | ||
NamespaceEventsQuery, | ||
NamespaceEventsQueryVariables | ||
> | ||
namespaced | ||
columns={COLUMNS} | ||
query={useNamespaceEventsQuery} | ||
queryOptions={{ | ||
variables: { name } as NamespaceEventsQueryVariables, | ||
}} | ||
queryName="handleGetNamespaceEvents" | ||
itemsKey="events" | ||
disableOnRowClick | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.