The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Open advanced settings + scroll to that collapsible if submitting has an error (#45818)
Joshen Lim52237e1ae481
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsxindex 76c075fbf7e..f105c7d6e6d 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx@@ -3,7 +3,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useParams } from 'common'import { AnimatePresence, motion } from 'framer-motion'import { ChevronRight } from 'lucide-react'-import { useEffect, useState } from 'react'+import { useEffect, useRef, useState } from 'react'import { useForm } from 'react-hook-form'import { CloudProvider } from 'shared-data'import { toast } from 'sonner'@@ -13,6 +13,7 @@ import {Collapsible_Shadcn_,CollapsibleContent_Shadcn_,CollapsibleTrigger_Shadcn_,+ DialogSectionSeparator,Form,Separator,} from 'ui'@@ -77,6 +78,8 @@ export function DiskManagementForm() {const { data: org } = useSelectedOrganizationQuery()const { setProjectStatus } = useSetProjectStatus()+ const advancedSettingsRef = useRef<HTMLDivElement>(null)+const isSpendCapEnabled =org?.plan.id !== 'free' && !org?.usage_billing_enabled && project?.cloud_provider !== 'FLY'@@ -163,43 +166,8 @@ export function DiskManagementForm() {reValidateMode: 'onChange',})- useEffect(() => {- if (!isDiskAttributesSuccess) return- // @ts-ignore- const { type, iops, throughput_mbps, size_gb } = data?.attributes ?? { size_gb: 0 }- const formValues = {- storageType: type,- provisionedIOPS: iops,- throughput: throughput_mbps,- totalSize: size_gb,- computeSize: form.getValues('computeSize'),- }-- if (!('requested_modification' in data)) {- if (refetchInterval !== false) {- form.reset(formValues)- setRefetchInterval(false)- toast.success('Disk configuration changes have been successfully applied!')- }- } else {- setRefetchInterval(2000)- }- }, [data, isDiskAttributesSuccess, form, refetchInterval])-const { computeSize: modifiedComputeSize } = form.watch()- // We only support disk configurations for >=Large instances- // If a customer downgrades back to <Large, we should reset the storage settings to avoid incurring unnecessary costs- useEffect(() => {- if (modifiedComputeSize && project?.infra_compute_size && isDialogOpen) {- if (RESTRICTED_COMPUTE_FOR_THROUGHPUT_ON_GP3.includes(modifiedComputeSize)) {- form.setValue('storageType', DiskType.GP3)- form.setValue('throughput', DISK_LIMITS['gp3'].minThroughput)- form.setValue('provisionedIOPS', DISK_LIMITS['gp3'].minIops)- }- }- }, [modifiedComputeSize, isDialogOpen, project])-const isSuccess =isAddonsSuccess &&isDiskAttributesSuccess &&@@ -213,6 +181,7 @@ export function DiskManagementForm() {const isPlanUpgradeRequired = !hasAccessconst { formState } = form+ const errors = formState.errorsconst usedSize = Math.round(((diskUtil?.metrics.fs_used_bytes ?? 0) / GB) * 100) / 100const totalSize = formState.defaultValues?.totalSize || 0const usedPercentage = (usedSize / totalSize) * 100@@ -328,6 +297,41 @@ export function DiskManagementForm() {}}+ useEffect(() => {+ if (!isDiskAttributesSuccess) return+ // @ts-ignore+ const { type, iops, throughput_mbps, size_gb } = data?.attributes ?? { size_gb: 0 }+ const formValues = {+ storageType: type,+ provisionedIOPS: iops,+ throughput: throughput_mbps,+ totalSize: size_gb,+ computeSize: form.getValues('computeSize'),+ }++ if (!('requested_modification' in data)) {+ if (refetchInterval !== false) {+ form.reset(formValues)+ setRefetchInterval(false)+ toast.success('Disk configuration changes have been successfully applied!')+ }+ } else {+ setRefetchInterval(2000)+ }+ }, [data, isDiskAttributesSuccess, form, refetchInterval])++ // We only support disk configurations for >=Large instances+ // If a customer downgrades back to <Large, we should reset the storage settings to avoid incurring unnecessary costs+ useEffect(() => {+ if (modifiedComputeSize && project?.infra_compute_size && isDialogOpen) {+ if (RESTRICTED_COMPUTE_FOR_THROUGHPUT_ON_GP3.includes(modifiedComputeSize)) {+ form.setValue('storageType', DiskType.GP3)+ form.setValue('throughput', DISK_LIMITS['gp3'].minThroughput)+ form.setValue('provisionedIOPS', DISK_LIMITS['gp3'].minIops)+ }+ }+ }, [modifiedComputeSize, isDialogOpen, project])+useEffect(() => {// Initialize field values properly when data has been loaded, preserving any user changesif (isDiskAttributesSuccess || isSuccess) {@@ -336,6 +340,26 @@ export function DiskManagementForm() {// eslint-disable-next-line react-hooks/exhaustive-deps}, [isSuccess, isDiskAttributesSuccess])+ useEffect(() => {+ const fieldErrors = Object.keys(errors)+ if (fieldErrors.length > 0) {+ if (+ fieldErrors.includes('throughput') ||+ fieldErrors.includes('provisionedIOPS') ||+ fieldErrors.includes('maxSizeGb')+ ) {+ setAdvancedSettingsOpenState(true)++ // [Joshen] The timeout is to let the collapsible open prior to scrolling+ const timeoutId = setTimeout(() => {+ advancedSettingsRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })+ }, 100)++ return () => clearTimeout(timeoutId)+ }+ }+ }, [errors])+return (<><ScaffoldContainer className="relative flex flex-col gap-10" bottomPadding>@@ -447,8 +471,6 @@ export function DiskManagementForm() {<Separator /><Collapsible_Shadcn_- // TO DO: wrap component into pattern- className="-space-y-px"open={advancedSettingsOpen}onOpenChange={() => setAdvancedSettingsOpenState((prev) => !prev)}>@@ -467,16 +489,17 @@ export function DiskManagementForm() {/></CollapsibleTrigger_Shadcn_><CollapsibleContent_Shadcn_+ ref={advancedSettingsRef}className={cn('transition-all rounded-b',- 'data-open:border data-closed:animate-collapsible-up data-open:animate-collapsible-down'+ 'border border-t-0 data-closed:animate-collapsible-up data-open:animate-collapsible-down')}><div className="flex flex-col gap-y-8 py-8"><div className="px-card flex flex-col gap-y-8"><AutoScaleFields form={form} /></div>- <Separator />+ <DialogSectionSeparator /><div className="px-card flex flex-col gap-y-8"><NoticeBartype="default"diff --git a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsxindex a7a9edafbaa..2f05a0c7c9e 100644--- a/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx+++ b/apps/studio/components/interfaces/Settings/General/DeleteProjectPanel/DeleteProjectModal.tsx@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'import { useEffect, useState } from 'react'import { toast } from 'sonner'import { TextArea_Shadcn_ as TextArea } from 'ui'+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { CANCELLATION_REASONS } from '@/components/interfaces/Billing/Billing.constants'import { LogicalBackupCliInstructions } from '@/components/layouts/ProjectLayout/LogicalBackupCliInstructions'@@ -141,17 +142,18 @@ export const DeleteProjectModal = ({><div className="space-y-6"><LogicalBackupCliInstructions enabled={visible} showResetPassword={false} />+{/*[Joshen] This is basically ExitSurvey.tsx, ideally we have one shared component but the onein ExitSurvey has a Form wrapped around it already. Will probably need some effort to refactorbut leaving that for the future.*/}{!isFree && (- <>- <div className="space-y-1">- <h4 className="text-base">What made you decide to delete your project?</h4>- </div>- <div className="space-y-4 pt-4">+ <div className="flex flex-col gap-y-6">+ <FormItemLayout+ isReactForm={false}+ label="What made you decide to delete your project?"+ ><div className="flex flex-wrap gap-2" data-toggle="buttons">{shuffledReasons.map((option) => {const active = selectedReason[0] === option.value@@ -181,19 +183,17 @@ export const DeleteProjectModal = ({)})}</div>- <div className="text-area-text-sm flex flex-col gap-y-2">- <label htmlFor="message" className="text-sm whitespace-pre-line wrap-break-word">- {textareaLabel}- </label>- <TextArea- name="message"- rows={3}- value={message}- onChange={(event) => setMessage(event.target.value)}- />- </div>- </div>- </>+ </FormItemLayout>++ <FormItemLayout isReactForm={false} label={textareaLabel}>+ <TextArea+ name="message"+ rows={3}+ value={message}+ onChange={(event) => setMessage(event.target.value)}+ />+ </FormItemLayout>+ </div>)}</div></TextConfirmModal>