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:
parent
5586910e9d
commit
1e61f7e305
9 changed files with 105 additions and 60 deletions
|
@ -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
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -3,11 +3,7 @@ import { Lock, Plus, Trash2 } from 'lucide-react';
|
|||
import { Secret } 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 SecretsDatatable() {
|
||||
const tableState = useTableState(settingsStore, storageKey);
|
||||
const readOnly = !useAuthorizations(['K8sSecretsW']);
|
||||
const { isAdmin } = useCurrentUser();
|
||||
const canAccessSystemResources = useAuthorizations(
|
||||
'K8sAccessSystemNamespaces'
|
||||
);
|
||||
|
||||
const environmentId = useEnvironmentId();
|
||||
const { data: namespaces, ...namespacesQuery } = useNamespaces(
|
||||
|
@ -63,10 +61,10 @@ export function SecretsDatatable() {
|
|||
() =>
|
||||
secrets?.filter(
|
||||
(secret) =>
|
||||
(isAdmin && tableState.showSystemResources) ||
|
||||
(canAccessSystemResources && tableState.showSystemResources) ||
|
||||
!isSystemNamespace(secret.metadata?.namespace ?? '')
|
||||
) || [],
|
||||
[secrets, tableState, isAdmin]
|
||||
[secrets, tableState, canAccessSystemResources]
|
||||
);
|
||||
const secretRowData = useSecretRowData(
|
||||
filteredSecrets,
|
||||
|
@ -95,13 +93,15 @@ export function SecretsDatatable() {
|
|||
<TableSettingsMenu>
|
||||
<DefaultDatatableSettings
|
||||
settings={tableState}
|
||||
hideShowSystemResources={!isAdmin}
|
||||
hideShowSystemResources={!canAccessSystemResources}
|
||||
/>
|
||||
</TableSettingsMenu>
|
||||
)}
|
||||
description={
|
||||
<SystemResourceDescription
|
||||
showSystemResources={tableState.showSystemResources || !isAdmin}
|
||||
showSystemResources={
|
||||
tableState.showSystemResources || !canAccessSystemResources
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue