diff --git a/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/created.tsx b/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/created.tsx index 02ec353d0..200cc8885 100644 --- a/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/created.tsx +++ b/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/created.tsx @@ -1,6 +1,8 @@ import { formatDate } from '@/portainer/filters/filters'; +import { appOwnerLabel } from '@/react/kubernetes/applications/constants'; import { ConfigMapRowData } from '../types'; +import { configurationOwnerUsernameLabel } from '../../../constants'; import { columnHelper } from './helper'; @@ -12,7 +14,8 @@ export const created = columnHelper.accessor((row) => getCreatedAtText(row), { function getCreatedAtText(row: ConfigMapRowData) { const owner = - row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner']; + row.metadata?.labels?.[configurationOwnerUsernameLabel] || + row.metadata?.labels?.[appOwnerLabel]; const date = formatDate(row.metadata?.creationTimestamp); return owner ? `${date} by ${owner}` : date; } diff --git a/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/name.tsx b/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/name.tsx index 88d707343..183548043 100644 --- a/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/name.tsx +++ b/app/react/kubernetes/configs/ListView/ConfigMapsDatatable/columns/name.tsx @@ -1,11 +1,13 @@ import { CellContext } from '@tanstack/react-table'; import { Authorized } from '@/react/hooks/useUser'; +import { appOwnerLabel } from '@/react/kubernetes/applications/constants'; import { Link } from '@@/Link'; import { Badge } from '@@/Badge'; import { ConfigMapRowData } from '../types'; +import { configurationOwnerUsernameLabel } from '../../../constants'; import { columnHelper } from './helper'; @@ -16,8 +18,11 @@ export const name = columnHelper.accessor( const isSystemToken = name?.includes('default-token-'); const isSystemConfigMap = isSystemToken || row.isSystem; - const hasConfigurationOwner = - !!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner']; + const hasConfigurationOwner = !!( + row.metadata?.labels?.[configurationOwnerUsernameLabel] || + row.metadata?.labels?.[appOwnerLabel] + ); + return `${name} ${isSystemConfigMap ? 'system' : ''} ${ !isSystemToken && !hasConfigurationOwner ? 'external' : '' } ${!row.inUse && !isSystemConfigMap ? 'unused' : ''}`; diff --git a/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/created.tsx b/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/created.tsx index df27985b9..729d1c9c9 100644 --- a/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/created.tsx +++ b/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/created.tsx @@ -1,6 +1,8 @@ import { formatDate } from '@/portainer/filters/filters'; +import { appOwnerLabel } from '@/react/kubernetes/applications/constants'; import { SecretRowData } from '../types'; +import { configurationOwnerUsernameLabel } from '../../../constants'; import { columnHelper } from './helper'; @@ -12,7 +14,8 @@ export const created = columnHelper.accessor((row) => getCreatedAtText(row), { function getCreatedAtText(row: SecretRowData) { const owner = - row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner']; + row.metadata?.labels?.[configurationOwnerUsernameLabel] || + row.metadata?.labels?.[appOwnerLabel]; const date = formatDate(row.metadata?.creationTimestamp); return owner ? `${date} by ${owner}` : date; } diff --git a/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/name.tsx b/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/name.tsx index ae11acddb..d4617ab81 100644 --- a/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/name.tsx +++ b/app/react/kubernetes/configs/ListView/SecretsDatatable/columns/name.tsx @@ -1,11 +1,13 @@ import { CellContext } from '@tanstack/react-table'; import { Authorized } from '@/react/hooks/useUser'; +import { appOwnerLabel } from '@/react/kubernetes/applications/constants'; import { Link } from '@@/Link'; import { Badge } from '@@/Badge'; import { SecretRowData } from '../types'; +import { configurationOwnerUsernameLabel } from '../../../constants'; import { columnHelper } from './helper'; @@ -18,8 +20,10 @@ export const name = columnHelper.accessor( row.metadata?.annotations?.['portainer.io/registry.id']; const isSystemSecret = isSystemToken || row.isSystem || isRegistrySecret; - const hasConfigurationOwner = - !!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner']; + const hasConfigurationOwner = !!( + row.metadata?.labels?.[configurationOwnerUsernameLabel] || + row.metadata?.labels?.[appOwnerLabel] + ); return `${name} ${isSystemSecret ? 'system' : ''} ${ !isSystemToken && !hasConfigurationOwner ? 'external' : '' } ${!row.inUse && !isSystemSecret ? 'unused' : ''}`; diff --git a/app/react/kubernetes/configs/constants.ts b/app/react/kubernetes/configs/constants.ts new file mode 100644 index 000000000..a444ddf74 --- /dev/null +++ b/app/react/kubernetes/configs/constants.ts @@ -0,0 +1,2 @@ +export const configurationOwnerUsernameLabel = + 'io.portainer.kubernetes.configuration.owner'; diff --git a/app/react/kubernetes/ingresses/IngressDatatable/columns/created.tsx b/app/react/kubernetes/ingresses/IngressDatatable/columns/created.tsx index e9d88c4a6..b64af9f84 100644 --- a/app/react/kubernetes/ingresses/IngressDatatable/columns/created.tsx +++ b/app/react/kubernetes/ingresses/IngressDatatable/columns/created.tsx @@ -1,4 +1,5 @@ import { formatDate } from '@/portainer/filters/filters'; +import { appOwnerLabel } from '@/react/kubernetes/applications/constants'; import { columnHelper } from './helper'; @@ -13,7 +14,8 @@ export const created = columnHelper.accessor( cell: ({ row, getValue }) => { const date = formatDate(getValue()); const owner = - row.original.Labels?.['io.portainer.kubernetes.ingress.owner']; + row.original.Labels?.['io.portainer.kubernetes.ingress.owner'] || + row.original.Labels?.[appOwnerLabel]; return owner ? `${date} by ${owner}` : date; },