mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +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
|
@ -1,14 +1,15 @@
|
|||
import { useMemo } from 'react';
|
||||
import { Shuffle, Trash2 } from 'lucide-react';
|
||||
import { useRouter } from '@uirouter/react';
|
||||
import clsx from 'clsx';
|
||||
import { Row } from '@tanstack/react-table';
|
||||
|
||||
import { Namespaces } from '@/react/kubernetes/namespaces/types';
|
||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||
import { Authorized, useAuthorizations } from '@/react/hooks/useUser';
|
||||
import { notifyError, notifySuccess } from '@/portainer/services/notifications';
|
||||
import { pluralize } from '@/portainer/helpers/strings';
|
||||
import { DefaultDatatableSettings } from '@/react/kubernetes/datatables/DefaultDatatableSettings';
|
||||
import { isSystemNamespace } from '@/react/kubernetes/namespaces/utils';
|
||||
import { SystemResourceDescription } from '@/react/kubernetes/datatables/SystemResourceDescription';
|
||||
import { useNamespacesQuery } from '@/react/kubernetes/namespaces/queries/useNamespacesQuery';
|
||||
|
||||
|
@ -52,12 +53,17 @@ export function ServicesDatatable() {
|
|||
const filteredServices = services?.filter(
|
||||
(service) =>
|
||||
(canAccessSystemResources && tableState.showSystemResources) ||
|
||||
!isSystemNamespace(service.Namespace)
|
||||
!namespaces?.[service.Namespace].IsSystem
|
||||
);
|
||||
|
||||
const servicesWithIsSystem = useServicesRowData(
|
||||
filteredServices || [],
|
||||
namespaces
|
||||
);
|
||||
|
||||
return (
|
||||
<Datatable
|
||||
dataset={filteredServices || []}
|
||||
dataset={servicesWithIsSystem || []}
|
||||
columns={columns}
|
||||
settingsManager={tableState}
|
||||
isLoading={servicesQuery.isLoading || namespacesQuery.isLoading}
|
||||
|
@ -65,7 +71,7 @@ export function ServicesDatatable() {
|
|||
title="Services"
|
||||
titleIcon={Shuffle}
|
||||
getRowId={(row) => row.UID}
|
||||
isRowSelectable={(row) => !isSystemNamespace(row.original.Namespace)}
|
||||
isRowSelectable={(row) => !namespaces?.[row.original.Namespace].IsSystem}
|
||||
disableSelect={readOnly}
|
||||
renderTableActions={(selectedRows) => (
|
||||
<TableActions selectedItems={selectedRows} />
|
||||
|
@ -87,6 +93,21 @@ export function ServicesDatatable() {
|
|||
);
|
||||
}
|
||||
|
||||
// useServicesRowData appends the `isSyetem` property to the service data
|
||||
function useServicesRowData(
|
||||
services: Service[],
|
||||
namespaces?: Namespaces
|
||||
): Service[] {
|
||||
return useMemo(
|
||||
() =>
|
||||
services.map((service) => ({
|
||||
...service,
|
||||
IsSystem: namespaces ? namespaces?.[service.Namespace].IsSystem : false,
|
||||
})),
|
||||
[services, namespaces]
|
||||
);
|
||||
}
|
||||
|
||||
// needed to apply custom styling to the row cells and not globally.
|
||||
// required in the AC's for this ticket.
|
||||
function servicesRenderRow(row: Row<Service>, highlightedItemId?: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue