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 ConfigMapsDatatable() {
|
|||
configMaps?.filter(
|
||||
(configMap) =>
|
||||
(canAccessSystemResources && tableState.showSystemResources) ||
|
||||
!isSystemNamespace(configMap.metadata?.namespace ?? '')
|
||||
!namespaces?.[configMap.metadata?.namespace ?? '']?.IsSystem
|
||||
) || [],
|
||||
[configMaps, tableState, canAccessSystemResources]
|
||||
[configMaps, tableState, canAccessSystemResources, namespaces]
|
||||
);
|
||||
const configMapRowData = useConfigMapRowData(
|
||||
filteredConfigMaps,
|
||||
applications ?? [],
|
||||
applicationsQuery.isLoading
|
||||
applicationsQuery.isLoading,
|
||||
namespaces
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -85,7 +86,7 @@ export function ConfigMapsDatatable() {
|
|||
titleIcon={FileCode}
|
||||
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 ConfigMapsDatatable() {
|
|||
function useConfigMapRowData(
|
||||
configMaps: ConfigMap[],
|
||||
applications: Application[],
|
||||
applicationsLoading: boolean
|
||||
applicationsLoading: boolean,
|
||||
namespaces?: Namespaces
|
||||
): ConfigMapRowData[] {
|
||||
return useMemo(
|
||||
() =>
|
||||
|
@ -119,8 +121,11 @@ function useConfigMapRowData(
|
|||
inUse:
|
||||
// if the apps are loading, set inUse to true to hide the 'unused' badge
|
||||
applicationsLoading || getIsConfigMapInUse(configMap, applications),
|
||||
isSystem: namespaces
|
||||
? namespaces?.[configMap.metadata?.namespace ?? '']?.IsSystem
|
||||
: false,
|
||||
})),
|
||||
[configMaps, applicationsLoading, applications]
|
||||
[configMaps, 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,13 +12,9 @@ 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 isSystemConfigMap = isSystemToken || isInSystemNamespace;
|
||||
const isSystemConfigMap = isSystemToken || row.isSystem;
|
||||
|
||||
const hasConfigurationOwner =
|
||||
!!row.metadata?.labels?.['io.portainer.kubernetes.configuration.owner'];
|
||||
|
@ -36,11 +31,9 @@ export const name = columnHelper.accessor(
|
|||
|
||||
function Cell({ row }: CellContext<ConfigMapRowData, 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 isSystemConfigMap = isSystemToken || isInSystemNamespace;
|
||||
const isSystemConfigMap = isSystemToken || row.original.isSystem;
|
||||
|
||||
const hasConfigurationOwner =
|
||||
!!row.original.metadata?.labels?.[
|
||||
|
|
|
@ -2,4 +2,5 @@ import { ConfigMap } from 'kubernetes-types/core/v1';
|
|||
|
||||
export interface ConfigMapRowData extends ConfigMap {
|
||||
inUse: boolean;
|
||||
isSystem: boolean;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue