1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

refactor(kube/registries): migrate access table to react [EE-4706] (#10688)

This commit is contained in:
Chaim Lev-Ari 2024-04-08 17:23:12 +03:00 committed by GitHub
parent f584bf3830
commit a00cb951bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 74 additions and 142 deletions

View file

@ -0,0 +1,58 @@
import { UserX } from 'lucide-react';
import { createColumnHelper } from '@tanstack/react-table';
import { Datatable } from '@@/datatables';
import { createPersistedStore } from '@@/datatables/types';
import { useTableState } from '@@/datatables/useTableState';
import { DeleteButton } from '@@/buttons/DeleteButton';
type Item = { value: string };
const columnHelper = createColumnHelper<Item>();
const columns = [
columnHelper.accessor('value', {
header: 'Namespace',
}),
];
const tableKey = 'kube-access-table';
const store = createPersistedStore(tableKey);
export function AccessTable({
dataset,
onRemove,
}: {
dataset: Array<Item>;
onRemove: (selectedItems: Array<Item>) => void;
}) {
const tableState = useTableState(store, tableKey);
return (
<Datatable
title="Access"
titleIcon={UserX}
dataset={dataset}
columns={columns}
emptyContentLabel="No namespace has been authorized yet."
settingsManager={tableState}
renderTableActions={(selectedItems) => (
<DeleteButton
disabled={selectedItems.length === 0}
confirmMessage={
<>
<p>
This registry might be used by one or more applications inside
this environment. Removing the registry access could lead to a
service interruption for these applications.
</p>
<p>Are you sure you wish to continue?</p>
</>
}
onConfirmed={() => onRemove(selectedItems)}
/>
)}
/>
);
}