2023-03-02 19:45:19 +00:00
|
|
|
import { Authorized } from '@/react/hooks/useUser';
|
|
|
|
|
2023-10-12 14:10:16 +00:00
|
|
|
import { Badge } from '@@/Badge';
|
|
|
|
|
2023-05-02 06:42:16 +00:00
|
|
|
import { columnHelper } from './helper';
|
2023-03-02 19:45:19 +00:00
|
|
|
|
2023-05-11 00:55:15 +00:00
|
|
|
export const name = columnHelper.accessor(
|
|
|
|
(row) => {
|
|
|
|
let name = row.Name;
|
2023-03-02 19:45:19 +00:00
|
|
|
|
|
|
|
const isExternal =
|
2023-05-11 00:55:15 +00:00
|
|
|
!row.Labels || !row.Labels['io.portainer.kubernetes.application.owner'];
|
|
|
|
|
2024-01-23 00:49:25 +00:00
|
|
|
if (isExternal && !row.IsSystem) {
|
2023-05-11 00:55:15 +00:00
|
|
|
name = `${name} external`;
|
|
|
|
}
|
|
|
|
|
2024-01-23 00:49:25 +00:00
|
|
|
if (row.IsSystem) {
|
2023-05-11 00:55:15 +00:00
|
|
|
name = `${name} system`;
|
|
|
|
}
|
|
|
|
return name;
|
2023-03-02 19:45:19 +00:00
|
|
|
},
|
2023-05-11 00:55:15 +00:00
|
|
|
{
|
|
|
|
header: 'Name',
|
2023-06-11 21:46:48 +00:00
|
|
|
id: 'name',
|
2023-05-11 00:55:15 +00:00
|
|
|
cell: ({ row }) => {
|
|
|
|
const name = row.original.Name;
|
|
|
|
|
|
|
|
const isExternal =
|
|
|
|
!row.original.Labels ||
|
|
|
|
!row.original.Labels['io.portainer.kubernetes.application.owner'];
|
|
|
|
|
|
|
|
return (
|
2023-10-12 14:10:16 +00:00
|
|
|
<div className="flex">
|
|
|
|
<Authorized authorizations="K8sServiceW" childrenUnauthorized={name}>
|
|
|
|
{name}
|
|
|
|
|
2024-01-23 00:49:25 +00:00
|
|
|
{row.original.IsSystem && (
|
2023-10-12 14:10:16 +00:00
|
|
|
<Badge type="success" className="ml-2">
|
|
|
|
System
|
|
|
|
</Badge>
|
|
|
|
)}
|
|
|
|
|
2024-01-23 00:49:25 +00:00
|
|
|
{isExternal && !row.original.IsSystem && (
|
2023-10-12 14:10:16 +00:00
|
|
|
<Badge className="ml-2">External</Badge>
|
|
|
|
)}
|
|
|
|
</Authorized>
|
|
|
|
</div>
|
2023-05-11 00:55:15 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|