mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
refactor(docker/events): convert table to react [EE-4667] (#8937)
This commit is contained in:
parent
ecd54ab929
commit
a725883cbc
5 changed files with 61 additions and 114 deletions
54
app/react/docker/events/EventsDatatables.tsx
Normal file
54
app/react/docker/events/EventsDatatables.tsx
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
import { Clock } from 'lucide-react';
|
||||
|
||||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
|
||||
import { Datatable } from '@@/datatables';
|
||||
import { createPersistedStore } from '@@/datatables/types';
|
||||
import { useTableState } from '@@/datatables/useTableState';
|
||||
|
||||
type DockerEvent = {
|
||||
Time: number;
|
||||
Type: string;
|
||||
Details: string;
|
||||
};
|
||||
|
||||
const columnHelper = createColumnHelper<DockerEvent>();
|
||||
|
||||
export const columns = [
|
||||
columnHelper.accessor('Time', {
|
||||
header: 'Date',
|
||||
cell: ({ getValue }) => {
|
||||
const value = getValue();
|
||||
return isoDateFromTimestamp(value);
|
||||
},
|
||||
}),
|
||||
columnHelper.accessor('Type', {
|
||||
header: 'Type',
|
||||
}),
|
||||
columnHelper.accessor('Details', {
|
||||
header: 'Details',
|
||||
}),
|
||||
];
|
||||
|
||||
const tableKey = 'docker-events';
|
||||
const settingsStore = createPersistedStore(tableKey, {
|
||||
id: 'Time',
|
||||
desc: true,
|
||||
});
|
||||
|
||||
export function EventsDatatable({ dataset }: { dataset: Array<DockerEvent> }) {
|
||||
const tableState = useTableState(settingsStore, tableKey);
|
||||
|
||||
return (
|
||||
<Datatable
|
||||
dataset={dataset}
|
||||
columns={columns}
|
||||
settingsManager={tableState}
|
||||
title="Events"
|
||||
titleIcon={Clock}
|
||||
disableSelect
|
||||
emptyContentLabel="No event available."
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue