mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
refactor(tags): migrate tags to react [EE-4707] (#10771)
This commit is contained in:
parent
a00cb951bc
commit
45be6c2b45
7 changed files with 54 additions and 125 deletions
50
app/react/portainer/environments/TagsView/TagsDatatable.tsx
Normal file
50
app/react/portainer/environments/TagsView/TagsDatatable.tsx
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { TagIcon } from 'lucide-react';
|
||||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
|
||||
import { Tag } from '@/portainer/tags/types';
|
||||
|
||||
import { Datatable } from '@@/datatables';
|
||||
import { createPersistedStore } from '@@/datatables/types';
|
||||
import { useTableState } from '@@/datatables/useTableState';
|
||||
import { DeleteButton } from '@@/buttons/DeleteButton';
|
||||
|
||||
const columnHelper = createColumnHelper<Tag>();
|
||||
|
||||
const columns = [
|
||||
columnHelper.accessor('Name', {
|
||||
header: 'Name',
|
||||
}),
|
||||
];
|
||||
|
||||
const tableKey = 'tags-table';
|
||||
|
||||
const store = createPersistedStore(tableKey);
|
||||
|
||||
export function TagsDatatable({
|
||||
dataset,
|
||||
onRemove,
|
||||
}: {
|
||||
dataset: Array<Tag> | undefined;
|
||||
onRemove: (selectedItems: Array<Tag>) => void;
|
||||
}) {
|
||||
const tableState = useTableState(store, tableKey);
|
||||
|
||||
return (
|
||||
<Datatable
|
||||
title="Tags"
|
||||
titleIcon={TagIcon}
|
||||
dataset={dataset || []}
|
||||
columns={columns}
|
||||
isLoading={!dataset}
|
||||
emptyContentLabel="No tag available."
|
||||
settingsManager={tableState}
|
||||
renderTableActions={(selectedItems) => (
|
||||
<DeleteButton
|
||||
disabled={selectedItems.length === 0}
|
||||
confirmMessage="Are you sure you want to remove the selected tag(s)?"
|
||||
onConfirmed={() => onRemove(selectedItems)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue