import type { ColumnDef } from '@tanstack/react-table';
import { Archive, Lock } from 'lucide-react';
import type { ServerBackup } from '@/api/server/backups/queries';
import Can from '@/components/elements/Can';
import Icon from '@/components/elements/Icon';
import Spinner from '@/components/elements/Spinner';
import { actionsColumn } from '@/components/elements/table/RowActions';
import BackupContextMenu from '@/components/server/backups/BackupContextMenu';
import { bytesToString } from '@/lib/formatters';
import dayjs from '@/lib/dayjs';
const BackupIdentityCell = ({ backup }: { backup: ServerBackup }) => {
const { attributes } = backup;
return (
{attributes.completed_at === null ? (
) : (
)}
{attributes.completed_at !== null && !attributes.is_successful ? (
Failed
) : null}
{attributes.name}
{attributes.checksum}
);
};
const BackupActionsCell = ({ backup, page }: { backup: ServerBackup; page: number }) => (
{backup.attributes.completed_at ? : null}
);
export const backupColumns = (page: number): ColumnDef[] => [
{
id: 'name',
accessorFn: (backup) => backup.attributes.name,
header: 'Backup',
cell: ({ row }) => ,
enableSorting: false,
},
{
id: 'bytes',
accessorFn: (backup) => backup.attributes.bytes,
header: 'Size',
cell: ({ row }) => (
{row.original.attributes.completed_at && row.original.attributes.is_successful
? bytesToString(row.original.attributes.bytes)
: '-'}
),
enableSorting: false,
meta: { headerClassName: 'hidden md:table-cell w-28', cellClassName: 'hidden md:table-cell w-28' },
},
{
id: 'created_at',
accessorFn: (backup) => backup.attributes.created_at,
header: 'Created',
cell: ({ row }) => (
),
enableSorting: false,
meta: { headerClassName: 'hidden sm:table-cell w-32', cellClassName: 'hidden sm:table-cell w-32' },
},
actionsColumn(2, (backup) => ),
];