The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Use new sheet component + small nudges to UI (#43979)
Joshen Lim77e053870ccb
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/AddRowOperationItem.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/AddRowOperationItem.tsxindex 0b2878cee77..637cc986b6e 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/AddRowOperationItem.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/AddRowOperationItem.tsx@@ -1,13 +1,13 @@import { useQueryClient } from '@tanstack/react-query'-import { Plus, Undo2 } from 'lucide-react'import { tableRowKeys } from 'data/table-rows/keys'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { Undo2 } from 'lucide-react'import { useTableEditorStateSnapshot } from 'state/table-editor'+import { Card, CardContent, CardHeader } from 'ui'import { formatOperationItemValue } from './OperationQueueSidePanel.utils'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import { AddRowPayload } from '@/state/table-editor-operation-queue.types'-import { Card, CardContent, CardHeader } from 'ui'interface AddRowOperationItemProps {operationId: string@@ -49,7 +49,7 @@ export const AddRowOperationItem = ({return (<Card className="overflow-hidden">- <CardHeader className="pt-2.5 flex flex-row gap-2">+ <CardHeader className="py-2 px-3 flex flex-row gap-2 space-y-0 items-center"><div className="min-w-0 flex-1 flex items-start gap-2"><div className="min-w-0 flex-1"><code className="text-code-inline dark:bg-surface-300 dark:border-foreground-muted/50">@@ -62,14 +62,13 @@ export const AddRowOperationItem = ({</div><ButtonTooltiptype="text"- size="tiny"aria-label="Revert change"- className="px-1.5"+ className="w-7"icon={<Undo2 />}onClick={handleDelete}tooltip={{content: {- side: 'bottom',+ side: 'left',align: 'end',text: 'Revert change',},@@ -77,7 +76,12 @@ export const AddRowOperationItem = ({/></CardHeader>- <CardContent className="font-mono text-xs space-y-1 text-brand-link">+ <CardContent className="py-2 px-3 font-mono text-xs text-brand-link">+ {previewColumns.length === 0 && (+ <span className="text-foreground-light">+ No data provided, default values will be used+ </span>+ )}{previewColumns.map(([key, value]) => (<div key={key} className="flex gap-2 py-0.5"><span className="text-brand-link select-none font-medium">+</span>diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/DeleteRowOperationItem.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/DeleteRowOperationItem.tsxindex 56069c3b2c6..4ad7e893ebd 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/DeleteRowOperationItem.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/DeleteRowOperationItem.tsx@@ -1,13 +1,13 @@import { useQueryClient } from '@tanstack/react-query'-import { Undo2 } from 'lucide-react'import { tableRowKeys } from 'data/table-rows/keys'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { Undo2 } from 'lucide-react'import { useTableEditorStateSnapshot } from 'state/table-editor'+import { Card, CardContent, CardHeader } from 'ui'import { formatOperationItemValue } from './OperationQueueSidePanel.utils'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import { DeleteRowPayload } from '@/state/table-editor-operation-queue.types'-import { Card, CardContent, CardHeader } from 'ui'interface DeleteRowOperationItemProps {operationId: string@@ -47,7 +47,7 @@ export const DeleteRowOperationItem = ({return (<Card className="overflow-hidden border-destructive-500 bg-destructive-500/5">- <CardHeader className="pt-2.5 flex flex-row gap-2 border-b border-destructive-500">+ <CardHeader className="py-2 px-3 flex flex-row gap-2 border-b border-destructive-500 space-y-0 items-center"><div className="min-w-0 flex-1 flex items-start gap-2"><div className="min-w-0 flex-1"><code className="text-code-inline dark:bg-surface-300 dark:border-foreground-muted/50">@@ -62,14 +62,13 @@ export const DeleteRowOperationItem = ({</div><ButtonTooltiptype="text"- size="tiny"aria-label="Revert change"- className="px-1.5"+ className="w-7"icon={<Undo2 />}onClick={handleDelete}tooltip={{content: {- side: 'bottom',+ side: 'left',align: 'end',text: 'Revert change',},@@ -77,7 +76,7 @@ export const DeleteRowOperationItem = ({/></CardHeader>- <CardContent className="font-mono text-xs bg-destructive-100/30">+ <CardContent className="py-2 px-3 font-mono text-xs bg-destructive-100/30"><div className="text-destructive py-0.5">Row will be deleted</div></CardContent></Card>diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationItem.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationItem.tsxindex 4773099a270..0e65c097a9f 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationItem.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationItem.tsx@@ -1,13 +1,13 @@import { useQueryClient } from '@tanstack/react-query'-import { Undo2 } from 'lucide-react'import { tableRowKeys } from 'data/table-rows/keys'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'+import { Undo2 } from 'lucide-react'import { useTableEditorStateSnapshot } from 'state/table-editor'+import { Card, CardContent, CardHeader } from 'ui'import { formatOperationItemValue } from './OperationQueueSidePanel.utils'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import { EditCellContentPayload } from '@/state/table-editor-operation-queue.types'-import { Card, CardContent, CardHeader } from 'ui'interface OperationItemProps {operationId: string@@ -46,7 +46,7 @@ export const OperationItem = ({ operationId, tableId, content }: OperationItemPrreturn (<Card className="overflow-hidden">- <CardHeader className="pt-2.5 flex flex-row gap-2">+ <CardHeader className="py-2 px-3 flex flex-row gap-2 space-y-0 items-center"><div className="min-w-0 flex-1"><code className="text-code-inline dark:bg-surface-300 dark:border-foreground-muted/50">{fullTableName}@@ -59,14 +59,13 @@ export const OperationItem = ({ operationId, tableId, content }: OperationItemPr</div><ButtonTooltiptype="text"- size="tiny"aria-label="Revert change"className="px-1.5"icon={<Undo2 />}onClick={handleDelete}tooltip={{content: {- side: 'bottom',+ side: 'left',align: 'end',text: 'Revert change',},@@ -74,7 +73,7 @@ export const OperationItem = ({ operationId, tableId, content }: OperationItemPr/></CardHeader>- <CardContent className="font-mono text-xs">+ <CardContent className="py-2 px-3 font-mono text-xs"><div className="flex gap-2 py-0.5"><span className="text-destructive select-none font-medium">-</span><span className="text-destructive truncate max-w-full" title={formattedOldValue}>diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationList.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationList.tsxindex 1c3dc3b7559..af3c365133c 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationList.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationList.tsx@@ -1,8 +1,8 @@import {- QueuedOperation,isAddRowOperation,isDeleteRowOperation,isEditCellContentOperation,+ QueuedOperation,} from 'state/table-editor-operation-queue.types'import { AddRowOperationItem } from './AddRowOperationItem'@@ -27,10 +27,10 @@ export const OperationList = ({ operations }: OperationListProps) => {const editOperations = operations.filter(isEditCellContentOperation)return (- <div className="space-y-8">+ <div className="divide-y">{deleteOperations.length > 0 && (- <div className="space-y-3">- <h3 className="text-xs text-foreground-lighter">+ <div className="space-y-3 p-4">+ <h3 className="text-xs text-foreground-lighter font-mono uppercase">{deleteOperations.length} row deletion{deleteOperations.length !== 1 ? 's' : ''}</h3>@@ -48,8 +48,8 @@ export const OperationList = ({ operations }: OperationListProps) => {)}{addOperations.length > 0 && (- <div className="space-y-3">- <h3 className="text-xs text-foreground-lighter">+ <div className="space-y-3 p-4">+ <h3 className="text-xs text-foreground-lighter font-mono uppercase">{addOperations.length} row addition{addOperations.length !== 1 ? 's' : ''}</h3><div className="space-y-3">@@ -66,8 +66,8 @@ export const OperationList = ({ operations }: OperationListProps) => {)}{editOperations.length > 0 && (- <div className="space-y-3">- <h3 className="text-xs text-foreground-lighter">+ <div className="space-y-3 p-4">+ <h3 className="text-xs text-foreground-lighter font-mono uppercase">{editOperations.length} cell edit{editOperations.length !== 1 ? 's' : ''}</h3>diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsxindex e561e28fa75..f0314fd96e4 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/OperationQueueSidePanel/OperationQueueSidePanel.tsx@@ -1,72 +1,84 @@import { useOperationQueueActions } from 'components/grid/hooks/useOperationQueueActions'import { useTableEditorStateSnapshot } from 'state/table-editor'-import { Button, SidePanel } from 'ui'+import {+ Button,+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetSection,+ SheetTitle,+} from 'ui'import { OperationList } from './OperationList'+import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'+import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'import { getModKeyLabel } from '@/lib/helpers'import { QueuedOperation } from '@/state/table-editor-operation-queue.types'-interface OperationQueueSidePanelProps {- visible: boolean- closePanel: () => void-}--export const OperationQueueSidePanel = ({ visible, closePanel }: OperationQueueSidePanelProps) => {+export const OperationQueueSidePanel = () => {const modKey = getModKeyLabel()const snap = useTableEditorStateSnapshot()+ const visible = snap.sidePanel?.type === 'operation-queue'const operations = snap.operationQueue.operations as readonly QueuedOperation[]const { handleSave, handleCancel, isSaving } = useOperationQueueActions({- onSaveSuccess: closePanel,- onCancelSuccess: closePanel,+ onSaveSuccess: snap.closeSidePanel,+ onCancelSuccess: snap.closeSidePanel,+ })++ const { confirmOnClose, modalProps: closeConfirmationModalProps } = useConfirmOnClose({+ checkIsDirty: () => true,+ onClose: () => handleCancel(),})return (- <SidePanel- size="large"- visible={visible}- onCancel={closePanel}- onOpenAutoFocus={(event) => event.preventDefault()} // Prevent focus on first focussable element since it is the revert changes ButtonTooltip- header={- <div className="flex items-center justify-between w-full">- <div className="flex flex-col gap-1">- <span>Pending changes</span>- <span className="text-xs text-foreground-lighter">+ <>+ <Sheet open={visible} onOpenChange={(open) => !open && snap.closeSidePanel()}>+ <SheetContent+ className="flex flex-col gap-y-0"+ onOpenAutoFocus={(event) => event.preventDefault()}+ >+ <SheetHeader>+ <SheetTitle>Pending changes</SheetTitle>+ <SheetDescription>{operations.length} operation{operations.length !== 1 ? 's' : ''}- </span>- </div>- </div>- }- customFooter={- <div className="flex w-full justify-between border-t border-default px-3 py-4">- <Button type="default" onClick={closePanel}>- Close- <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}.</span>- </Button>- <div className="flex space-x-3">- <Button- type="default"- onClick={handleCancel}- disabled={isSaving || operations.length === 0}- >- Revert{operations.length > 1 && ' all'}- </Button>- <Button- onClick={handleSave}- disabled={isSaving || operations.length === 0}- loading={isSaving}- >- Save{operations.length > 1 && ' all'}- <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}S</span>+ </SheetDescription>+ </SheetHeader>++ <SheetSection className="overflow-auto flex-grow p-0">+ <OperationList operations={operations} />+ </SheetSection>++ <SheetFooter className="!justify-between">+ <Button type="default" onClick={snap.closeSidePanel}>+ Close+ <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}.</span></Button>- </div>- </div>- }- >- <SidePanel.Content className="py-4 h-full">- <OperationList operations={operations} />- </SidePanel.Content>- </SidePanel>+ <div className="flex space-x-3">+ <Button+ type="default"+ onClick={confirmOnClose}+ disabled={isSaving || operations.length === 0}+ >+ Revert{operations.length > 1 && ' all'}+ </Button>+ <Button+ onClick={handleSave}+ disabled={isSaving || operations.length === 0}+ loading={isSaving}+ >+ Save{operations.length > 1 && ' all'}+ <span className="text-foreground/40 text-[10px] ml-1.5">{modKey}S</span>+ </Button>+ </div>+ </SheetFooter>+ </SheetContent>+ </Sheet>++ <DiscardChangesConfirmationDialog {...closeConfirmationModalProps} />+ </>)}diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsxindex 30db82f074c..13a81de1bd7 100644--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx@@ -1064,10 +1064,7 @@ export const SidePanelEditor = ({closePanel={onClosePanel}updateEditorDirty={setIsEdited}/>- <OperationQueueSidePanel- visible={snap.sidePanel?.type === 'operation-queue'}- closePanel={snap.closeSidePanel}- />+ <OperationQueueSidePanel /><DiscardChangesConfirmationDialog {...modalProps} /></>)diff --git a/e2e/studio/features/queue-table-operations.spec.ts b/e2e/studio/features/queue-table-operations.spec.tsindex 9a0fd34281a..b237580bbe5 100644--- a/e2e/studio/features/queue-table-operations.spec.ts+++ b/e2e/studio/features/queue-table-operations.spec.ts@@ -105,12 +105,57 @@ test.describe('Queue Table Operations', () => {await page.getByRole('button', { name: 'Revert', exact: true }).click()+ const confirmDialog = page.getByRole('alertdialog')+ await expect(confirmDialog.getByRole('heading', { name: 'Unsaved changes' })).toBeVisible()+ await confirmDialog.getByRole('button', { name: 'Discard changes' }).click()+await expect(page.getByRole('gridcell', { name: 'keep this value' })).toBeVisible()await expect(page.getByRole('gridcell', { name: 'should be cancelled' })).not.toBeVisible()await expect(page.getByText('pending change')).not.toBeVisible()})+ test('revert can be cancelled via discard confirmation dialog', async ({ page, ref }) => {+ const tableName = `${tableNamePrefix}_discard_cancel`+ const columnName = 'name'++ await using _ = await withSetupCleanup(+ async () => {+ await createTable(tableName, columnName, [{ name: 'keep this value' }])+ },+ async () => {+ await dropTable(tableName)+ }+ )++ await page.goto(toUrl(`/project/${ref}/editor?schema=public`))+ await enableQueueOperations(page)+ await page.reload()+ await waitForTableToLoad(page, ref)++ await page.getByRole('button', { name: `View ${tableName}`, exact: true }).click()+ await page.waitForURL(/\/editor\/\d+\?schema=public$/)++ const cell = page.getByRole('gridcell', { name: 'keep this value' })+ await cell.dblclick()+ const editor = page.getByRole('textbox', { name: /Editor content/ })+ await editor.fill('edited value')+ await page.keyboard.press('Enter')++ await expect(page.getByText('1 pending change')).toBeVisible()+ await page.getByRole('button', { name: /Review/ }).click()++ await page.getByRole('button', { name: 'Revert', exact: true }).click()++ const confirmDialog = page.getByRole('alertdialog')+ await expect(confirmDialog.getByRole('heading', { name: 'Unsaved changes' })).toBeVisible()+ await confirmDialog.getByRole('button', { name: 'Keep editing' }).click()++ const sidePanel = page.getByRole('dialog')+ await expect(sidePanel.getByText('Pending changes')).toBeVisible()+ await expect(sidePanel.getByText('1 operation')).toBeVisible()+ })+test('row inserts are queued and can be saved', async ({ page, ref }) => {const tableName = `${tableNamePrefix}_row_insert`const columnName = 'name'@@ -277,6 +322,7 @@ test.describe('Queue Table Operations', () => {await expect(page.getByRole('dialog').getByText('Pending changes')).toBeVisible()await page.keyboard.press('ControlOrMeta+.')+ await expect(page.getByRole('dialog')).not.toBeVisible()await expect(page.getByRole('button', { name: /Review/ })).toBeVisible()await page.keyboard.press('ControlOrMeta+s')@@ -517,6 +563,10 @@ test.describe('Queue Table Operations', () => {await page.getByRole('button', { name: /Review/ }).click()await page.getByRole('button', { name: 'Revert', exact: true }).click()+ const confirmDialog = page.getByRole('alertdialog')+ await expect(confirmDialog.getByRole('heading', { name: 'Unsaved changes' })).toBeVisible()+ await confirmDialog.getByRole('button', { name: 'Discard changes' }).click()+await expect(page.getByRole('gridcell', { name: 'should not be deleted' })).toBeVisible()await expect(page.getByText('pending change')).not.toBeVisible()})