import {
Button,
KeyboardShortcut,
Sheet,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetSection,
SheetTitle,
} from 'ui'
import { OperationList } from './OperationList'
import { useOperationQueueActions } from '@/components/grid/hooks/useOperationQueueActions'
import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'
import { useTableEditorStateSnapshot } from '@/state/table-editor'
import { QueuedOperation } from '@/state/table-editor-operation-queue.types'
export const OperationQueueSidePanel = () => {
const snap = useTableEditorStateSnapshot()
const visible = snap.sidePanel?.type === 'operation-queue'
const operations = snap.operationQueue.operations as readonly QueuedOperation[]
const { handleSave, handleCancel, isSaving } = useOperationQueueActions({
onSaveSuccess: snap.closeSidePanel,
onCancelSuccess: snap.closeSidePanel,
})
const { confirmOnClose, modalProps: closeConfirmationModalProps } = useConfirmOnClose({
checkIsDirty: () => true,
onClose: () => handleCancel(),
})
return (
<>
!open && snap.closeSidePanel()}>
event.preventDefault()}
>
Pending changes
{operations.length} operation{operations.length !== 1 ? 's' : ''}
}
>
Close
}
>
Save
>
)
}