mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
fix(ui): mark resources system correctly [EE-6558] (#10996)
* fix(ui): mark resources system correctly [EE-6558] * address review comments
This commit is contained in:
parent
85ae705833
commit
f7840e0407
17 changed files with 110 additions and 75 deletions
|
@ -6,12 +6,12 @@ import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
|||
import { Authorized, useAuthorizations } from '@/react/hooks/useUser';
|
||||
import { DefaultDatatableSettings } from '@/react/kubernetes/datatables/DefaultDatatableSettings';
|
||||
import { createStore } from '@/react/kubernetes/datatables/default-kube-datatable-store';
|
||||
import { isSystemNamespace } from '@/react/kubernetes/namespaces/utils';
|
||||
import { SystemResourceDescription } from '@/react/kubernetes/datatables/SystemResourceDescription';
|
||||
import { useApplicationsQuery } from '@/react/kubernetes/applications/application.queries';
|
||||
import { Application } from '@/react/kubernetes/applications/types';
|
||||
import { pluralize } from '@/portainer/helpers/strings';
|
||||
import { useNamespacesQuery } from '@/react/kubernetes/namespaces/queries/useNamespacesQuery';
|
||||
import { Namespaces } from '@/react/kubernetes/namespaces/types';
|
||||
|
||||
import { Datatable, TableSettingsMenu } from '@@/datatables';
|
||||
import { confirmDelete } from '@@/modals/confirm';
|
||||
|
@ -64,14 +64,15 @@ export function SecretsDatatable() {
|
|||
secrets?.filter(
|
||||
(secret) =>
|
||||
(canAccessSystemResources && tableState.showSystemResources) ||
|
||||
!isSystemNamespace(secret.metadata?.namespace ?? '')
|
||||
!namespaces?.[secret.metadata?.namespace ?? '']?.IsSystem
|
||||
) || [],
|
||||
[secrets, tableState, canAccessSystemResources]
|
||||
[secrets, tableState, canAccessSystemResources, namespaces]
|
||||
);
|
||||
const secretRowData = useSecretRowData(
|
||||
filteredSecrets,
|
||||
applications ?? [],
|
||||
applicationsQuery.isLoading
|
||||
applicationsQuery.isLoading,
|
||||
namespaces
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -85,7 +86,7 @@ export function SecretsDatatable() {
|
|||
titleIcon={Lock}
|
||||
getRowId={(row) => row.metadata?.uid ?? ''}
|
||||
isRowSelectable={(row) =>
|
||||
!isSystemNamespace(row.original.metadata?.namespace ?? '')
|
||||
!namespaces?.[row.original.metadata?.namespace ?? '']?.IsSystem
|
||||
}
|
||||
disableSelect={readOnly}
|
||||
renderTableActions={(selectedRows) => (
|
||||
|
@ -110,7 +111,8 @@ export function SecretsDatatable() {
|
|||
function useSecretRowData(
|
||||
secrets: Secret[],
|
||||
applications: Application[],
|
||||
applicationsLoading: boolean
|
||||
applicationsLoading: boolean,
|
||||
namespaces?: Namespaces
|
||||
): SecretRowData[] {
|
||||
return useMemo(
|
||||
() =>
|
||||
|
@ -119,8 +121,11 @@ function useSecretRowData(
|
|||
inUse:
|
||||
// if the apps are loading, set inUse to true to hide the 'unused' badge
|
||||
applicationsLoading || getIsSecretInUse(secret, applications),
|
||||
isSystem: namespaces
|
||||
? namespaces?.[secret.metadata?.namespace ?? '']?.IsSystem
|
||||
: false,
|
||||
})),
|
||||
[secrets, applicationsLoading, applications]
|
||||
[secrets, applicationsLoading, applications, namespaces]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import { isSystemNamespace } from '@/react/kubernetes/namespaces/utils';
|
||||
import { Authorized } from '@/react/hooks/useUser';
|
||||
|
||||
import { Link } from '@@/Link';
|
||||
|
@ -13,16 +12,11 @@ import { columnHelper } from './helper';
|
|||
export const name = columnHelper.accessor(
|
||||
(row) => {
|
||||
const name = row.metadata?.name;
|
||||
const namespace = row.metadata?.namespace;
|
||||
|
||||
const isSystemToken = name?.includes('default-token-');
|
||||
const isInSystemNamespace = namespace
|
||||
? isSystemNamespace(namespace)
|
||||
: false;
|
||||
|
||||
const isRegistrySecret =
|
||||
row.metadata?.annotations?.['portainer.io/registry.id'];
|
||||
const isSystemSecret =
|
||||
isSystemToken || isInSystemNamespace || isRegistrySecret;
|
||||
const isSystemSecret = isSystemToken || row.isSystem || isRegistrySecret;
|
||||
|
||||
const hasConfigurationOwner =
|
||||
!!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
||||
|
@ -39,11 +33,9 @@ export const name = columnHelper.accessor(
|
|||
|
||||
function Cell({ row }: CellContext<SecretRowData, string>) {
|
||||
const name = row.original.metadata?.name;
|
||||
const namespace = row.original.metadata?.namespace;
|
||||
|
||||
const isSystemToken = name?.includes('default-token-');
|
||||
const isInSystemNamespace = namespace ? isSystemNamespace(namespace) : false;
|
||||
const isSystemSecret = isSystemToken || isInSystemNamespace;
|
||||
const isSystemSecret = isSystemToken || row.original.isSystem;
|
||||
|
||||
const hasConfigurationOwner =
|
||||
!!row.original.metadata?.labels?.[
|
||||
|
|
|
@ -2,4 +2,5 @@ import { Secret } from 'kubernetes-types/core/v1';
|
|||
|
||||
export interface SecretRowData extends Secret {
|
||||
inUse: boolean;
|
||||
isSystem: boolean;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue