Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): show queue changes label for queued table edits (#44168)

Danny White8cd43e358481
diff --git a/apps/studio/components/grid/components/editor/DateTimeEditor.tsx b/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
index 445e55e1af7..c7ef67b6768 100644
--- a/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
+++ b/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
@@ -1,5 +1,6 @@
import dayjs from 'dayjs'
import { ChevronDown } from 'lucide-react'
+import { useIsQueueOperationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { useEffect, useRef, useState } from 'react'
import type { RenderEditCellProps } from 'react-data-grid'
@@ -42,10 +43,12 @@ function BaseEditor<TRow, TSummaryRow = unknown>({
}: BaseEditorProps<TRow, TSummaryRow>) {
const ref = useRef<HTMLInputElement>(null)
const format = FORMAT_MAP[type]
+ const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
const value = row[column.key as keyof TRow] as unknown as string
const [inputValue, setInputValue] = useState(value)
const timeValue = inputValue ? Number(dayjs(inputValue, format)) : inputValue
+ const applyChangesLabel = isQueueOperationsEnabled ? 'Queue changes' : 'Save changes'
const saveChanges = (value: string | null) => {
if ((typeof value === 'string' && value.length === 0) || timeValue === 'Invalid Date') return
@@ -126,7 +129,7 @@ function BaseEditor<TRow, TSummaryRow = unknown>({
<div className="px-1.5 h-[22px] rounded bg-surface-300 border border-strong flex items-center justify-center">
<span className="text-[10px]">⏎</span>
</div>
- <p className="text-xs text-foreground-light">Save changes</p>
+ <p className="text-xs text-foreground-light">{applyChangesLabel}</p>
</div>
<div className="flex items-center space-x-2">
<div className="px-1 h-[22px] rounded bg-surface-300 border border-strong flex items-center justify-center">
diff --git a/apps/studio/components/grid/components/editor/JsonEditor.tsx b/apps/studio/components/grid/components/editor/JsonEditor.tsx
index bc30143a74d..fc79ddb41f9 100644
--- a/apps/studio/components/grid/components/editor/JsonEditor.tsx
+++ b/apps/studio/components/grid/components/editor/JsonEditor.tsx
@@ -4,6 +4,7 @@ import type { RenderEditCellProps } from 'react-data-grid'
import { toast } from 'sonner'
import { useParams } from 'common'
+import { useIsQueueOperationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { isValueTruncated } from 'components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils'
import { useTableEditorQuery } from 'data/table-editor/table-editor-query'
import { isTableLike } from 'data/table-editor/table-editor-types'
@@ -56,6 +57,7 @@ export const JsonEditor = <TRow, TSummaryRow = unknown>({
const { id: _id } = useParams()
const id = _id ? Number(_id) : undefined
const { data: project } = useSelectedProjectQuery()
+ const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
const { data: selectedTable } = useTableEditorQuery({
projectRef: project?.ref,
@@ -74,6 +76,7 @@ export const JsonEditor = <TRow, TSummaryRow = unknown>({
const isTruncated = isValueTruncated(initialValue)
const [isPopoverOpen, setIsPopoverOpen] = useState(true)
const [value, setValue] = useState<string | null>(jsonString)
+ const applyChangesLabel = isQueueOperationsEnabled ? 'Queue changes' : 'Save changes'
const { mutate: getCellValue, isPending, isSuccess } = useGetCellValueMutation()
@@ -187,7 +190,7 @@ export const JsonEditor = <TRow, TSummaryRow = unknown>({
<div className="px-1.5 py-[2.5px] rounded bg-selection border border-strong flex items-center justify-center">
<span className="text-[10px]">⏎</span>
</div>
- <p className="text-xs text-foreground-light">Save changes</p>
+ <p className="text-xs text-foreground-light">{applyChangesLabel}</p>
</div>
<div className="flex items-center space-x-2">
<div className="px-1 py-[2.5px] rounded bg-selection border border-strong flex items-center justify-center">
diff --git a/apps/studio/components/grid/components/editor/TextEditor.tsx b/apps/studio/components/grid/components/editor/TextEditor.tsx
index ddfc2229a61..00d7aa03c1d 100644
--- a/apps/studio/components/grid/components/editor/TextEditor.tsx
+++ b/apps/studio/components/grid/components/editor/TextEditor.tsx
@@ -46,6 +46,7 @@ export const TextEditor = <TRow, TSummaryRow = unknown>({
const [value, setValue] = useState<string | null>(initialValue)
const [isConfirmNextModalOpen, setIsConfirmNextModalOpen] = useState(false)
const { isQueueEnabled } = useTableRowOperations()
+ const applyChangesLabel = isQueueEnabled ? 'Queue changes' : 'Save changes'
const { mutate: getCellValue, isPending, isSuccess } = useGetCellValueMutation()
@@ -145,7 +146,7 @@ export const TextEditor = <TRow, TSummaryRow = unknown>({
<div className="px-1.5 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">
<span className="text-[10px]">⏎</span>
</div>
- <p className="text-xs text-foreground-light">Save changes</p>
+ <p className="text-xs text-foreground-light">{applyChangesLabel}</p>
</div>
<div className="flex items-center space-x-2">
<div className="px-1 py-[2.5px] rounded bg-surface-300 border border-strong flex items-center justify-center">
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
index 724aa533e7d..24127eddffd 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
@@ -21,6 +21,7 @@ import {
validateFields,
} from './RowEditor.utils'
import { TextEditor } from './TextEditor'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
export interface RowEditorProps {
row?: Dictionary<any>
@@ -43,6 +44,10 @@ export const RowEditor = ({
saveChanges = noop,
updateEditorDirty = noop,
}: RowEditorProps) => {
+ const { data: project } = useSelectedProjectQuery()
+ const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
+ const applyChangesLabel = isQueueOperationsEnabled ? 'Queue changes' : 'Save'
+
const [errors, setErrors] = useState<Dictionary<any>>({})
const [rowFields, setRowFields] = useState<RowField[]>([])
@@ -64,7 +69,6 @@ export const RowEditor = ({
(rowField: any) => !rowField.isNullable
)
- const { data: project } = useSelectedProjectQuery()
const { data } = useForeignKeyConstraintsQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
@@ -182,7 +186,7 @@ export const RowEditor = ({
loading={loading}
formId={formId}
backButtonLabel="Cancel"
- applyButtonLabel="Save"
+ applyButtonLabel={applyChangesLabel}
closePanel={closePanel}
hideApply={!editable}
visible={visible}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index aaf6bc56c32..1cdfa93e64d 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -4,6 +4,7 @@ import { useQueryClient } from '@tanstack/react-query'
import { useParams } from 'common'
import { useTableRowOperations } from 'components/grid/hooks/useTableRowOperations'
import { type GeneratedPolicy } from 'components/interfaces/Auth/Policies/Policies.utils'
+import { useIsQueueOperationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { DiscardChangesConfirmationDialog } from 'components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { databasePoliciesKeys } from 'data/database-policies/keys'
import { useDatabasePublicationCreateMutation } from 'data/database-publications/database-publications-create-mutation'
@@ -196,6 +197,7 @@ export const SidePanelEditor = ({
const { data: project } = useSelectedProjectQuery()
const { data: org } = useSelectedOrganizationQuery()
const isApiGrantTogglesEnabled = useDataApiGrantTogglesEnabled()
+ const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
const { updateRow, addRow, isEditPending } = useTableRowOperations()
const [isEdited, setIsEdited] = useState<boolean>(false)
@@ -963,7 +965,7 @@ export const SidePanelEditor = ({
row={(snap.sidePanel?.type === 'json' && snap.sidePanel.jsonValue.row) || {}}
column={(snap.sidePanel?.type === 'json' && snap.sidePanel.jsonValue.column) || ''}
backButtonLabel="Cancel"
- applyButtonLabel="Save changes"
+ applyButtonLabel={isQueueOperationsEnabled ? 'Queue changes' : 'Save changes'}
readOnly={!editable}
closePanel={onClosePanel}
onSaveJSON={onSaveColumnValue}