update service account type and isSystem check for new api endpoint

pull/12297/head
testA113 2024-10-04 14:46:01 +13:00
parent 49e5fb286a
commit 609c30e8b8
4 changed files with 30 additions and 31 deletions

View File

@ -1,5 +1,5 @@
import { Badge } from '@@/Badge'; import { Badge } from '@@/Badge';
export function SystemBadge() { export function SystemBadge() {
return <Badge type="success">system</Badge>; return <Badge type="success">System</Badge>;
} }

View File

@ -1,7 +1,9 @@
import { PortainerNamespace } from '@/react/kubernetes/namespaces/types';
import { name } from './name'; import { name } from './name';
import { namespace } from './namespace'; import { namespace } from './namespace';
import { created } from './created'; import { created } from './created';
export function useColumns() { export function useColumns(namespaces?: PortainerNamespace[]) {
return [name, namespace, created]; return [name(namespaces), namespace, created];
} }

View File

@ -1,17 +1,17 @@
import { isSystemNamespace } from '@/react/kubernetes/namespaces/queries/useIsSystemNamespace';
import { PortainerNamespace } from '@/react/kubernetes/namespaces/types';
import { SystemBadge } from '@@/Badge/SystemBadge'; import { SystemBadge } from '@@/Badge/SystemBadge';
import { UnusedBadge } from '@@/Badge/UnusedBadge';
import { columnHelper } from './helper'; import { columnHelper } from './helper';
export const name = columnHelper.accessor( export function name(namespaces?: PortainerNamespace[]) {
return columnHelper.accessor(
(row) => { (row) => {
let result = row.name; let result = row.name;
if (row.isSystem) { if (isSystemNamespace(row.namespace, namespaces)) {
result += ' system'; result += ' system';
} }
if (row.isUnused) {
result += ' unused';
}
return result; return result;
}, },
{ {
@ -20,9 +20,11 @@ export const name = columnHelper.accessor(
cell: ({ row }) => ( cell: ({ row }) => (
<div className="flex gap-2"> <div className="flex gap-2">
<div>{row.original.name}</div> <div>{row.original.name}</div>
{row.original.isSystem && <SystemBadge />} {isSystemNamespace(row.original.namespace, namespaces) && (
{!row.original.isSystem && row.original.isUnused && <UnusedBadge />} <SystemBadge />
)}
</div> </div>
), ),
} }
); );
}

View File

@ -1,10 +1,5 @@
export type ServiceAccount = { export type ServiceAccount = {
name: string; name: string;
namespace: string; namespace: string;
resourceVersion: string;
uid: string;
creationDate: string; creationDate: string;
isSystem: boolean;
isUnused: boolean;
}; };