From 458df73a37635deff483a27933d29addd3221bcd Mon Sep 17 00:00:00 2001 From: Ali Waseem Date: Mon, 30 Mar 2026 15:05:35 -0600 Subject: [PATCH] wip: cleaned up toggle --- .../Account/Preferences/DashboardToggle.tsx | 43 +++++++++ .../Preferences/InlineEditorSettings.tsx | 90 +++++-------------- 2 files changed, 65 insertions(+), 68 deletions(-) create mode 100644 apps/studio/components/interfaces/Account/Preferences/DashboardToggle.tsx 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..a416dc32b39 --- /dev/null +++ b/apps/studio/components/interfaces/Account/Preferences/DashboardToggle.tsx @@ -0,0 +1,43 @@ +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 { + form: UseFormReturn + name: Path + label: string + description: string + onToggle: (value: boolean) => void + isLast?: boolean +} + +export function DashboardToggle({ + form, + name, + label, + description, + onToggle, + isLast, +}: DashboardToggleProps) { + return ( + + ( + + + { + field.onChange(value) + onToggle(value) + }} + /> + + + )} + /> + + ) +} diff --git a/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx index dcd1053a8af..f7f80aa440f 100644 --- a/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx +++ b/apps/studio/components/interfaces/Account/Preferences/InlineEditorSettings.tsx @@ -4,16 +4,7 @@ import { useSendEventMutation } from 'data/telemetry/send-event-mutation' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization' import { useForm } from 'react-hook-form' -import { - Card, - CardContent, - Form_Shadcn_, - FormControl_Shadcn_, - FormField_Shadcn_, - Separator, - Switch, -} from 'ui' -import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' +import { Card, Form_Shadcn_ } from 'ui' import { PageSection, PageSectionContent, @@ -24,6 +15,8 @@ import { } from 'ui-patterns/PageSection' import * as z from 'zod' +import { DashboardToggle } from './DashboardToggle' + const DashboardSettingsSchema = z.object({ inlineEditorEnabled: z.boolean(), queueOperationsEnabled: z.boolean(), @@ -65,12 +58,8 @@ export const InlineEditorSettings = () => { sendEvent({ action: 'inline_editor_setting_clicked', - properties: { - enabled: value, - }, - groups: { - organization: org?.slug, - }, + properties: { enabled: value }, + groups: { organization: org?.slug }, }) } @@ -80,12 +69,8 @@ export const InlineEditorSettings = () => { sendEvent({ action: 'queue_operations_setting_clicked', - properties: { - enabled: value, - }, - groups: { - organization: org?.slug, - }, + properties: { enabled: value }, + groups: { organization: org?.slug }, }) } @@ -102,52 +87,21 @@ export const InlineEditorSettings = () => { - - ( - - - { - field.onChange(value) - handleInlineEditorToggle(value) - }} - /> - - - )} - /> - - - ( - - - { - field.onChange(value) - handleQueueOperationsToggle(value) - }} - /> - - - )} - /> - + +