-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
9 changed files
with
369 additions
and
4 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
73 changes: 73 additions & 0 deletions
73
assets/src/components/kubernetes/access/ServiceAccount.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { ReactElement, useMemo } from 'react' | ||
import { Outlet, useParams } from 'react-router-dom' | ||
import { useSetBreadcrumbs } from '@pluralsh/design-system' | ||
|
||
import { MetadataSidecar, useKubernetesCluster } from '../utils' | ||
import { | ||
ServiceAccountQueryVariables, | ||
useServiceAccountQuery, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { KubernetesClient } from '../../../helpers/kubernetes.client' | ||
import { | ||
SERVICE_ACCOUNTS_REL_PATH, | ||
getAccessAbsPath, | ||
getResourceDetailsAbsPath, | ||
} from '../../../routes/kubernetesRoutesConsts' | ||
import { NAMESPACE_PARAM } from '../Kubernetes' | ||
import LoadingIndicator from '../../utils/LoadingIndicator' | ||
import ResourceDetails, { TabEntry } from '../ResourceDetails' | ||
|
||
import { getBreadcrumbs } from './ServiceAccounts' | ||
|
||
const directory: Array<TabEntry> = [{ path: 'raw', label: 'Raw' }] as const | ||
|
||
export default function ServiceAccount(): ReactElement { | ||
const cluster = useKubernetesCluster() | ||
const { clusterId, name = '', namespace = '' } = useParams() | ||
const { data, loading } = useServiceAccountQuery({ | ||
client: KubernetesClient(clusterId ?? ''), | ||
skip: !clusterId, | ||
pollInterval: 30_000, | ||
variables: { | ||
name, | ||
namespace, | ||
} as ServiceAccountQueryVariables, | ||
}) | ||
|
||
const serviceAccount = data?.handleGetServiceAccountDetail | ||
|
||
useSetBreadcrumbs( | ||
useMemo( | ||
() => [ | ||
...getBreadcrumbs(cluster), | ||
{ | ||
label: namespace ?? '', | ||
url: `${getAccessAbsPath( | ||
cluster?.id | ||
)}/${SERVICE_ACCOUNTS_REL_PATH}?${NAMESPACE_PARAM}=${namespace}`, | ||
}, | ||
{ | ||
label: name ?? '', | ||
url: getResourceDetailsAbsPath( | ||
clusterId, | ||
'serviceaccount', | ||
name, | ||
namespace | ||
), | ||
}, | ||
], | ||
[cluster, clusterId, name, namespace] | ||
) | ||
) | ||
|
||
if (loading) return <LoadingIndicator /> | ||
|
||
return ( | ||
<ResourceDetails | ||
tabs={directory} | ||
sidecar={<MetadataSidecar resource={serviceAccount} />} | ||
> | ||
<Outlet context={serviceAccount} /> | ||
</ResourceDetails> | ||
) | ||
} |
62 changes: 62 additions & 0 deletions
62
assets/src/components/kubernetes/access/ServiceAccounts.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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { createColumnHelper } from '@tanstack/react-table' | ||
import { useMemo } from 'react' | ||
import { useSetBreadcrumbs } from '@pluralsh/design-system' | ||
|
||
import { | ||
Maybe, | ||
Serviceaccount_ServiceAccountList as ServiceAccountListT, | ||
Serviceaccount_ServiceAccount as ServiceAccountT, | ||
ServiceAccountsQuery, | ||
ServiceAccountsQueryVariables, | ||
useServiceAccountsQuery, | ||
} from '../../../generated/graphql-kubernetes' | ||
import { getBaseBreadcrumbs, useDefaultColumns } from '../utils' | ||
import { ResourceList } from '../ResourceList' | ||
import { ClusterTinyFragment } from '../../../generated/graphql' | ||
import { | ||
SERVICE_ACCOUNTS_REL_PATH, | ||
getAccessAbsPath, | ||
} from '../../../routes/kubernetesRoutesConsts' | ||
import { useKubernetesContext } from '../Kubernetes' | ||
|
||
export const getBreadcrumbs = (cluster?: Maybe<ClusterTinyFragment>) => [ | ||
...getBaseBreadcrumbs(cluster), | ||
{ | ||
label: 'access', | ||
url: getAccessAbsPath(cluster?.id), | ||
}, | ||
{ | ||
label: 'service accounts', | ||
url: `${getAccessAbsPath(cluster?.id)}/${SERVICE_ACCOUNTS_REL_PATH}`, | ||
}, | ||
] | ||
|
||
const columnHelper = createColumnHelper<ServiceAccountT>() | ||
|
||
export default function ServiceAccounts() { | ||
const { cluster } = useKubernetesContext() | ||
|
||
useSetBreadcrumbs(useMemo(() => getBreadcrumbs(cluster), [cluster])) | ||
|
||
const { colName, colNamespace, colLabels, colCreationTimestamp } = | ||
useDefaultColumns(columnHelper) | ||
const columns = useMemo( | ||
() => [colName, colNamespace, colLabels, colCreationTimestamp], | ||
[colName, colNamespace, colLabels, colCreationTimestamp] | ||
) | ||
|
||
return ( | ||
<ResourceList< | ||
ServiceAccountListT, | ||
ServiceAccountT, | ||
ServiceAccountsQuery, | ||
ServiceAccountsQueryVariables | ||
> | ||
namespaced | ||
columns={columns} | ||
query={useServiceAccountsQuery} | ||
queryName="handleGetServiceAccountList" | ||
itemsKey="items" | ||
/> | ||
) | ||
} |
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
Oops, something went wrong.