import type { ColumnDef } from '@tanstack/react-table'; import { useStore } from '@tanstack/react-form'; import { Link } from '@tanstack/react-router'; import { type AdminMount, deleteAdminMountInput, useDeleteAdminMount } from '@/api/admin/mounts/queries'; import Button from '@/components/elements/Button'; import { Dialog } from '@/components/elements/dialog'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import DataTableColumnHeader from '@/components/elements/table/DataTableColumnHeader'; import { actionsColumn, DeleteAction, EditLinkAction, RowActions } from '@/components/elements/table/RowActions'; import { Form, useAppForm } from '@/components/form'; interface MountDialogProps { mount: AdminMount; open: boolean; onClose: () => void; } function DeleteMountDialog({ mount, open, onClose }: MountDialogProps) { const { attributes } = mount; const deleteMount = useDeleteAdminMount(); const deleteForm = useAppForm({ defaultValues: { confirm: '' }, onSubmit: async () => { try { await deleteMount.mutateAsync(deleteAdminMountInput(attributes.id, attributes.name)); onClose(); } catch { // Error toast is handled by the mutation. } }, }); const isSubmitting = useStore(deleteForm.store, (state) => state.isSubmitting); return (

Deleting a mount is permanent. This will permanently delete {attributes.name} and remove it from attached eggs and nodes.

value === attributes.name ? undefined : 'The mount name must be provided.', }} > {(field) => ( )}
Cancel Delete mount
); } const MountIdentityCell = ({ mount }: { mount: AdminMount }) => (
{mount.attributes.name} {mount.attributes.description ? (

{mount.attributes.description}

) : null}
); const MountPathCell = ({ path }: { path: string }) => ( {path} ); const MountActionsCell = ({ mount }: { mount: AdminMount }) => ( } > {({ open, onClose }) => } ); export const mountColumns = [ { id: 'name', accessorFn: (mount) => mount.attributes.name, header: ({ column }) => , cell: ({ row }) => , enableSorting: true, meta: { headerClassName: 'min-w-48', cellClassName: 'min-w-48' }, }, { id: 'source', header: 'Source', cell: ({ row }) => , enableSorting: false, meta: { headerClassName: 'hidden w-44 @2xl:table-cell', cellClassName: 'hidden w-44 @2xl:table-cell' }, }, { id: 'target', header: 'Target', cell: ({ row }) => , enableSorting: false, meta: { headerClassName: 'hidden w-44 @4xl:table-cell', cellClassName: 'hidden w-44 @4xl:table-cell' }, }, { id: 'eggs_count', header: 'Eggs', cell: ({ row }) => {row.original.attributes.eggs_count}, enableSorting: false, meta: { headerClassName: 'hidden w-20 @sm:table-cell', cellClassName: 'hidden w-20 @sm:table-cell' }, }, { id: 'nodes_count', header: 'Nodes', cell: ({ row }) => {row.original.attributes.nodes_count}, enableSorting: false, meta: { headerClassName: 'hidden w-20 @xl:table-cell', cellClassName: 'hidden w-20 @xl:table-cell' }, }, actionsColumn(2, (mount) => ), ] satisfies ColumnDef[];