2023-03-03 08:45:19 +13:00
|
|
|
import { Authorized } from '@/react/hooks/useUser';
|
2023-05-11 12:55:15 +12:00
|
|
|
import { isSystemNamespace } from '@/react/kubernetes/namespaces/utils';
|
2023-03-03 08:45:19 +13:00
|
|
|
|
2023-05-02 13:42:16 +07:00
|
|
|
import { columnHelper } from './helper';
|
2023-03-03 08:45:19 +13:00
|
|
|
|
2023-05-11 12:55:15 +12:00
|
|
|
export const name = columnHelper.accessor(
|
|
|
|
(row) => {
|
|
|
|
let name = row.Name;
|
2023-03-03 08:45:19 +13:00
|
|
|
|
|
|
|
const isExternal =
|
2023-05-11 12:55:15 +12:00
|
|
|
!row.Labels || !row.Labels['io.portainer.kubernetes.application.owner'];
|
|
|
|
const isSystem = isSystemNamespace(row.Namespace);
|
|
|
|
|
|
|
|
if (isExternal && !isSystem) {
|
|
|
|
name = `${name} external`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSystem) {
|
|
|
|
name = `${name} system`;
|
|
|
|
}
|
|
|
|
return name;
|
2023-03-03 08:45:19 +13:00
|
|
|
},
|
2023-05-11 12:55:15 +12:00
|
|
|
{
|
|
|
|
header: 'Name',
|
2023-06-12 09:46:48 +12:00
|
|
|
id: 'name',
|
2023-05-11 12:55:15 +12:00
|
|
|
cell: ({ row }) => {
|
|
|
|
const name = row.original.Name;
|
|
|
|
const isSystem = isSystemNamespace(row.original.Namespace);
|
|
|
|
|
|
|
|
const isExternal =
|
|
|
|
!row.original.Labels ||
|
|
|
|
!row.original.Labels['io.portainer.kubernetes.application.owner'];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Authorized authorizations="K8sServiceW" childrenUnauthorized={name}>
|
|
|
|
{name}
|
|
|
|
|
|
|
|
{isSystem && (
|
|
|
|
<span className="label label-info image-tag label-margins">
|
|
|
|
system
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{isExternal && !isSystem && (
|
|
|
|
<span className="label label-primary image-tag label-margins">
|
|
|
|
external
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</Authorized>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|