-
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
019abc1
commit bd886a6
Showing
5 changed files
with
195 additions
and
8 deletions.
There are no files selected for viewing
95 changes: 93 additions & 2 deletions
95
assets/src/components/kubernetes/access/ClusterRoleBinding.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,96 @@ | ||
import { ReactElement } from 'react' | ||
import { ReactElement, useMemo } from 'react' | ||
|
||
import { Link, Outlet, useOutletContext, useParams } from 'react-router-dom' | ||
|
||
import { SidecarItem, useSetBreadcrumbs } from '@pluralsh/design-system' | ||
|
||
import { A } from 'honorable' | ||
|
||
import ResourceDetails, { TabEntry } from '../ResourceDetails' | ||
import { MetadataSidecar, useKubernetesCluster } from '../utils' | ||
import { | ||
ClusterRoleBindingQueryVariables, | ||
Clusterrolebinding_ClusterRoleBindingDetail as ClusterRoleBindingT, | ||
useClusterRoleBindingQuery, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { KubernetesClient } from '../../../helpers/kubernetes.client' | ||
|
||
import { getResourceDetailsAbsPath } from '../../../routes/kubernetesRoutesConsts' | ||
|
||
import LoadingIndicator from '../../utils/LoadingIndicator' | ||
|
||
import { FullHeightTableWrap } from '../../utils/layout/FullHeightTableWrap' | ||
import Subjects from '../common/Subjects' | ||
|
||
import { getBreadcrumbs } from './ClusterRoleBindings' | ||
|
||
const directory: Array<TabEntry> = [ | ||
{ path: '', label: 'Subjects' }, | ||
{ path: 'raw', label: 'Raw' }, | ||
] as const | ||
|
||
export default function ClusterRoleBinding(): ReactElement { | ||
return <div>ClusterRoleBinding details</div> | ||
const cluster = useKubernetesCluster() | ||
const { clusterId, name = '' } = useParams() | ||
const { data, loading } = useClusterRoleBindingQuery({ | ||
client: KubernetesClient(clusterId ?? ''), | ||
skip: !clusterId, | ||
pollInterval: 30_000, | ||
variables: { | ||
name, | ||
} as ClusterRoleBindingQueryVariables, | ||
}) | ||
|
||
const crb = data?.handleGetClusterRoleBindingDetail | ||
|
||
useSetBreadcrumbs( | ||
useMemo( | ||
() => [ | ||
...getBreadcrumbs(cluster), | ||
{ | ||
label: name ?? '', | ||
url: getResourceDetailsAbsPath(clusterId, 'clusterrolebinding', name), | ||
}, | ||
], | ||
[cluster, clusterId, name] | ||
) | ||
) | ||
|
||
if (loading) return <LoadingIndicator /> | ||
|
||
return ( | ||
<ResourceDetails | ||
tabs={directory} | ||
sidecar={ | ||
<MetadataSidecar objectMeta={crb?.objectMeta}> | ||
<SidecarItem heading="Role"> | ||
<A | ||
as={Link} | ||
to={getResourceDetailsAbsPath( | ||
clusterId, | ||
'clusterrole', | ||
crb?.roleRef.name ?? '' | ||
)} | ||
inline | ||
> | ||
{crb?.roleRef.name} | ||
</A> | ||
</SidecarItem> | ||
</MetadataSidecar> | ||
} | ||
> | ||
<Outlet context={crb} /> | ||
</ResourceDetails> | ||
) | ||
} | ||
|
||
// TODO: Add links. | ||
export function ClusterRoleBindingSubjects(): ReactElement { | ||
const crb = useOutletContext() as ClusterRoleBindingT | ||
|
||
return ( | ||
<FullHeightTableWrap> | ||
<Subjects subjects={crb?.subjects} /> | ||
</FullHeightTableWrap> | ||
) | ||
} |
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