Skip to content

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

feat: add user preference to enable queue operations (#44366)

Ali Waseem6be596ea348d
diff --git a/apps/studio/components/grid/components/editor/DateTimeEditor.tsx b/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
index a88343b955e..8f0e8f4ac33 100644
--- a/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
+++ b/apps/studio/components/grid/components/editor/DateTimeEditor.tsx
@@ -17,7 +17,7 @@ import { TimestampInfo, timestampLocalFormatter } from 'ui-patterns'
import { Input } from 'ui-patterns/DataInputs/Input'
import { BlockKeys } from '../common/BlockKeys'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
interface BaseEditorProps<TRow, TSummaryRow = unknown> extends RenderEditCellProps<
TRow,
diff --git a/apps/studio/components/grid/components/editor/JsonEditor.tsx b/apps/studio/components/grid/components/editor/JsonEditor.tsx
index 6d7d1c35ea0..da6ed1e8162 100644
--- a/apps/studio/components/grid/components/editor/JsonEditor.tsx
+++ b/apps/studio/components/grid/components/editor/JsonEditor.tsx
@@ -9,7 +9,7 @@ import { BlockKeys } from '../common/BlockKeys'
import { MonacoEditor } from '../common/MonacoEditor'
import { NullValue } from '../common/NullValue'
import { TruncatedWarningOverlay } from './TruncatedWarningOverlay'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
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'
diff --git a/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx b/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx
index 3e47da5317d..3c67b9089ef 100644
--- a/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx
+++ b/apps/studio/components/grid/components/footer/operations/SaveQueueActionBar.tsx
@@ -13,7 +13,7 @@ import {
import { useOperationQueueActions } from '@/components/grid/hooks/useOperationQueueActions'
import { useOperationQueueShortcuts } from '@/components/grid/hooks/useOperationQueueShortcuts'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { useConfirmOnClose } from '@/hooks/ui/useConfirmOnClose'
import { getModKeyLabel } from '@/lib/helpers'
diff --git a/apps/studio/components/grid/hooks/useOperationQueueShortcuts.ts b/apps/studio/components/grid/hooks/useOperationQueueShortcuts.ts
index 1c1f3852df8..d93c41823f7 100644
--- a/apps/studio/components/grid/hooks/useOperationQueueShortcuts.ts
+++ b/apps/studio/components/grid/hooks/useOperationQueueShortcuts.ts
@@ -1,7 +1,7 @@
import { useQueryClient } from '@tanstack/react-query'
+import { useIsQueueOperationsEnabled } from 'components/interfaces/Account/Preferences/useDashboardSettings'
import { useOperationQueueActions } from './useOperationQueueActions'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { tableRowKeys } from '@/data/table-rows/keys'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useHotKey } from '@/hooks/ui/useHotKey'
diff --git a/apps/studio/components/grid/hooks/useTableRowOperations.ts b/apps/studio/components/grid/hooks/useTableRowOperations.ts
index 2ed9ab80ea9..5845a548e92 100644
--- a/apps/studio/components/grid/hooks/useTableRowOperations.ts
+++ b/apps/studio/components/grid/hooks/useTableRowOperations.ts
@@ -9,7 +9,7 @@ import {
queueRowAddWithOptimisticUpdate,
queueRowDeletesWithOptimisticUpdate,
} from '@/components/grid/utils/queueOperationUtils'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { isTableLike, type Entity } from '@/data/table-editor/table-editor-types'
import { tableRowKeys } from '@/data/table-rows/keys'
import { useTableRowCreateMutation } from '@/data/table-rows/table-row-create-mutation'
diff --git a/apps/studio/components/interfaces/Account/Preferences/AccountIdentities.tsx b/apps/studio/components/interfaces/Account/Preferences/AccountIdentities.tsx
index e33a2c98c8f..24487ace02a 100644
--- a/apps/studio/components/interfaces/Account/Preferences/AccountIdentities.tsx
+++ b/apps/studio/components/interfaces/Account/Preferences/AccountIdentities.tsx
@@ -132,7 +132,7 @@ export const AccountIdentities = () => {
)}
</div>
<p className="text-sm text-foreground-lighter">
- {!!username ? <span>{username} • </span> : null}
+ {!!username ? <span>{username} · </span> : null}
{identity.email}
</p>
</div>
diff --git a/apps/studio/components/interfaces/Account/Preferences/DashboardSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/DashboardSettings.tsx
new file mode 100644
index 00000000000..d05217368cc
--- /dev/null
+++ b/apps/studio/components/interfaces/Account/Preferences/DashboardSettings.tsx
@@ -0,0 +1,28 @@
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
+
+import { DashboardSettingsToggles } from './DashboardSettingsToggles'
+
+export const DashboardSettings = () => {
+ return (
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle id="dashboard">Dashboard</PageSectionTitle>
+ <PageSectionDescription>
+ Customize how the dashboard works on this browser and device.
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <DashboardSettingsToggles />
+ </PageSectionContent>
+ </PageSection>
+ )
+}
diff --git a/apps/studio/components/interfaces/Account/Preferences/DashboardSettingsToggles.tsx b/apps/studio/components/interfaces/Account/Preferences/DashboardSettingsToggles.tsx
new file mode 100644
index 00000000000..24433a93c03
--- /dev/null
+++ b/apps/studio/components/interfaces/Account/Preferences/DashboardSettingsToggles.tsx
@@ -0,0 +1,85 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { useForm } from 'react-hook-form'
+import { toast } from 'sonner'
+import { Card, Form_Shadcn_ } from 'ui'
+import * as z from 'zod'
+
+import { DashboardToggle } from './DashboardToggle'
+import { useIsInlineEditorSetting, useIsQueueOperationsSetting } from './useDashboardSettings'
+
+const DashboardSettingsSchema = z.object({
+ inlineEditorEnabled: z.boolean(),
+ queueOperationsEnabled: z.boolean(),
+})
+
+export const DashboardSettingsToggles = () => {
+ const { inlineEditorEnabled, setInlineEditorEnabled } = useIsInlineEditorSetting()
+ const { isQueueOperationsEnabled, setIsQueueOperationsEnabled } = useIsQueueOperationsSetting()
+
+ const { data: org } = useSelectedOrganizationQuery()
+
+ const { mutate: sendEvent } = useSendEventMutation()
+
+ const form = useForm<z.infer<typeof DashboardSettingsSchema>>({
+ resolver: zodResolver(DashboardSettingsSchema),
+ values: {
+ inlineEditorEnabled: inlineEditorEnabled ?? false,
+ queueOperationsEnabled: isQueueOperationsEnabled ?? false,
+ },
+ })
+
+ const handleInlineEditorToggle = (value: boolean) => {
+ setInlineEditorEnabled(value)
+ form.setValue('inlineEditorEnabled', value)
+
+ sendEvent({
+ action: 'inline_editor_setting_clicked',
+ properties: { enabled: value },
+ groups: { organization: org?.slug },
+ })
+
+ toast(
+ `${value ? 'Editing entities will now be via the SQL Editor' : 'Editing entities will now be via a guided UI panel'}`
+ )
+ }
+
+ const handleQueueOperationsToggle = (value: boolean) => {
+ setIsQueueOperationsEnabled(value)
+ form.setValue('queueOperationsEnabled', value)
+
+ sendEvent({
+ action: 'queue_operations_setting_clicked',
+ properties: { enabled: value },
+ groups: { organization: org?.slug },
+ })
+
+ toast(
+ `${value ? 'Table edits in the Table Editor will now be queued' : 'Table edits in the Table Editor will now be saved immediately'}`
+ )
+ }
+
+ return (
+ <Form_Shadcn_ {...form}>
+ <Card>
+ <DashboardToggle
+ form={form}
+ name="inlineEditorEnabled"
+ label="Edit entities in SQL"
+ description="Edit policies, triggers, and functions in the SQL editor instead of the guided UI."
+ onToggle={handleInlineEditorToggle}
+ />
+ <DashboardToggle
+ form={form}
+ name="queueOperationsEnabled"
+ label="Queue table operations"
+ description="Review and batch table edits in Table Editor before saving them to your database."
+ discussionsUrl="https://github.com/orgs/supabase/discussions/42460"
+ onToggle={handleQueueOperationsToggle}
+ isLast
+ />
+ </Card>
+ </Form_Shadcn_>
+ )
+}
diff --git a/apps/studio/components/interfaces/Account/Preferences/DashboardToggle.tsx b/apps/studio/components/interfaces/Account/Preferences/DashboardToggle.tsx
new file mode 100644
index 00000000000..401d34108bc
--- /dev/null
+++ b/apps/studio/components/interfaces/Account/Preferences/DashboardToggle.tsx
@@ -0,0 +1,70 @@
+import { ExternalLink } from 'lucide-react'
+import Link from 'next/link'
+import type { ReactNode } from 'react'
+import type { FieldValues, Path, UseFormReturn } from 'react-hook-form'
+import { CardContent, FormControl_Shadcn_, FormField_Shadcn_, Switch } from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+
+interface DashboardToggleProps<T extends FieldValues> {
+ form: UseFormReturn<T>
+ name: Path<T>
+ label: string
+ description: ReactNode
+ onToggle: (value: boolean) => void
+ discussionsUrl?: string
+ isLast?: boolean
+}
+
+export function DashboardToggle<T extends FieldValues>({
+ form,
+ name,
+ label,
+ description,
+ onToggle,
+ discussionsUrl,
+ isLast,
+}: DashboardToggleProps<T>) {
+ return (
+ <CardContent className={isLast ? undefined : 'border-b'}>
+ <FormField_Shadcn_
+ control={form.control}
+ name={name}
+ render={({ field }) => (
+ <FormItemLayout
+ layout="flex-row-reverse"
+ label={label}
+ description={
+ <p className="text-balance">
+ {description}
+ {discussionsUrl && (
+ <>
+ {' '}
+ <Link
+ href={discussionsUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="inline-flex items-center gap-x-1 text-foreground-light hover:text-foreground transition"
+ >
+ Give feedback
+ <ExternalLink size={12} strokeWidth={1.5} />
+ </Link>
+ </>
+ )}
+ </p>
+ }
+ >
+ <FormControl_Shadcn_>
+ <Switch
+ checked={field.value}
+ onCheckedChange={(value) => {
+ field.onChange(value)
+ onToggle(value)
+ }}
+ />
+ </FormControl_Shadcn_>
+ </FormItemLayout>
+ )}
+ />
+ </CardContent>
+ )
+}
diff --git a/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx
deleted file mode 100644
index cae4255aef4..00000000000
--- a/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import { zodResolver } from '@hookform/resolvers/zod'
-import { LOCAL_STORAGE_KEYS } from 'common'
-import { useForm } from 'react-hook-form'
-import { Card, CardContent, Form_Shadcn_, FormControl_Shadcn_, FormField_Shadcn_, Switch } from 'ui'
-import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-import {
- PageSection,
- PageSectionContent,
- PageSectionDescription,
- PageSectionMeta,
- PageSectionSummary,
- PageSectionTitle,
-} from 'ui-patterns/PageSection'
-import * as z from 'zod'
-
-import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
-import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-
-const InlineEditorSchema = z.object({
- inlineEditorEnabled: z.boolean(),
-})
-
-export const useIsInlineEditorEnabled = () => {
- const [inlineEditorEnabled] = useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR,
- false
- )
-
- return inlineEditorEnabled ?? false
-}
-
-export const InlineEditorSettings = () => {
- const [inlineEditorEnabled, setInlineEditorEnabled] = useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR,
- false
- )
- const { data: org } = useSelectedOrganizationQuery()
-
- const { mutate: sendEvent } = useSendEventMutation()
-
- const form = useForm<z.infer<typeof InlineEditorSchema>>({
- resolver: zodResolver(InlineEditorSchema),
- values: {
- inlineEditorEnabled: inlineEditorEnabled ?? false,
- },
- })
-
- const handleToggle = (value: boolean) => {
- setInlineEditorEnabled(value)
- form.setValue('inlineEditorEnabled', value)
-
- sendEvent({
- action: 'inline_editor_setting_clicked',
- properties: {
- enabled: value,
- },
- groups: {
- organization: org?.slug,
- },
- })
- }
-
- return (
- <PageSection>
- <PageSectionMeta>
- <PageSectionSummary>
- <PageSectionTitle id="inline-editor">Dashboard</PageSectionTitle>
- <PageSectionDescription>
- Choose your preferred experience when editing policies, triggers, and functions.
- </PageSectionDescription>
- </PageSectionSummary>
- </PageSectionMeta>
- <PageSectionContent>
- <Form_Shadcn_ {...form}>
- <Card>
- <CardContent>
- <FormField_Shadcn_
- control={form.control}
- name="inlineEditorEnabled"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="Edit entities in SQL"
- description="When enabled, view and edit policies, triggers, and functions directly in the SQL editor instead of a more beginner-friendly UI panel. Ideal for those comfortable with SQL."
- >
- <FormControl_Shadcn_>
- <Switch
- checked={field.value}
- onCheckedChange={(value) => {
- field.onChange(value)
- handleToggle(value)
- }}
- />
- </FormControl_Shadcn_>
- </FormItemLayout>
- )}
- />
- </CardContent>
- </Card>
- </Form_Shadcn_>
- </PageSectionContent>
- </PageSection>
- )
-}
diff --git a/apps/studio/components/interfaces/Account/Preferences/useDashboardSettings.ts b/apps/studio/components/interfaces/Account/Preferences/useDashboardSettings.ts
new file mode 100644
index 00000000000..36b37c83c11
--- /dev/null
+++ b/apps/studio/components/interfaces/Account/Preferences/useDashboardSettings.ts
@@ -0,0 +1,35 @@
+import { LOCAL_STORAGE_KEYS } from 'common'
+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
+
+export const useIsInlineEditorSetting = () => {
+ const [inlineEditorEnabled, setInlineEditorEnabled] = useLocalStorageQuery(
+ LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR,
+ false
+ )
+
+ return {
+ inlineEditorEnabled: inlineEditorEnabled ?? false,
+ setInlineEditorEnabled,
+ }
+}
+
+export const useIsQueueOperationsSetting = () => {
+ const [isQueueOperationsEnabled, setIsQueueOperationsEnabled] = useLocalStorageQuery(
+ LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS,
+ false
+ )
+ return {
+ isQueueOperationsEnabled: isQueueOperationsEnabled ?? false,
+ setIsQueueOperationsEnabled,
+ }
+}
+
+export const useIsInlineEditorEnabled = () => {
+ const { inlineEditorEnabled } = useIsInlineEditorSetting()
+ return inlineEditorEnabled ?? false
+}
+
+export const useIsQueueOperationsEnabled = () => {
+ const { isQueueOperationsEnabled } = useIsQueueOperationsSetting()
+ return isQueueOperationsEnabled ?? false
+}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
index 0798fc22072..55017c38630 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
@@ -108,11 +108,6 @@ export const useIsAdvisorRulesEnabled = () => {
return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES]
}
-export const useIsQueueOperationsEnabled = () => {
- const { flags } = useFeaturePreviewContext()
- return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS]
-}
-
export const useIsPlatformWebhooksEnabled = () => {
const { flags } = useFeaturePreviewContext()
const platformWebhooksEnabled = useFlag('platformWebhooks')
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
index b4a89858c12..aab353f7742 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
@@ -30,12 +30,10 @@ import { FloatingMobileToolbarPreview } from './FloatingMobileToolbarPreview'
import { JitDbAccessPreview } from './JitDbAccessPreview'
import { PgDeltaDiffPreview } from './PgDeltaDiffPreview'
import { PlatformWebhooksPreview } from './PlatformWebhooksPreview'
-import { QueueOperationsPreview } from './QueueOperationsPreview'
import { TableFilterBarPreview } from './TableFilterBarPreview'
import { UnifiedLogsPreview } from './UnifiedLogsPreview'
import { FeaturePreview, useFeaturePreviews } from './useFeaturePreviews'
import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
-import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { IS_PLATFORM } from '@/lib/constants'
@@ -47,7 +45,6 @@ const FEATURE_PREVIEW_KEY_TO_CONTENT: {
[LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES]: <AdvisorRulesPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]: <CLSPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]: <UnifiedLogsPreview />,
- [LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS]: <QueueOperationsPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR]: <TableFilterBarPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS]: <PlatformWebhooksPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS]: <JitDbAccessPreview />,
@@ -67,12 +64,6 @@ export const FeaturePreviewModal = () => {
const featurePreviewContext = useFeaturePreviewContext()
const { mutate: sendEvent } = useSendEventMutation()
- const [isDismissedTableQueueOperations, setIsDismissedTableQueueOperations] =
- useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.TABLE_EDITOR_QUEUE_OPERATIONS_BANNER_DISMISSED(ref ?? ''),
- false
- )
-
const { flags, onUpdateFlag } = featurePreviewContext
const allFeaturePreviews = (
IS_PLATFORM ? featurePreviews : featurePreviews.filter((x) => !x.isPlatformOnly)
@@ -91,13 +82,6 @@ export const FeaturePreviewModal = () => {
properties: { feature: selectedFeature.key },
groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },
})
-
- if (
- selectedFeature.key === LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS &&
- !isDismissedTableQueueOperations
- ) {
- setIsDismissedTableQueueOperations(true)
- }
}
return (
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/QueueOperationsPreview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/QueueOperationsPreview.tsx
deleted file mode 100644
index 7b748c8a36c..00000000000
--- a/apps/studio/components/interfaces/App/FeaturePreview/QueueOperationsPreview.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { useParams } from 'common'
-import Image from 'next/image'
-
-import { InlineLink } from '@/components/ui/InlineLink'
-import { BASE_PATH } from '@/lib/constants'
-
-export const QueueOperationsPreview = () => {
- const { ref = '_' } = useParams()
-
- return (
- <div className="flex flex-col gap-2">
- <p className="text-foreground-light text-sm mb-4">
- Queue your table edits in the{' '}
- <InlineLink href={`/project/${ref}/editor`}>Table Editor</InlineLink> and review all pending
- changes before saving them to your database. This gives you more control over when changes
- are committed, allowing you to batch multiple edits and review them together.
- </p>
- <Image
- src={`${BASE_PATH}/img/previews/queue-operations-table-preview.png`}
- width={1296}
- height={900}
- alt="queue-operations-preview"
- className="rounded border"
- />
- <div className="space-y-2 !mt-4">
- <p className="text-sm">Enabling this preview will:</p>
- <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">
- <li>Queue cell edits in the Table Editor instead of saving them immediately</li>
- <li>Show a panel to review all pending changes before committing them</li>
- <li>Allow you to cancel individual changes or save all changes at once</li>
- </ul>
- </div>
- </div>
- )
-}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
index f0e2fa61022..042a99567e4 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
+++ b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
@@ -95,15 +95,6 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
isPlatformOnly: false,
isDefaultOptIn: false,
},
- {
- key: LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS,
- name: 'Queue table operations',
- discussionsUrl: 'https://github.com/orgs/supabase/discussions/42460',
- enabled: true,
- isNew: true,
- isPlatformOnly: false,
- isDefaultOptIn: false,
- },
{
key: LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR,
name: 'New Table Filter Bar',
diff --git a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx
index 9a14939b4c1..75a0ed06db9 100644
--- a/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx
+++ b/apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx
@@ -11,7 +11,7 @@ import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import { ProtectedSchemaWarning } from '../../ProtectedSchemaWarning'
import FunctionList from './FunctionList'
-import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/InlineEditorSettings'
+import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { CreateFunction } from '@/components/interfaces/Database/Functions/CreateFunction'
import {
ReportsSelectFilter,
diff --git a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx
index 3e88837df98..9c4b333f189 100644
--- a/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx
+++ b/apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggersList.tsx
@@ -11,7 +11,7 @@ import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import { CreateTriggerButtons } from './CreateTriggerButtons'
import { TriggerList } from './TriggerList'
import { generateTriggerCreateSQL } from './TriggerList.utils'
-import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/InlineEditorSettings'
+import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { ProtectedSchemaWarning } from '@/components/interfaces/Database/ProtectedSchemaWarning'
import { TriggerSheet } from '@/components/interfaces/Database/Triggers/TriggerSheet'
import {
diff --git a/apps/studio/components/interfaces/LocalDropdown.test.tsx b/apps/studio/components/interfaces/LocalDropdown.test.tsx
new file mode 100644
index 00000000000..2656b40098d
--- /dev/null
+++ b/apps/studio/components/interfaces/LocalDropdown.test.tsx
@@ -0,0 +1,153 @@
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import type { MouseEventHandler, ReactElement, ReactNode } from 'react'
+import { describe, expect, it, vi } from 'vitest'
+
+import { LocalDropdown } from './LocalDropdown'
+
+const { mockRouter, mockSetTheme, mockSetLastRoute, mockToggleFeaturePreviewModal } = vi.hoisted(
+ () => ({
+ mockRouter: {
+ pathname: '/project/[ref]/editor',
+ asPath: '/project/default/editor',
+ },
+ mockSetTheme: vi.fn(),
+ mockSetLastRoute: vi.fn(),
+ mockToggleFeaturePreviewModal: vi.fn(),
+ })
+)
+
+vi.mock('next/router', () => ({
+ useRouter: () => mockRouter,
+}))
+
+vi.mock('next/link', () => ({
+ default: ({
+ href,
+ children,
+ onClick,
+ }: {
+ href: string
+ children: ReactNode
+ onClick?: MouseEventHandler<HTMLAnchorElement>
+ }) => (
+ <a href={href} onClick={onClick}>
+ {children}
+ </a>
+ ),
+}))
+
+vi.mock('next-themes', () => ({
+ useTheme: () => ({
+ theme: 'dark',
+ setTheme: mockSetTheme,
+ }),
+}))
+
+vi.mock('state/app-state', () => ({
+ useAppStateSnapshot: () => ({
+ setLastRouteBeforeVisitingAccountPage: mockSetLastRoute,
+ }),
+}))
+
+vi.mock('components/ui/ProfileImage', () => ({
+ ProfileImage: () => <div>Avatar</div>,
+}))
+
+vi.mock('./App/FeaturePreview/FeaturePreviewContext', () => ({
+ useFeaturePreviewModal: () => ({
+ toggleFeaturePreviewModal: mockToggleFeaturePreviewModal,
+ }),
+}))
+
+vi.mock('ui', async () => {
+ const React = await import('react')
+
+ return {
+ Button: ({
+ children,
+ ...props
+ }: React.ButtonHTMLAttributes<HTMLButtonElement> & { children?: ReactNode }) => (
+ <button {...props}>{children}</button>
+ ),
+ cn: (...classes: Array<string | false | null | undefined>) => classes.filter(Boolean).join(' '),
+ DropdownMenu: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ DropdownMenuTrigger: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ DropdownMenuContent: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ DropdownMenuGroup: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ DropdownMenuItem: ({
+ children,
+ asChild,
+ onClick,
+ onSelect,
+ }: {
+ children: ReactNode
+ asChild?: boolean
+ onClick?: () => void
+ onSelect?: () => void
+ }) =>
+ asChild ? (
+ <div>{children}</div>
+ ) : (
+ <button
+ onClick={() => {
+ onClick?.()
+ onSelect?.()
+ }}
+ >
+ {children}
+ </button>
+ ),
+ DropdownMenuLabel: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ DropdownMenuSeparator: () => <hr />,
+ DropdownMenuRadioGroup: ({
+ children,
+ onValueChange,
+ }: {
+ children: ReactNode
+ onValueChange: (value: string) => void
+ }) => (
+ <div>
+ {React.Children.map(children, (child: ReactNode) =>
+ React.isValidElement<{ value: string; onClick?: () => void }>(child)
+ ? React.cloneElement(child, {
+ onClick: () => onValueChange(child.props.value),
+ })
+ : (child as ReactElement)
+ )}
+ </div>
+ ),
+ DropdownMenuRadioItem: ({
+ children,
+ onClick,
+ }: {
+ children: ReactNode
+ onClick?: () => void
+ }) => <button onClick={onClick}>{children}</button>,
+ singleThemes: [
+ { value: 'dark', name: 'Dark' },
+ { value: 'light', name: 'Light' },
+ ],
+ }
+})
+
+describe('LocalDropdown', () => {
+ it('shows Preferences, removes Command menu, and keeps theme controls wired', async () => {
+ const user = userEvent.setup()
+
+ render(<LocalDropdown />)
+
+ expect(screen.getByText('Preferences')).toBeInTheDocument()
+ expect(screen.queryByText('Command menu')).not.toBeInTheDocument()
+ expect(screen.getByText('Theme')).toBeInTheDocument()
+
+ await user.click(screen.getByText('Preferences'))
+ expect(mockSetLastRoute).toHaveBeenCalledWith('/project/default/editor')
+
+ await user.click(screen.getByText('Feature previews'))
+ expect(mockToggleFeaturePreviewModal).toHaveBeenCalledWith(true)
+
+ await user.click(screen.getByText('Light'))
+ expect(mockSetTheme).toHaveBeenCalledWith('light')
+ })
+})
diff --git a/apps/studio/components/interfaces/LocalDropdown.tsx b/apps/studio/components/interfaces/LocalDropdown.tsx
index 08384f772ad..f37144893c2 100644
--- a/apps/studio/components/interfaces/LocalDropdown.tsx
+++ b/apps/studio/components/interfaces/LocalDropdown.tsx
@@ -1,5 +1,8 @@
-import { Command, FlaskConical } from 'lucide-react'
+import { FlaskConical, Settings } from 'lucide-react'
import { useTheme } from 'next-themes'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { useAppStateSnapshot } from 'state/app-state'
import {
Button,
cn,
@@ -15,7 +18,6 @@ import {
singleThemes,
Theme,
} from 'ui'
-import { useSetCommandMenuOpen } from 'ui-patterns'
import { ButtonTooltip } from '../ui/ButtonTooltip'
import { useFeaturePreviewModal } from './App/FeaturePreview/FeaturePreviewContext'
@@ -28,8 +30,9 @@ export const LocalDropdown = ({
triggerClassName?: string
contentClassName?: string
}) => {
+ const router = useRouter()
const { theme, setTheme } = useTheme()
- const setCommandMenuOpen = useSetCommandMenuOpen()
+ const appStateSnapshot = useAppStateSnapshot()
const { toggleFeaturePreviewModal } = useFeaturePreviewModal()
return (
@@ -44,6 +47,19 @@ export const LocalDropdown = ({
</ButtonTooltip>
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className={cn('w-44', contentClassName)}>
+ <DropdownMenuItem className="flex gap-2 cursor-pointer" asChild>
+ <Link
+ href="/account/me"
+ onClick={() => {
+ if (router.pathname !== '/account/me') {
+ appStateSnapshot.setLastRouteBeforeVisitingAccountPage(router.asPath)
+ }
+ }}
+ >
+ <Settings size={14} strokeWidth={1.5} className="text-foreground-lighter" />
+ Preferences
+ </Link>
+ </DropdownMenuItem>
<DropdownMenuItem
className="flex gap-2 cursor-pointer"
onClick={() => toggleFeaturePreviewModal(true)}
@@ -52,13 +68,6 @@ export const LocalDropdown = ({
<FlaskConical size={14} strokeWidth={1.5} className="text-foreground-lighter" />
Feature previews
</DropdownMenuItem>
- <DropdownMenuItem
- className="flex gap-2 cursor-pointer"
- onClick={() => setCommandMenuOpen(true)}
- >
- <Command size={14} strokeWidth={1.5} className="text-foreground-lighter" />
- Command menu
- </DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuLabel>Theme</DropdownMenuLabel>
diff --git a/apps/studio/components/interfaces/Settings/General/DashboardPreferences.tsx b/apps/studio/components/interfaces/Settings/General/DashboardPreferences.tsx
index 050d49db8ab..854e8b864db 100644
--- a/apps/studio/components/interfaces/Settings/General/DashboardPreferences.tsx
+++ b/apps/studio/components/interfaces/Settings/General/DashboardPreferences.tsx
@@ -23,7 +23,13 @@ import {
} from 'ui'
import { Admonition } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
-import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
import ShimmeringLoader, { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
import * as z from 'zod'
@@ -80,11 +86,17 @@ export const DashboardPreferences = () => {
return (
<PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle id="queries">Queries</PageSectionTitle>
+ </PageSectionSummary>
+ </PageSectionMeta>
+
<PageSectionContent className="flex flex-col gap-y-4">
{/* [Joshen] Ideally we're able to persist this for all users in the project, but will need support in our middleware */}
<Admonition
type="note"
- title="Preferences currently do not affect other members of this project"
+ title="These preferences control only your experience in the dashboard. Other members of this project will not be affected"
/>
{isLoading ? (
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
index c6417113447..3914dd2f73a 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.tsx
@@ -18,7 +18,7 @@ import {
validateFields,
} from './RowEditor.utils'
import { TextEditor } from './TextEditor'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { useForeignKeyConstraintsQuery } from '@/data/database/foreign-key-constraints-query'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import type { Dictionary } from '@/types'
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 095693767bb..ea6d7f04c43 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -35,7 +35,7 @@ import {
import { TableEditor } from './TableEditor/TableEditor'
import type { ImportContent } from './TableEditor/TableEditor.types'
import { useTableRowOperations } from '@/components/grid/hooks/useTableRowOperations'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { type GeneratedPolicy } from '@/components/interfaces/Auth/Policies/Policies.utils'
import { DiscardChangesConfirmationDialog } from '@/components/ui-patterns/Dialogs/DiscardChangesConfirmationDialog'
import { databasePoliciesKeys } from '@/data/database-policies/keys'
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.selfhosted.test.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.selfhosted.test.tsx
new file mode 100644
index 00000000000..3f00bde5622
--- /dev/null
+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.selfhosted.test.tsx
@@ -0,0 +1,151 @@
+import { render, screen, waitFor } from '@testing-library/react'
+import type { PropsWithChildren, ReactNode } from 'react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import AccountLayout from './AccountLayout'
+
+const { mockRouter, mockRegisterOpenMenu, mockSetMobileSheetContent } = vi.hoisted(() => ({
+ mockRouter: {
+ pathname: '/account/me',
+ push: vi.fn(),
+ },
+ mockRegisterOpenMenu: vi.fn(),
+ mockSetMobileSheetContent: vi.fn(),
+}))
+
+vi.mock('lib/constants', async () => {
+ const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
+ return {
+ ...actual,
+ IS_PLATFORM: false,
+ }
+})
+
+vi.mock('next/router', () => ({
+ useRouter: () => mockRouter,
+}))
+
+vi.mock('next/head', async () => {
+ const React = await import('react')
+
+ const Head = ({ children }: { children?: ReactNode }) => {
+ React.useEffect(() => {
+ const titleElement = React.Children.toArray(children).find(
+ (child) => React.isValidElement(child) && child.type === 'title'
+ )
+
+ if (!React.isValidElement(titleElement)) return
+
+ const titleText = React.Children.toArray(titleElement.props.children).join('')
+ document.title = titleText
+ }, [children])
+
+ return null
+ }
+
+ return { default: Head }
+})
+
+vi.mock('hooks/custom-content/useCustomContent', () => ({
+ useCustomContent: () => ({ appTitle: 'Supabase' }),
+}))
+
+vi.mock('hooks/misc/useIsFeatureEnabled', () => ({
+ useIsFeatureEnabled: () => false,
+}))
+
+vi.mock('hooks/misc/useLocalStorage', () => ({
+ useLocalStorageQuery: () => [''],
+}))
+
+vi.mock('hooks/misc/withAuth', () => ({
+ withAuth: <T,>(Component: T) => Component,
+}))
+
+vi.mock('state/app-state', () => ({
+ useAppStateSnapshot: () => ({
+ lastRouteBeforeVisitingAccountPage: '',
+ }),
+}))
+
+vi.mock('../Navigation/NavigationBar/MobileSheetContext', () => ({
+ useMobileSheet: () => ({
+ setContent: mockSetMobileSheetContent,
+ registerOpenMenu: (callback: () => void) => {
+ mockRegisterOpenMenu(callback)
+ return () => {}
+ },
+ }),
+}))
+
+vi.mock('./WithSidebar', () => ({
+ WithSidebar: ({
+ sections,
+ children,
+ }: PropsWithChildren<{
+ sections: Array<{
+ key: string
+ heading?: string
+ links: Array<{ key: string; label: string }>
+ }>
+ }>) => (
+ <div>
+ <nav>
+ {sections.map((section) => (
+ <div key={section.key}>
+ {section.heading ? <span>{section.heading}</span> : null}
+ {section.links.map((link) => (
+ <span key={link.key}>{link.label}</span>
+ ))}
+ </div>
+ ))}
+ </nav>
+ {children}
+ </div>
+ ),
+}))
+
+vi.mock('ui', () => ({
+ cn: (...classes: Array<string | false | null | undefined>) => classes.filter(Boolean).join(' '),
+}))
+
+describe('AccountLayout (self-hosted)', () => {
+ beforeEach(() => {
+ mockRouter.pathname = '/account/me'
+ mockRouter.push.mockReset()
+ mockRegisterOpenMenu.mockReset()
+ mockSetMobileSheetContent.mockReset()
+ document.title = ''
+ })
+
+ it('keeps /account/me available and shows only the Preferences link', async () => {
+ render(
+ <AccountLayout title="Preferences">
+ <div>Preferences page</div>
+ </AccountLayout>
+ )
+
+ await waitFor(() => {
+ expect(document.title).toBe('Preferences | Supabase')
+ })
+
+ expect(screen.getByText('Preferences')).toBeInTheDocument()
+ expect(screen.queryByText('Access Tokens')).not.toBeInTheDocument()
+ expect(screen.queryByText('Account Settings')).not.toBeInTheDocument()
+ expect(mockRouter.push).not.toHaveBeenCalled()
+ })
+
+ it('redirects unsupported account routes back to the project dashboard', async () => {
+ mockRouter.pathname = '/account/tokens'
+
+ render(
+ <AccountLayout title="Preferences">
+ <div>Unsupported</div>
+ </AccountLayout>
+ )
+
+ await waitFor(() => {
+ expect(mockRouter.push).toHaveBeenCalledWith('/project/default')
+ })
+ })
+})
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
index e4418c68acf..32fdb76ac20 100644
--- a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -24,11 +24,13 @@ const AccountLayout = ({ children, title }: PropsWithChildren<AccountLayoutProps
const router = useRouter()
const appSnap = useAppStateSnapshot()
const { setContent: setMobileSheetContent, registerOpenMenu } = useMobileSheet()
+ const currentPath = router.pathname
const showSecuritySettings = useIsFeatureEnabled('account:show_security_settings')
const { appTitle } = useCustomContent(['app:title'])
const brandTitle = appTitle || 'Supabase'
+ const surfaceLabel = IS_PLATFORM ? 'Account' : 'Preferences'
const [lastVisitedOrganization] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,
@@ -38,60 +40,77 @@ const AccountLayout = ({ children, title }: PropsWithChildren<AccountLayoutProps
const backToDashboardURL =
appSnap.lastRouteBeforeVisitingAccountPage.length > 0
? appSnap.lastRouteBeforeVisitingAccountPage
- : !!lastVisitedOrganization
+ : IS_PLATFORM && !!lastVisitedOrganization
? `/org/${lastVisitedOrganization}`
- : '/organizations'
+ : IS_PLATFORM
+ ? '/organizations'
+ : '/project/default'
- const currentPath = router.pathname
const pageTitle = buildStudioPageTitle({
section: title,
- surface: 'Account',
+ surface: surfaceLabel,
brand: brandTitle,
})
const sections = useMemo(
- () => [
- {
- key: 'account-settings',
- heading: 'Account Settings',
- links: [
- {
- key: 'preferences',
- label: 'Preferences',
- href: '/account/me',
- isActive: currentPath === '/account/me',
- },
- {
- key: 'access-tokens',
- label: 'Access Tokens',
- href: '/account/tokens',
- isActive: currentPath === '/account/tokens' || currentPath === '/account/tokens/scoped',
- },
- ...(showSecuritySettings
- ? [
+ () =>
+ !IS_PLATFORM
+ ? [
+ {
+ key: 'preferences',
+ links: [
+ {
+ key: 'preferences',
+ label: 'Preferences',
+ href: '/account/me',
+ isActive: currentPath === '/account/me',
+ },
+ ],
+ },
+ ]
+ : [
+ {
+ key: 'account-settings',
+ heading: 'Account Settings',
+ links: [
+ {
+ key: 'preferences',
+ label: 'Preferences',
+ href: '/account/me',
+ isActive: currentPath === '/account/me',
+ },
+ {
+ key: 'access-tokens',
+ label: 'Access Tokens',
+ href: '/account/tokens',
+ isActive:
+ currentPath === '/account/tokens' || currentPath === '/account/tokens/scoped',
+ },
+ ...(showSecuritySettings
+ ? [
+ {
+ key: 'security',
+ label: 'Security',
+ href: '/account/security',
+ isActive: currentPath === '/account/security',
+ },
+ ]
+ : []),
+ ],
+ },
+ {
+ key: 'logs',
+ heading: 'Logs',
+ links: [
{
- key: 'security',
- label: 'Security',
- href: '/account/security',
- isActive: currentPath === '/account/security',
+ key: 'audit-logs',
+ label: 'Audit Logs',
+ href: '/account/audit',
+ isActive: currentPath === '/account/audit',
},
- ]
- : []),
- ],
- },
- {
- key: 'logs',
- heading: 'Logs',
- links: [
- {
- key: 'audit-logs',
- label: 'Audit Logs',
- href: '/account/audit',
- isActive: currentPath === '/account/audit',
- },
- ],
- },
- ],
+ ],
+ },
+ ],
[currentPath, showSecuritySettings]
)
@@ -105,10 +124,10 @@ const AccountLayout = ({ children, title }: PropsWithChildren<AccountLayoutProps
}, [registerOpenMenu, setMobileSheetContent, sections])
useEffect(() => {
- if (!IS_PLATFORM) {
+ if (!IS_PLATFORM && currentPath !== '/account/me') {
router.push('/project/default')
}
- }, [router])
+ }, [currentPath, router])
return (
<>
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsx
index 42b9c00aff7..b761a4b98c1 100644
--- a/apps/studio/components/layouts/DefaultLayout.tsx
+++ b/apps/studio/components/layouts/DefaultLayout.tsx
@@ -16,6 +16,7 @@ import { AppBannerWrapper } from '@/components/interfaces/App/AppBannerWrapper'
import { Sidebar } from '@/components/interfaces/Sidebar'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useCheckLatestDeploy } from '@/hooks/use-check-latest-deploy'
+import { IS_PLATFORM } from '@/lib/constants'
import { useAppStateSnapshot } from '@/state/app-state'
export interface DefaultLayoutProps {
@@ -50,9 +51,11 @@ export const DefaultLayout = ({
const backToDashboardURL = router.pathname.startsWith('/account')
? appSnap.lastRouteBeforeVisitingAccountPage.length > 0
? appSnap.lastRouteBeforeVisitingAccountPage
- : !!lastVisitedOrganization
+ : IS_PLATFORM && !!lastVisitedOrganization
? `/org/${lastVisitedOrganization}`
- : '/organizations'
+ : IS_PLATFORM
+ ? '/organizations'
+ : '/project/default'
: undefined
useCheckLatestDeploy()
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx
new file mode 100644
index 00000000000..ff16183f526
--- /dev/null
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.selfhosted.test.tsx
@@ -0,0 +1,60 @@
+import { renderHook } from '@testing-library/react'
+import { describe, expect, it, vi } from 'vitest'
+
+import { useGenerateSettingsMenu } from './SettingsMenu.utils'
+
+vi.mock('lib/constants', async () => {
+ const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
+ return {
+ ...actual,
+ IS_PLATFORM: false,
+ }
+})
+
+vi.mock('common', () => ({
+ useFlag: vi.fn().mockReturnValue(false),
+ useParams: vi.fn().mockReturnValue({ ref: 'project-ref' }),
+}))
+
+vi.mock('@/hooks/misc/useSelectedOrganization', () => ({
+ useSelectedOrganizationQuery: vi.fn().mockReturnValue({ data: { slug: 'my-org' } }),
+}))
+
+vi.mock('@/hooks/misc/useSelectedProject', () => ({
+ useSelectedProjectQuery: vi.fn().mockReturnValue({ data: { status: 'ACTIVE_HEALTHY' } }),
+}))
+
+vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
+ useIsFeatureEnabled: vi
+ .fn()
+ .mockReturnValue({ projectSettingsLegacyJwtKeys: false, billingAll: true }),
+}))
+
+vi.mock('@/components/interfaces/App/FeaturePreview/FeaturePreviewContext', () => ({
+ useIsPlatformWebhooksEnabled: vi.fn().mockReturnValue(false),
+}))
+
+describe('useGenerateSettingsMenu (self-hosted)', () => {
+ it('includes Log Drains in self-hosted mode', () => {
+ const { result } = renderHook(() => useGenerateSettingsMenu())
+ const configGroup = result.current.find((group) => group.title === 'Configuration')
+
+ expect(configGroup?.items.some((item) => item.key === 'log-drains')).toBe(true)
+ })
+
+ it('does not include dashboard settings in self-hosted mode', () => {
+ const { result } = renderHook(() => useGenerateSettingsMenu())
+ const configGroup = result.current.find((group) => group.title === 'Configuration')
+
+ expect(configGroup?.items.some((item) => item.key === 'dashboard')).toBe(false)
+ })
+
+ it('does not include platform-only settings in self-hosted mode', () => {
+ const { result } = renderHook(() => useGenerateSettingsMenu())
+ const configGroup = result.current.find((group) => group.title === 'Configuration')
+
+ expect(configGroup?.items.some((item) => item.key === 'general')).toBe(false)
+ expect(configGroup?.items.some((item) => item.key === 'api-keys')).toBe(false)
+ expect(configGroup?.items.some((item) => item.key === 'infrastructure')).toBe(false)
+ })
+})
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
index c5c4cfd3786..6d711333cb3 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.test.tsx
@@ -67,26 +67,25 @@ describe('useGenerateSettingsMenu', () => {
expect(hasMembers).toBe(false)
})
- it('includes dashboard preferences when flag is enabled', () => {
+ it('includes dashboard in configuration when flag is enabled', () => {
vi.mocked(useFlag).mockReturnValue(true)
const { result } = renderHook(() => useGenerateSettingsMenu())
- const preferencesGroup = result.current.find((group) => group.title === 'Preferences')
- const hasDashboardPreferences = preferencesGroup?.items.some(
- (item) =>
- item.name === 'Dashboard preferences' &&
- item.url === '/project/project-ref/settings/preferences'
+ const configurationGroup = result.current.find((group) => group.title === 'Configuration')
+ const hasDashboardPreferences = configurationGroup?.items.some(
+ (item) => item.name === 'Dashboard' && item.url === '/project/project-ref/settings/dashboard'
)
expect(hasDashboardPreferences).toBe(true)
+ expect(result.current.find((group) => group.title === 'Preferences')).toBeUndefined()
})
- it('hides dashboard preferences when flag is disabled', () => {
+ it('hides dashboard in configuration when flag is disabled', () => {
vi.mocked(useFlag).mockReturnValue(false)
const { result } = renderHook(() => useGenerateSettingsMenu())
- const preferencesGroup = result.current.find((group) => group.title === 'Preferences')
+ const configurationGroup = result.current.find((group) => group.title === 'Configuration')
- expect(preferencesGroup).toBeUndefined()
+ expect(configurationGroup?.items.some((item) => item.name === 'Dashboard')).toBe(false)
})
})
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index 03b1da18cdb..0a15a1364ef 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -11,8 +11,8 @@ export const useGenerateSettingsMenu = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
-
const showDashboardPreferences = useFlag('dashboardPreferences')
+
const platformWebhooksEnabled = useIsPlatformWebhooksEnabled()
const { projectSettingsLegacyJwtKeys: legacyJwtKeysEnabled, billingAll: billingEnabled } =
@@ -110,23 +110,18 @@ export const useGenerateSettingsMenu = () => {
url: `/project/${ref}/settings/addons`,
items: [],
},
- ],
- },
- ...(IS_PLATFORM && showDashboardPreferences
- ? [
- {
- title: 'Preferences',
- items: [
+ ...(showDashboardPreferences
+ ? [
{
- name: 'Dashboard preferences',
- key: 'preferences',
- url: `/project/${ref}/settings/preferences`,
+ name: 'Dashboard',
+ key: 'dashboard',
+ url: `/project/${ref}/settings/dashboard`,
items: [],
},
- ],
- },
- ]
- : []),
+ ]
+ : []),
+ ],
+ },
{
title: 'Integrations',
items: [
diff --git a/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx b/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx
index 5fef71bcf11..882aa8ad5e8 100644
--- a/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx
+++ b/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx
@@ -4,7 +4,7 @@ import { PropsWithChildren, useEffect } from 'react'
import { ProjectLayoutWithAuth } from '../ProjectLayout'
import { SaveQueueActionBar } from '@/components/grid/components/footer/operations/SaveQueueActionBar'
-import { useIsQueueOperationsEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { BannerTableEditorQueueOperations } from '@/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations'
import { useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'
import NoPermission from '@/components/ui/NoPermission'
diff --git a/apps/studio/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations.tsx b/apps/studio/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations.tsx
index 941e6427f00..0c7fee8be57 100644
--- a/apps/studio/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations.tsx
+++ b/apps/studio/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations.tsx
@@ -1,18 +1,17 @@
import { LOCAL_STORAGE_KEYS } from 'common'
import { useParams } from 'common/hooks'
+import Link from 'next/link'
import { Badge, Button, Card, CardContent, CardHeader } from 'ui'
import { BannerCard } from '../BannerCard'
import { useBannerStack } from '../BannerStackProvider'
-import {
- useFeaturePreviewModal,
- useIsQueueOperationsEnabled,
-} from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
+const DASHBOARD_SETTINGS_URL = '/account/me#dashboard'
+
export const BannerTableEditorQueueOperations = () => {
const { ref } = useParams()
- const { selectFeaturePreview } = useFeaturePreviewModal()
const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
const { dismissBanner } = useBannerStack()
@@ -31,7 +30,7 @@ export const BannerTableEditorQueueOperations = () => {
<div className="flex flex-col gap-y-4">
<div className="flex flex-col gap-y-2 items-start">
<Badge variant="success" className="-ml-0.5 uppercase inline-flex items-center mb-2">
- Preview
+ New
</Badge>
<Card className="text-xs w-full">
<CardHeader className="flex flex-row gap-2 px-2 py-2">
@@ -62,12 +61,10 @@ export const BannerTableEditorQueueOperations = () => {
Batch multiple row edits and review them before saving to your database
</p>
</div>
- <Button
- type="default"
- className="w-min"
- onClick={() => selectFeaturePreview(LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS)}
- >
- {isQueueOperationsEnabled ? 'View' : 'Enable'} feature preview
+ <Button asChild type="default" className="w-min">
+ <Link href={DASHBOARD_SETTINGS_URL}>
+ {isQueueOperationsEnabled ? 'View' : 'Enable in'} preferences
+ </Link>
</Button>
</div>
</BannerCard>
diff --git a/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx b/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx
index ec248dcd497..7f402dad624 100644
--- a/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx
+++ b/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx
@@ -12,7 +12,7 @@ import {
} from 'ui'
import { ButtonTooltip } from '../ButtonTooltip'
-import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/InlineEditorSettings'
+import { useIsInlineEditorEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import useNewQuery from '@/components/interfaces/SQLEditor/hooks'
import { DiffType } from '@/components/interfaces/SQLEditor/SQLEditor.types'
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
diff --git a/apps/studio/lib/local-storage.test.ts b/apps/studio/lib/local-storage.test.ts
new file mode 100644
index 00000000000..0a0bb58bcad
--- /dev/null
+++ b/apps/studio/lib/local-storage.test.ts
@@ -0,0 +1,16 @@
+import { clearLocalStorage, LOCAL_STORAGE_KEYS } from 'common'
+import { describe, expect, it } from 'vitest'
+
+describe('clearLocalStorage', () => {
+ it('preserves queue operations preferences while removing non-allowlisted keys', () => {
+ localStorage.clear()
+
+ localStorage.setItem(LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS, 'true')
+ localStorage.setItem('not-allowlisted', 'remove-me')
+
+ clearLocalStorage()
+
+ expect(localStorage.getItem(LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS)).toBe('true')
+ expect(localStorage.getItem('not-allowlisted')).toBeNull()
+ })
+})
diff --git a/apps/studio/pages/account/me.tsx b/apps/studio/pages/account/me.tsx
index 74f9f5d31e4..674c44182e8 100644
--- a/apps/studio/pages/account/me.tsx
+++ b/apps/studio/pages/account/me.tsx
@@ -2,8 +2,8 @@ import { AccountConnections } from 'components/interfaces/Account/Preferences/Ac
import { AccountDeletion } from 'components/interfaces/Account/Preferences/AccountDeletion'
import { AccountIdentities } from 'components/interfaces/Account/Preferences/AccountIdentities'
import { AnalyticsSettings } from 'components/interfaces/Account/Preferences/AnalyticsSettings'
+import { DashboardSettings } from 'components/interfaces/Account/Preferences/DashboardSettings'
import { HotkeySettings } from 'components/interfaces/Account/Preferences/HotkeySettings'
-import { InlineEditorSettings } from 'components/interfaces/Account/Preferences/InlineEditorSettings'
import { ProfileInformation } from 'components/interfaces/Account/Preferences/ProfileInformation'
import { ThemeSettings } from 'components/interfaces/Account/Preferences/ThemeSettings'
import AccountLayout from 'components/layouts/AccountLayout/AccountLayout'
@@ -11,6 +11,7 @@ import { AppLayout } from 'components/layouts/AppLayout/AppLayout'
import { DefaultLayout } from 'components/layouts/DefaultLayout'
import { AlertError } from 'components/ui/AlertError'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
+import { IS_PLATFORM } from 'lib/constants'
import { useProfile } from 'lib/profile'
import type { NextPageWithLayout } from 'types'
import { Card, CardContent } from 'ui'
@@ -25,12 +26,12 @@ import {
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
const User: NextPageWithLayout = () => {
- return <ProfileCard />
+ return IS_PLATFORM ? <PlatformPreferences /> : <SelfHostedPreferences />
}
User.getLayout = (page) => (
<AppLayout>
- <DefaultLayout headerTitle="Account">
+ <DefaultLayout headerTitle={IS_PLATFORM ? 'Account' : 'Preferences'}>
<AccountLayout title="Preferences">{page}</AccountLayout>
</DefaultLayout>
</AppLayout>
@@ -38,7 +39,18 @@ User.getLayout = (page) => (
export default User
-const ProfileCard = () => {
+const PreferencesPageHeader = ({ description }: { description: string }) => (
+ <PageHeader size="small">
+ <PageHeaderMeta>
+ <PageHeaderSummary>
+ <PageHeaderTitle>Preferences</PageHeaderTitle>
+ <PageHeaderDescription>{description}</PageHeaderDescription>
+ </PageHeaderSummary>
+ </PageHeaderMeta>
+ </PageHeader>
+)
+
+const PlatformPreferences = () => {
const { profileShowInformation, profileShowAnalyticsAndMarketing, profileShowAccountDeletion } =
useIsFeatureEnabled([
'profile:show_information',
@@ -49,16 +61,7 @@ const ProfileCard = () => {
return (
<>
- <PageHeader size="small">
- <PageHeaderMeta>
- <PageHeaderSummary>
- <PageHeaderTitle>Preferences</PageHeaderTitle>
- <PageHeaderDescription>
- Manage your account profile, connections, and dashboard experience.
- </PageHeaderDescription>
- </PageHeaderSummary>
- </PageHeaderMeta>
- </PageHeader>
+ <PreferencesPageHeader description="Manage your account profile, connections, and dashboard experience." />
<PageContainer size="small">
{isLoading && (
<Card>
@@ -89,7 +92,7 @@ const ProfileCard = () => {
<HotkeySettings />
- <InlineEditorSettings />
+ <DashboardSettings />
{profileShowAnalyticsAndMarketing && <AnalyticsSettings />}
@@ -98,3 +101,18 @@ const ProfileCard = () => {
</>
)
}
+
+const SelfHostedPreferences = () => {
+ return (
+ <>
+ <PreferencesPageHeader description="Manage how the dashboard looks and behaves on this browser and device." />
+ <PageContainer size="small">
+ <ThemeSettings />
+
+ <HotkeySettings />
+
+ <DashboardSettings />
+ </PageContainer>
+ </>
+ )
+}
diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsx
index 3ba6e76f7dd..722ac009564 100644
--- a/apps/studio/pages/project/[ref]/auth/policies.tsx
+++ b/apps/studio/pages/project/[ref]/auth/policies.tsx
@@ -1,7 +1,7 @@
import type { PostgresPolicy, PostgresTable } from '@supabase/postgres-meta'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
-import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/InlineEditorSettings'
+import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/useDashboardSettings'
import { Policies } from 'components/interfaces/Auth/Policies/Policies'
import { PoliciesDataProvider } from 'components/interfaces/Auth/Policies/PoliciesDataContext'
import { getGeneralPolicyTemplates } from 'components/interfaces/Auth/Policies/PolicyEditorModal/PolicyEditorModal.constants'
diff --git a/apps/studio/pages/project/[ref]/settings/preferences.tsx b/apps/studio/pages/project/[ref]/settings/dashboard.tsx
similarity index 58%
rename from apps/studio/pages/project/[ref]/settings/preferences.tsx
rename to apps/studio/pages/project/[ref]/settings/dashboard.tsx
index 08ecba7527d..374751f5aad 100644
--- a/apps/studio/pages/project/[ref]/settings/preferences.tsx
+++ b/apps/studio/pages/project/[ref]/settings/dashboard.tsx
@@ -1,5 +1,9 @@
+import { useFlag } from 'common'
import DefaultLayout from 'components/layouts/DefaultLayout'
import SettingsLayout from 'components/layouts/ProjectSettingsLayout/SettingsLayout'
+import { IS_PLATFORM } from 'lib/constants'
+import { useRouter } from 'next/router'
+import { useEffect } from 'react'
import type { NextPageWithLayout } from 'types'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
@@ -13,21 +17,31 @@ import {
import { DashboardPreferences } from '@/components/interfaces/Settings/General/DashboardPreferences'
const Preferences: NextPageWithLayout = () => {
+ const router = useRouter()
+ // [Joshen] Using this flag to determine whether to show query preferences or not
+ const showQueryPreferences = useFlag('dashboardPreferences')
+
+ useEffect(() => {
+ if (!IS_PLATFORM) {
+ router.replace('/account/me#dashboard')
+ }
+ }, [router])
+
+ if (!IS_PLATFORM) return null
+
return (
<>
<PageHeader size="small">
<PageHeaderMeta>
<PageHeaderSummary>
- <PageHeaderTitle>Dashboard Preferences</PageHeaderTitle>
+ <PageHeaderTitle>Dashboard</PageHeaderTitle>
<PageHeaderDescription>
- Configure how the dashboard interacts with your project
+ Configure dashboard query preferences for this project.
</PageHeaderDescription>
</PageHeaderSummary>
</PageHeaderMeta>
</PageHeader>
- <PageContainer size="small">
- <DashboardPreferences />
- </PageContainer>
+ <PageContainer size="small">{showQueryPreferences && <DashboardPreferences />}</PageContainer>
</>
)
}
diff --git a/apps/studio/tests/pages/account/me.test.tsx b/apps/studio/tests/pages/account/me.test.tsx
new file mode 100644
index 00000000000..98777029a09
--- /dev/null
+++ b/apps/studio/tests/pages/account/me.test.tsx
@@ -0,0 +1,127 @@
+import { render, screen } from '@testing-library/react'
+import type { ReactNode } from 'react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import PreferencesPage from 'pages/account/me'
+
+const { mockIsPlatform, mockUseIsFeatureEnabled, mockUseProfile } = vi.hoisted(() => ({
+ mockIsPlatform: { value: true },
+ mockUseIsFeatureEnabled: vi.fn(),
+ mockUseProfile: vi.fn(),
+}))
+
+vi.mock('lib/constants', async () => {
+ const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
+ return {
+ ...actual,
+ get IS_PLATFORM() {
+ return mockIsPlatform.value
+ },
+ }
+})
+
+vi.mock('hooks/misc/useIsFeatureEnabled', () => ({
+ useIsFeatureEnabled: mockUseIsFeatureEnabled,
+}))
+
+vi.mock('lib/profile', () => ({
+ useProfile: mockUseProfile,
+}))
+
+vi.mock('components/layouts/AccountLayout/AccountLayout', () => ({
+ __esModule: true,
+ default: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}))
+
+vi.mock('components/layouts/AppLayout/AppLayout', () => ({
+ AppLayout: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}))
+
+vi.mock('components/layouts/DefaultLayout', () => ({
+ DefaultLayout: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/ProfileInformation', () => ({
+ ProfileInformation: () => <div>ProfileInformation</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/AccountIdentities', () => ({
+ AccountIdentities: () => <div>AccountIdentities</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/AccountConnections', () => ({
+ AccountConnections: () => <div>AccountConnections</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/ThemeSettings', () => ({
+ ThemeSettings: () => <div>ThemeSettings</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/HotkeySettings', () => ({
+ HotkeySettings: () => <div>HotkeySettings</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/DashboardSettings', () => ({
+ DashboardSettings: () => <div>DashboardSettings</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/AnalyticsSettings', () => ({
+ AnalyticsSettings: () => <div>AnalyticsSettings</div>,
+}))
+
+vi.mock('components/interfaces/Account/Preferences/AccountDeletion', () => ({
+ AccountDeletion: () => <div>AccountDeletion</div>,
+}))
+
+vi.mock('components/ui/AlertError', () => ({
+ AlertError: () => <div>AlertError</div>,
+}))
+
+describe('/account/me', () => {
+ beforeEach(() => {
+ mockUseIsFeatureEnabled.mockClear()
+ mockUseProfile.mockClear()
+ mockUseIsFeatureEnabled.mockReturnValue({
+ profileShowInformation: true,
+ profileShowAnalyticsAndMarketing: true,
+ profileShowAccountDeletion: true,
+ })
+ mockUseProfile.mockReturnValue({
+ error: null,
+ isLoading: false,
+ isError: false,
+ isSuccess: true,
+ })
+ })
+
+ it('renders hosted account sections on platform', () => {
+ mockIsPlatform.value = true
+
+ render(<PreferencesPage dehydratedState={{}} />)
+
+ expect(screen.getByText('ProfileInformation')).toBeInTheDocument()
+ expect(screen.getByText('AccountIdentities')).toBeInTheDocument()
+ expect(screen.getByText('AccountConnections')).toBeInTheDocument()
+ expect(screen.getByText('ThemeSettings')).toBeInTheDocument()
+ expect(screen.getByText('HotkeySettings')).toBeInTheDocument()
+ expect(screen.getByText('DashboardSettings')).toBeInTheDocument()
+ expect(screen.getByText('AnalyticsSettings')).toBeInTheDocument()
+ expect(screen.getByText('AccountDeletion')).toBeInTheDocument()
+ })
+
+ it('renders only local preferences on self-hosted', () => {
+ mockIsPlatform.value = false
+
+ render(<PreferencesPage dehydratedState={{}} />)
+
+ expect(screen.getByText('ThemeSettings')).toBeInTheDocument()
+ expect(screen.getByText('HotkeySettings')).toBeInTheDocument()
+ expect(screen.getByText('DashboardSettings')).toBeInTheDocument()
+ expect(screen.queryByText('ProfileInformation')).not.toBeInTheDocument()
+ expect(screen.queryByText('AccountIdentities')).not.toBeInTheDocument()
+ expect(screen.queryByText('AccountConnections')).not.toBeInTheDocument()
+ expect(screen.queryByText('AnalyticsSettings')).not.toBeInTheDocument()
+ expect(screen.queryByText('AccountDeletion')).not.toBeInTheDocument()
+ expect(mockUseProfile).not.toHaveBeenCalled()
+ })
+})
diff --git a/apps/studio/tests/pages/project/[ref]/settings/dashboard.test.tsx b/apps/studio/tests/pages/project/[ref]/settings/dashboard.test.tsx
new file mode 100644
index 00000000000..4ee2c7c8c34
--- /dev/null
+++ b/apps/studio/tests/pages/project/[ref]/settings/dashboard.test.tsx
@@ -0,0 +1,72 @@
+import { render, screen, waitFor } from '@testing-library/react'
+import DashboardPage from 'pages/project/[ref]/settings/dashboard'
+import type { ReactNode } from 'react'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+const { mockIsPlatform, mockRouter, mockUseFlag } = vi.hoisted(() => ({
+ mockIsPlatform: { value: true },
+ mockRouter: {
+ replace: vi.fn(),
+ },
+ mockUseFlag: vi.fn(),
+}))
+
+vi.mock('common', () => ({
+ useFlag: mockUseFlag,
+}))
+
+vi.mock('lib/constants', async () => {
+ const actual = await vi.importActual<Record<string, unknown>>('lib/constants')
+ return {
+ ...actual,
+ get IS_PLATFORM() {
+ return mockIsPlatform.value
+ },
+ }
+})
+
+vi.mock('next/router', () => ({
+ useRouter: () => mockRouter,
+}))
+
+vi.mock('components/layouts/DefaultLayout', () => ({
+ __esModule: true,
+ default: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}))
+
+vi.mock('components/layouts/ProjectSettingsLayout/SettingsLayout', () => ({
+ __esModule: true,
+ default: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}))
+
+vi.mock('@/components/interfaces/Settings/General/DashboardPreferences', () => ({
+ DashboardPreferences: () => <div>DashboardPreferences</div>,
+}))
+
+describe('/project/[ref]/settings/dashboard', () => {
+ beforeEach(() => {
+ mockIsPlatform.value = true
+ mockUseFlag.mockReturnValue(true)
+ mockRouter.replace.mockReset()
+ })
+
+ it('renders only query preferences on platform', () => {
+ render(<DashboardPage dehydratedState={{}} />)
+
+ expect(screen.getByText('Dashboard')).toBeInTheDocument()
+ expect(screen.getByText('DashboardPreferences')).toBeInTheDocument()
+ expect(screen.queryByText('Edits')).not.toBeInTheDocument()
+ })
+
+ it('redirects self-hosted visits to account preferences', async () => {
+ mockIsPlatform.value = false
+
+ render(<DashboardPage dehydratedState={{}} />)
+
+ await waitFor(() => {
+ expect(mockRouter.replace).toHaveBeenCalledWith('/account/me#dashboard')
+ })
+
+ expect(screen.queryByText('DashboardPreferences')).not.toBeInTheDocument()
+ })
+})
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
index a13f52b70c4..37b9daa710e 100644
--- a/packages/common/constants/local-storage.ts
+++ b/packages/common/constants/local-storage.ts
@@ -155,9 +155,9 @@ const LOCAL_STORAGE_KEYS_ALLOWLIST = [
LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT,
LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL,
LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR,
+ LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS,
LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS,
LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS,
- LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS,
LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR,
LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS,
LOCAL_STORAGE_KEYS.UI_PREVIEW_JIT_DB_ACCESS,
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index f17511275bb..0761ce96623 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -2471,6 +2471,24 @@ export interface InlineEditorSettingClickedEvent {
groups: Partial<TelemetryGroups>
}
+/**
+ * User toggled the queue table operations setting in account preferences.
+ *
+ * @group Events
+ * @source studio
+ * @page /dashboard/account/preferences
+ */
+export interface QueueOperationsSettingClickedEvent {
+ action: 'queue_operations_setting_clicked'
+ properties: {
+ /**
+ * Whether the queue operations was enabled or disabled
+ */
+ enabled: boolean
+ }
+ groups: Partial<TelemetryGroups>
+}
+
/**
* User clicked the save destination button in add log drains sheet.
*
@@ -3174,6 +3192,7 @@ export type TelemetryEvent =
| CommandMenuSearchSubmittedEvent
| CommandMenuCommandClickedEvent
| InlineEditorSettingClickedEvent
+ | QueueOperationsSettingClickedEvent
| SidebarOpenedEvent
| LogDrainSaveButtonClickedEvent
| LogDrainConfirmButtonSubmittedEvent