1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

fix(ingress): handle system resources [EE-4775] (#9972)

* fix(ingress): handle system resources [EE-4775]
This commit is contained in:
Ali 2023-08-23 09:13:35 +12:00 committed by GitHub
parent 5586910e9d
commit 1e61f7e305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 105 additions and 60 deletions

View file

@ -3,11 +3,7 @@ import { FileCode, Plus, Trash2 } from 'lucide-react';
import { ConfigMap } from 'kubernetes-types/core/v1';
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import {
Authorized,
useAuthorizations,
useCurrentUser,
} from '@/react/hooks/useUser';
import { Authorized, useAuthorizations } from '@/react/hooks/useUser';
import { useNamespaces } from '@/react/kubernetes/namespaces/queries';
import { DefaultDatatableSettings } from '@/react/kubernetes/datatables/DefaultDatatableSettings';
import { createStore } from '@/react/kubernetes/datatables/default-kube-datatable-store';
@ -39,7 +35,9 @@ const settingsStore = createStore(storageKey);
export function ConfigMapsDatatable() {
const tableState = useTableState(settingsStore, storageKey);
const readOnly = !useAuthorizations(['K8sConfigMapsW']);
const { isAdmin } = useCurrentUser();
const canAccessSystemResources = useAuthorizations(
'K8sAccessSystemNamespaces'
);
const environmentId = useEnvironmentId();
const { data: namespaces, ...namespacesQuery } = useNamespaces(
@ -63,10 +61,10 @@ export function ConfigMapsDatatable() {
() =>
configMaps?.filter(
(configMap) =>
(isAdmin && tableState.showSystemResources) ||
(canAccessSystemResources && tableState.showSystemResources) ||
!isSystemNamespace(configMap.metadata?.namespace ?? '')
) || [],
[configMaps, tableState, isAdmin]
[configMaps, tableState, canAccessSystemResources]
);
const configMapRowData = useConfigMapRowData(
filteredConfigMaps,
@ -95,13 +93,15 @@ export function ConfigMapsDatatable() {
<TableSettingsMenu>
<DefaultDatatableSettings
settings={tableState}
hideShowSystemResources={!isAdmin}
hideShowSystemResources={!canAccessSystemResources}
/>
</TableSettingsMenu>
)}
description={
<SystemResourceDescription
showSystemResources={tableState.showSystemResources || !isAdmin}
showSystemResources={
tableState.showSystemResources || !canAccessSystemResources
}
/>
}
/>