mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
clean up
This commit is contained in:
1 parent
994953a4d0
commit
cd2b4bc6e6
2 files changed
+13
-40
No files matched your search
@@ -53,14 +53,11 @@ import { PROJECT_STATUS } from 'lib/constants'
|
||||
import { setProjectStatus } from 'data/projects/projects-query'
|
||||
|
||||
export function DiskManagementForm() {
|
||||
const showDiskAndComputeForm = useFlag('diskAndComputeForm')
|
||||
const { project } = useProjectContext()
|
||||
const org = useSelectedOrganization()
|
||||
const { ref: projectRef } = useParams()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false)
|
||||
const [remainingTime, setRemainingTime] = useState(0)
|
||||
const [refetchInterval, setRefetchInterval] = useState<number | false>(false)
|
||||
const [messageState, setMessageState] = useState<{
|
||||
message: string
|
||||
@@ -194,8 +191,6 @@ export function DiskManagementForm() {
|
||||
|
||||
const { watch, formState } = form
|
||||
|
||||
const watchedComputeSize = watch('computeSize')
|
||||
|
||||
// const isAllocatedStorageDirty = !!dirtyFields.totalSize
|
||||
|
||||
const disableInput =
|
||||
@@ -208,23 +203,8 @@ export function DiskManagementForm() {
|
||||
// Initialize field values properly when data has been loaded, preserving any user changes
|
||||
if (isSuccess) {
|
||||
console.log('FORM resetting', form.formState)
|
||||
// const currentValues = form.getValues()
|
||||
// const dirtyFields = form.formState.dirtyFields
|
||||
|
||||
// const newValues = {
|
||||
// ...defaultValues,
|
||||
// ...Object.fromEntries(
|
||||
// Object.entries(currentValues).filter(
|
||||
// ([key]) => dirtyFields[key as keyof typeof dirtyFields]
|
||||
// )
|
||||
// ),
|
||||
// }
|
||||
form.reset(defaultValues, {
|
||||
// keepDirtyValues: true, // This preserves which fields have been changed
|
||||
// keepTouched: true,
|
||||
// keepDirty: true,
|
||||
// keepValues: true,
|
||||
})
|
||||
form.reset(defaultValues, {})
|
||||
}
|
||||
}, [isSuccess])
|
||||
|
||||
|
||||
+12
-19
@@ -146,34 +146,31 @@ export const DiskManagementReviewAndSubmitDialog = ({
|
||||
|
||||
const { formState, getValues } = form
|
||||
|
||||
/**
|
||||
* Queries
|
||||
* */
|
||||
const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })
|
||||
const {
|
||||
data: addons,
|
||||
isLoading: isAddonsLoading,
|
||||
error: addonsError,
|
||||
isSuccess: isAddonsSuccess,
|
||||
} = useProjectAddonsQuery({ projectRef: project?.ref })
|
||||
|
||||
const canUpdateDiskConfiguration = useCheckPermissions(PermissionAction.UPDATE, 'projects', {
|
||||
resource: {
|
||||
project_id: project?.id,
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* Queries
|
||||
* */
|
||||
const {
|
||||
data: subscription,
|
||||
// request deps in Form handle errors and loading
|
||||
} = useOrgSubscriptionQuery({ orgSlug: org?.slug })
|
||||
const {
|
||||
data: addons,
|
||||
// request deps in Form handle errors and loading
|
||||
} = useProjectAddonsQuery({ projectRef: project?.ref })
|
||||
|
||||
const planId = subscription?.plan.id ?? 'free'
|
||||
const isDirty = !!Object.keys(form.formState.dirtyFields).length
|
||||
const replicaTooltipText = `Price change includes primary database and ${numReplicas} replica${numReplicas > 1 ? 's' : ''}`
|
||||
|
||||
/**
|
||||
* Handle compute instances
|
||||
*/
|
||||
const availableAddons = useMemo(() => {
|
||||
return addons?.available_addons ?? []
|
||||
}, [addons])
|
||||
|
||||
const availableOptions = useMemo(() => {
|
||||
return getAvailableComputeOptions(availableAddons, project?.cloud_provider)
|
||||
}, [availableAddons, project?.cloud_provider])
|
||||
@@ -183,7 +180,6 @@ export const DiskManagementReviewAndSubmitDialog = ({
|
||||
oldComputeSize: form.formState.defaultValues?.computeSize || 'ci_micro',
|
||||
newComputeSize: form.getValues('computeSize'),
|
||||
})
|
||||
|
||||
const diskSizePrice = calculateDiskSizePrice({
|
||||
planId: planId,
|
||||
oldSize: formState.defaultValues?.totalSize || 0,
|
||||
@@ -192,7 +188,6 @@ export const DiskManagementReviewAndSubmitDialog = ({
|
||||
newStorageType: getValues('storageType') as DiskType,
|
||||
numReplicas,
|
||||
})
|
||||
|
||||
const iopsPrice = calculateIOPSPrice({
|
||||
oldStorageType: form.formState.defaultValues?.storageType as DiskType,
|
||||
oldProvisionedIOPS: form.formState.defaultValues?.provisionedIOPS || 0,
|
||||
@@ -200,7 +195,6 @@ export const DiskManagementReviewAndSubmitDialog = ({
|
||||
newProvisionedIOPS: form.getValues('provisionedIOPS'),
|
||||
numReplicas,
|
||||
})
|
||||
|
||||
const throughputPrice = calculateThroughputPrice({
|
||||
storageType: form.getValues('storageType') as DiskType,
|
||||
newThroughput: form.getValues('throughput') || 0,
|
||||
@@ -241,7 +235,6 @@ export const DiskManagementReviewAndSubmitDialog = ({
|
||||
Review changes
|
||||
</ButtonTooltip>
|
||||
</DialogTrigger>
|
||||
{loading && <h1>is loading</h1>}
|
||||
<DialogContent className="min-w-[620px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Review changes</DialogTitle>
|
||||
|
||||
Reference in new issue
Block a user