mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
fix(docker): hide write buttons for non authorized [EE-6775] (#11260)
Some checks failed
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
Some checks failed
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:s390x platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
ci / build_images (map[arch:arm platform:linux version:]) (push) Has been cancelled
/ triage (push) Has been cancelled
Lint / Run linters (push) Has been cancelled
Test / test-client (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:linux]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Has been cancelled
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Has been cancelled
Test / test-server (map[arch:arm64 platform:linux]) (push) Has been cancelled
ci / build_manifests (push) Has been cancelled
This commit is contained in:
parent
d8e374fb76
commit
19a6a5c608
5 changed files with 84 additions and 40 deletions
|
@ -3,6 +3,7 @@ import { Lock, Plus, Trash2 } from 'lucide-react';
|
|||
|
||||
import { SecretViewModel } from '@/docker/models/secret';
|
||||
import { isoDate } from '@/portainer/filters/filters';
|
||||
import { Authorized, useAuthorizations } from '@/react/hooks/useUser';
|
||||
|
||||
import { buildNameColumn } from '@@/datatables/buildNameColumn';
|
||||
import { Datatable, TableSettingsMenu } from '@@/datatables';
|
||||
|
@ -53,6 +54,11 @@ export function SecretsDatatable({
|
|||
const tableState = useTableState(store, storageKey);
|
||||
useRepeater(tableState.autoRefreshRate, onRefresh);
|
||||
|
||||
const hasWriteAccessQuery = useAuthorizations([
|
||||
'DockerSecretCreate',
|
||||
'DockerSecretDelete',
|
||||
]);
|
||||
|
||||
return (
|
||||
<Datatable
|
||||
title="Secrets"
|
||||
|
@ -60,11 +66,14 @@ export function SecretsDatatable({
|
|||
columns={columns}
|
||||
dataset={dataset || []}
|
||||
isLoading={!dataset}
|
||||
disableSelect={!hasWriteAccessQuery.authorized}
|
||||
settingsManager={tableState}
|
||||
emptyContentLabel="No secret available."
|
||||
renderTableActions={(selectedItems) => (
|
||||
<TableActions selectedItems={selectedItems} onRemove={onRemove} />
|
||||
)}
|
||||
renderTableActions={(selectedItems) =>
|
||||
hasWriteAccessQuery.authorized && (
|
||||
<TableActions selectedItems={selectedItems} onRemove={onRemove} />
|
||||
)
|
||||
}
|
||||
renderTableSettings={() => (
|
||||
<TableSettingsMenu>
|
||||
<TableSettingsMenuAutoRefresh
|
||||
|
@ -86,26 +95,30 @@ function TableActions({
|
|||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
color="dangerlight"
|
||||
disabled={selectedItems.length === 0}
|
||||
onClick={() => onRemove(selectedItems)}
|
||||
icon={Trash2}
|
||||
className="!m-0"
|
||||
data-cy="secret-removeSecretButton"
|
||||
>
|
||||
Remove
|
||||
</Button>
|
||||
<Authorized authorizations="DockerSecretDelete">
|
||||
<Button
|
||||
color="dangerlight"
|
||||
disabled={selectedItems.length === 0}
|
||||
onClick={() => onRemove(selectedItems)}
|
||||
icon={Trash2}
|
||||
className="!m-0"
|
||||
data-cy="secret-removeSecretButton"
|
||||
>
|
||||
Remove
|
||||
</Button>
|
||||
</Authorized>
|
||||
|
||||
<Button
|
||||
as={Link}
|
||||
props={{ to: '.new' }}
|
||||
icon={Plus}
|
||||
className="!m-0"
|
||||
data-cy="secret-addSecretButton"
|
||||
>
|
||||
Add secret
|
||||
</Button>
|
||||
<Authorized authorizations="DockerSecretCreate">
|
||||
<Button
|
||||
as={Link}
|
||||
props={{ to: '.new' }}
|
||||
icon={Plus}
|
||||
className="!m-0"
|
||||
data-cy="secret-addSecretButton"
|
||||
>
|
||||
Add secret
|
||||
</Button>
|
||||
</Authorized>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue