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';
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 { namespace } from './namespace';
import { created } from './created';
export function useColumns() {
return [name, namespace, created];
export function useColumns(namespaces?: PortainerNamespace[]) {
return [name(namespaces), namespace, created];
}

View File

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

View File

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