The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Moves inline editor from feature preview to setting (#39892)
Saxon Fletcher50255605ec34
diff --git a/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsxindex f9928a5b278..35267f776f6 100644--- a/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx+++ b/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx@@ -1,8 +1,17 @@-import { Toggle } from 'ui'+import { zodResolver } from '@hookform/resolvers/zod'+import { useForm } from 'react-hook-form'import { toast } from 'sonner'+import * as z from 'zod'+import { useConsentState } from 'common'import Panel from 'components/ui/Panel'import { useSendResetMutation } from 'data/telemetry/send-reset-mutation'+import { FormControl_Shadcn_, FormField_Shadcn_, Form_Shadcn_, Switch } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++const AnalyticsSchema = z.object({+ telemetryEnabled: z.boolean(),+})export const AnalyticsSettings = () => {const { hasAccepted, acceptAll, denyAll, categories } = useConsentState()@@ -10,31 +19,54 @@ export const AnalyticsSettings = () => {const { mutate: sendReset } = useSendResetMutation()- const onToggleOptIn = () => {+ const form = useForm<z.infer<typeof AnalyticsSchema>>({+ resolver: zodResolver(AnalyticsSchema),+ values: { telemetryEnabled: hasAccepted },+ })++ const handleToggle = (value: boolean) => {if (!hasLoaded) {- toast.error(+ return toast.error("We couldn't load the privacy settings due to an ad blocker or network error. Please disable any ad blockers and try again. If the problem persists, please contact support.")- return}- if (hasAccepted) {+ if (value) {+ acceptAll()+ } else {denyAll()sendReset()- } else {- acceptAll()}++ form.setValue('telemetryEnabled', value)}return (<Panel title={<h5 key="panel-title">Analytics and Marketing</h5>}><Panel.Content>- <Toggle- checked={hasAccepted}- onChange={onToggleOptIn}- label="Send telemetry data from Supabase services"- descriptionText="By opting in to sharing telemetry data, Supabase can analyze usage patterns to enhance user experience and use it for marketing and advertising purposes"- />+ <Form_Shadcn_ {...form}>+ <FormField_Shadcn_+ control={form.control}+ name="telemetryEnabled"+ render={({ field }) => (+ <FormItemLayout+ layout="flex-row-reverse"+ label="Send telemetry data from Supabase services"+ description="By opting in to sharing telemetry data, Supabase can analyze usage patterns to enhance user experience and use it for marketing and advertising purposes"+ >+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={(value) => {+ field.onChange(value)+ handleToggle(value)+ }}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </Form_Shadcn_></Panel.Content></Panel>)diff --git a/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx b/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsxindex cf89c8a4d1d..b97f3d0a19c 100644--- a/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx+++ b/apps/studio/components/interfaces/Account/Preferences/HotkeySettings.tsx@@ -1,8 +1,19 @@+import { zodResolver } from '@hookform/resolvers/zod'+import { useForm } from 'react-hook-form'+import * as z from 'zod'+import { LOCAL_STORAGE_KEYS } from 'common'import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'import Panel from 'components/ui/Panel'import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'-import { KeyboardShortcut, Toggle } from 'ui'+import { FormControl_Shadcn_, FormField_Shadcn_, Form_Shadcn_, KeyboardShortcut, Switch } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++const HotkeySchema = z.object({+ commandMenuEnabled: z.boolean(),+ aiAssistantEnabled: z.boolean(),+ inlineEditorEnabled: z.boolean(),+})export const HotkeySettings = () => {const [inlineEditorEnabled, setInlineEditorEnabled] = useLocalStorageQuery(@@ -18,6 +29,15 @@ export const HotkeySettings = () => {true)+ const form = useForm<z.infer<typeof HotkeySchema>>({+ resolver: zodResolver(HotkeySchema),+ values: {+ commandMenuEnabled: commandMenuEnabled ?? true,+ aiAssistantEnabled: aiAssistantEnabled ?? true,+ inlineEditorEnabled: inlineEditorEnabled ?? true,+ },+ })+return (<Paneltitle={@@ -29,38 +49,89 @@ export const HotkeySettings = () => {</div>}>- <Panel.Content className="space-y-2">- <Toggle- checked={commandMenuEnabled}- onChange={() => setCommandMenuEnabled(!commandMenuEnabled)}- label={- <div className="flex items-center gap-x-3">- <KeyboardShortcut keys={['Meta', 'k']} />- <span>Command menu</span>- </div>- }- />- <Toggle- checked={aiAssistantEnabled}- onChange={() => setAiAssistantEnabled(!aiAssistantEnabled)}- label={- <div className="flex items-center gap-x-3">- <KeyboardShortcut keys={['Meta', 'i']} />- <span>AI Assistant Panel</span>- </div>- }- />- <Toggle- checked={inlineEditorEnabled}- onChange={() => setInlineEditorEnabled(!inlineEditorEnabled)}- label={- <div className="flex items-center gap-x-3">- <KeyboardShortcut keys={['Meta', 'e']} />- <span>Inline SQL Editor Panel</span>- </div>- }- />- </Panel.Content>+ <Form_Shadcn_ {...form}>+ <Panel.Content className="border-b">+ <FormField_Shadcn_+ control={form.control}+ name="commandMenuEnabled"+ render={({ field }) => (+ <FormItemLayout+ layout="flex-row-reverse"+ label={+ <div className="flex items-center gap-x-3">+ <KeyboardShortcut keys={['Meta', 'k']} />+ <span>Command menu</span>+ </div>+ }+ >+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={(value) => {+ field.onChange(value)+ setCommandMenuEnabled(value)+ }}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </Panel.Content>+ <Panel.Content className="border-b">+ <FormField_Shadcn_+ control={form.control}+ name="aiAssistantEnabled"+ render={({ field }) => (+ <FormItemLayout+ layout="flex-row-reverse"+ label={+ <div className="flex items-center gap-x-3">+ <KeyboardShortcut keys={['Meta', 'i']} />+ <span>AI Assistant Panel</span>+ </div>+ }+ >+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={(value) => {+ field.onChange(value)+ setAiAssistantEnabled(value)+ }}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </Panel.Content>+ <Panel.Content>+ <FormField_Shadcn_+ control={form.control}+ name="inlineEditorEnabled"+ render={({ field }) => (+ <FormItemLayout+ layout="flex-row-reverse"+ label={+ <div className="flex items-center gap-x-3">+ <KeyboardShortcut keys={['Meta', 'e']} />+ <span>Inline SQL Editor Panel</span>+ </div>+ }+ >+ <FormControl_Shadcn_>+ <Switch+ checked={field.value}+ onCheckedChange={(value) => {+ field.onChange(value)+ setInlineEditorEnabled(value)+ }}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </Panel.Content>+ </Form_Shadcn_></Panel>)}diff --git a/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsxnew file mode 100644index 00000000000..c28bcaa39e6--- /dev/null+++ b/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx@@ -0,0 +1,86 @@+import { zodResolver } from '@hookform/resolvers/zod'+import { useForm } from 'react-hook-form'+import * as z from 'zod'++import { LOCAL_STORAGE_KEYS } from 'common'+import Panel from 'components/ui/Panel'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'+import { FormControl_Shadcn_, FormField_Shadcn_, Form_Shadcn_, Switch } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'++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 (+ <Panel title={<h5 id="inline-editor">Dashboard</h5>}>+ <Panel.Content>+ <Form_Shadcn_ {...form}>+ <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>+ )}+ />+ </Form_Shadcn_>+ </Panel.Content>+ </Panel>+ )+}diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsxindex ce8d859e785..89c110dd04d 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreview.constants.tsx@@ -29,13 +29,6 @@ export const FEATURE_PREVIEWS = [isNew: true,isPlatformOnly: true,},- {- key: LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR,- name: 'Directly edit database entities',- discussionsUrl: 'https://github.com/orgs/supabase/discussions/33690',- isNew: false,- isPlatformOnly: false,- },{key: LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL,name: 'Project API documentation',diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsxindex 248d731e5a7..79351481b7f 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx@@ -84,11 +84,6 @@ export const useIsColumnLevelPrivilegesEnabled = () => {return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]}-export const useIsInlineEditorEnabled = () => {- const { flags } = useFeaturePreviewContext()- return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR]-}-export const useUnifiedLogsPreview = () => {const { flags, onUpdateFlag } = useFeaturePreviewContext()diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsxindex 524e7cd28e5..18b5755d2b2 100644--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx@@ -13,7 +13,6 @@ import { Branching2Preview } from './Branching2Preview'import { CLSPreview } from './CLSPreview'import { FEATURE_PREVIEWS } from './FeaturePreview.constants'import { useFeaturePreviewContext, useFeaturePreviewModal } from './FeaturePreviewContext'-import { InlineEditorPreview } from './InlineEditorPreview'import { SecurityNotificationsPreview } from './SecurityNotificationsPreview'import { UnifiedLogsPreview } from './UnifiedLogsPreview'@@ -22,7 +21,6 @@ const FEATURE_PREVIEW_KEY_TO_CONTENT: {} = {[LOCAL_STORAGE_KEYS.UI_PREVIEW_BRANCHING_2_0]: <Branching2Preview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_ADVISOR_RULES]: <AdvisorRulesPreview />,- [LOCAL_STORAGE_KEYS.UI_PREVIEW_INLINE_EDITOR]: <InlineEditorPreview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_API_SIDE_PANEL]: <APISidePanelPreview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_CLS]: <CLSPreview />,[LOCAL_STORAGE_KEYS.UI_PREVIEW_UNIFIED_LOGS]: <UnifiedLogsPreview />,diff --git a/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx b/apps/studio/components/ui/QueryBlock/EditQueryButton.tsxindex 3637ef1edf7..5e514a60979 100644--- a/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx+++ b/apps/studio/components/ui/QueryBlock/EditQueryButton.tsx@@ -1,15 +1,16 @@import { Edit } from 'lucide-react'+import Link from 'next/link'import { useRouter } from 'next/router'+import { ComponentProps } from 'react'import { useParams } from 'common'-import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/InlineEditorSettings'import { DiffType } from 'components/interfaces/SQLEditor/SQLEditor.types'import useNewQuery from 'components/interfaces/SQLEditor/hooks'+import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'-import Link from 'next/link'-import { ComponentProps } from 'react'-import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state'+import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'import {cn,@@ -20,8 +21,6 @@ import {TooltipContent,} from 'ui'import { ButtonTooltip } from '../ButtonTooltip'-import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'-import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'interface EditQueryButtonProps {id?: stringdiff --git a/apps/studio/pages/account/me.tsx b/apps/studio/pages/account/me.tsxindex d41b1b1b1e7..c805527453f 100644--- a/apps/studio/pages/account/me.tsx+++ b/apps/studio/pages/account/me.tsx@@ -3,6 +3,7 @@ import { AccountDeletion } from 'components/interfaces/Account/Preferences/Accouimport { AccountIdentities } from 'components/interfaces/Account/Preferences/AccountIdentities'import { AnalyticsSettings } from 'components/interfaces/Account/Preferences/AnalyticsSettings'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'@@ -88,6 +89,10 @@ const ProfileCard = () => {<HotkeySettings /></section>+ <section>+ <InlineEditorSettings />+ </section>+{profileShowAnalyticsAndMarketing && (<section><AnalyticsSettings />diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsxindex e5c05ebbb44..d5a939e2143 100644--- a/apps/studio/pages/project/[ref]/auth/policies.tsx+++ b/apps/studio/pages/project/[ref]/auth/policies.tsx@@ -1,9 +1,10 @@import type { PostgresPolicy, PostgresTable } from '@supabase/postgres-meta'import { PermissionAction } from '@supabase/shared-types/out/constants'import { Search } from 'lucide-react'+import { parseAsString, useQueryState } from 'nuqs'import { useCallback, useDeferredValue, useMemo, useState } from 'react'-import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/InlineEditorSettings'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'@@ -26,7 +27,6 @@ import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { useIsProtectedSchema } from 'hooks/useProtectedSchemas'import { DOCS_URL } from 'lib/constants'-import { parseAsString, useQueryState } from 'nuqs'import { useEditorPanelStateSnapshot } from 'state/editor-panel-state'import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'import type { NextPageWithLayout } from 'types'diff --git a/apps/studio/pages/project/[ref]/database/functions.tsx b/apps/studio/pages/project/[ref]/database/functions.tsxindex 02e68b6ee14..d1446917a0e 100644--- a/apps/studio/pages/project/[ref]/database/functions.tsx+++ b/apps/studio/pages/project/[ref]/database/functions.tsx@@ -1,7 +1,7 @@import { PermissionAction } from '@supabase/shared-types/out/constants'import { useState } from 'react'-import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/InlineEditorSettings'import { CreateFunction } from 'components/interfaces/Database/Functions/CreateFunction'import { DeleteFunction } from 'components/interfaces/Database/Functions/DeleteFunction'import FunctionsList from 'components/interfaces/Database/Functions/FunctionsList/FunctionsList'@@ -19,10 +19,6 @@ import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'import type { NextPageWithLayout } from 'types'const DatabaseFunctionsPage: NextPageWithLayout = () => {- const [selectedFunction, setSelectedFunction] = useState<DatabaseFunction | undefined>()- const [showCreateFunctionForm, setShowCreateFunctionForm] = useState(false)- const [showDeleteFunctionForm, setShowDeleteFunctionForm] = useState(false)- const [isDuplicating, setIsDuplicating] = useState(false)const isInlineEditorEnabled = useIsInlineEditorEnabled()const { openSidebar } = useSidebarManagerSnapshot()const {@@ -36,6 +32,11 @@ const DatabaseFunctionsPage: NextPageWithLayout = () => {'functions')+ const [isDuplicating, setIsDuplicating] = useState(false)+ const [selectedFunction, setSelectedFunction] = useState<DatabaseFunction | undefined>()+ const [showCreateFunctionForm, setShowCreateFunctionForm] = useState(false)+ const [showDeleteFunctionForm, setShowDeleteFunctionForm] = useState(false)+const createFunction = () => {setIsDuplicating(false)if (isInlineEditorEnabled) {diff --git a/apps/studio/pages/project/[ref]/database/triggers.tsx b/apps/studio/pages/project/[ref]/database/triggers.tsxindex 90e0ef80659..3b1c35ed658 100644--- a/apps/studio/pages/project/[ref]/database/triggers.tsx+++ b/apps/studio/pages/project/[ref]/database/triggers.tsx@@ -2,7 +2,7 @@ import { PostgresTrigger } from '@supabase/postgres-meta'import { PermissionAction } from '@supabase/shared-types/out/constants'import { useState } from 'react'-import { useIsInlineEditorEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { useIsInlineEditorEnabled } from 'components/interfaces/Account/Preferences/InlineEditorSettings'import { DeleteTrigger } from 'components/interfaces/Database/Triggers/DeleteTrigger'import { TriggerSheet } from 'components/interfaces/Database/Triggers/TriggerSheet'import { generateTriggerCreateSQL } from 'components/interfaces/Database/Triggers/TriggersList/TriggerList.utils'diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.tsindex b5a0869c316..03e4b598902 100644--- a/packages/common/telemetry-constants.ts+++ b/packages/common/telemetry-constants.ts@@ -2181,6 +2181,24 @@ export interface TableQuickstartAssistantOpenedEvent {groups: TelemetryGroups}+/**+ * User toggled the inline editor setting in account preferences.+ *+ * @group Events+ * @source studio+ * @page /dashboard/account/preferences+ */+export interface InlineEditorSettingClickedEvent {+ action: 'inline_editor_setting_clicked'+ properties: {+ /**+ * Whether the inline editor was enabled or disabled+ */+ enabled: boolean+ }+ groups: Partial<TelemetryGroups>+}+/*** User clicked the save destination button in add log drains sheet.*@@ -2340,6 +2358,7 @@ export type TelemetryEvent =| CommandMenuOpenedEvent| CommandMenuSearchSubmittedEvent| CommandMenuCommandClickedEvent+ | InlineEditorSettingClickedEvent| SidebarOpenedEvent| LogDrainSaveButtonClickedEvent| LogDrainConfirmButtonSubmittedEvent