From 994953a4d01b89cd56f38cd1e98284cd4cc500d5 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Tue, 29 Oct 2024 16:11:36 +0800 Subject: [PATCH] moved some components around --- apps/studio-prototype/next-env.d.ts | 5 ++ .../DiskManagement/DiskManagementForm.tsx | 41 +++++++++----- .../DiskManagementRestartRequiredSection.tsx | 43 +++++++-------- .../DiskManagementReviewAndSubmitDialog.tsx | 41 +++++++------- .../fields/ComputeSizeField.tsx | 2 +- .../DiskManagement/ui/DiskCountdownRadial.tsx | 53 +++++++++++-------- .../ui/DiskManagementCoolDownSection.tsx | 14 ++--- .../DiskManagement/ui/DiskSpaceBar.tsx | 4 +- .../DiskManagement/ui/NoticeBar.tsx | 38 ++++++++----- .../layouts/ProjectLayout/ResizingState.tsx | 12 +++-- .../ui/CountdownTimer/CountdownTimerSpan.tsx | 40 +++++++------- 11 files changed, 163 insertions(+), 130 deletions(-) create mode 100644 apps/studio-prototype/next-env.d.ts diff --git a/apps/studio-prototype/next-env.d.ts b/apps/studio-prototype/next-env.d.ts new file mode 100644 index 00000000000..4f11a03dc6c --- /dev/null +++ b/apps/studio-prototype/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx index 59abef5c3ac..a0760ea253d 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx @@ -47,13 +47,17 @@ import { } from './ui/DiskManagement.constants' import { DiskManagementPlanUpgradeRequired } from './ui/DiskManagementPlanUpgradeRequired' import { NoticeBar } from './ui/NoticeBar' +import { DiskMangementRestartRequiredSection } from './DiskManagementRestartRequiredSection' +import { useQueryClient } from '@tanstack/react-query' +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(false) const [remainingTime, setRemainingTime] = useState(0) @@ -229,7 +233,11 @@ export function DiskManagementForm() { const { mutateAsync: updateSubscriptionAddon, isLoading: isUpdatingCompute } = useProjectAddonUpdateMutation({ onSuccess: () => { - setShowRestartPendingState(true) + /** + * Manually set project status to RESIZING + * Project status should be RESIZING on next project status request. + */ + setProjectStatus(queryClient, projectRef!, PROJECT_STATUS.RESIZING) }, }) @@ -311,28 +319,33 @@ export function DiskManagementForm() { // return <> const isDirty = !!Object.keys(form.formState.dirtyFields).length + const isProjectResizing = project?.status === PROJECT_STATUS.RESIZING + const isProjectRequestingDiskChanges = isRequestingChanges && !isProjectResizing return ( <> + {isProjectResizing || isProjectRequestingDiskChanges ? ( + + + + + ) : null}
- {showRestartPending ? ( - - ) : isRequestingChanges ? ( - - ) : null} - + {isPlanUpgradeRequired && } { - const [progress, setProgress] = useState(100) - const [showCountdown, setShowCountdown] = useState(false) - const [isJumping, setIsJumping] = useState(false) - const [isVisible, setIsVisible] = useState(true) +interface Props { + visible: boolean + title: string + description: string +} +export const DiskMangementRestartRequiredSection: React.FC = ({ + visible, + title, + description, +}) => { return ( - {isVisible && ( + {visible && ( - -
-
+ +
+
+
-

A Project restart will be required.

-

- You can restart after confirming changes or when convenient. -

+

{title}

+

{description}

-
)} diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx index b5e7b4b5d7b..e44c43cebeb 100644 --- a/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx +++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementReviewAndSubmitDialog.tsx @@ -1,12 +1,14 @@ import { PermissionAction } from '@supabase/shared-types/out/constants' -import { ChevronRight } from 'lucide-react' -import { UseFormReturn } from 'react-hook-form' - +import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' import { ButtonTooltip } from 'components/ui/ButtonTooltip' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' +import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization' import { formatCurrency } from 'lib/helpers' +import { ChevronRight } from 'lucide-react' +import { useMemo } from 'react' +import { UseFormReturn } from 'react-hook-form' import { Alert_Shadcn_, AlertTitle_Shadcn_, @@ -28,8 +30,7 @@ import { TableRow, WarningIcon, } from 'ui' -import { BillingChangeBadge } from './ui/BillingChangeBadge' -import { DiskType } from './ui/DiskManagement.constants' +import { DiskStorageSchemaType } from './DiskManagement.schema' import { calculateComputeSizePrice, calculateDiskSizePrice, @@ -37,12 +38,10 @@ import { calculateThroughputPrice, getAvailableComputeOptions, } from './DiskManagement.utils' -import { DiskMangementCoolDownSection } from './ui/DiskManagementCoolDownSection' -import { DiskStorageSchemaType } from './DiskManagement.schema' -import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' -import { useMemo } from 'react' -import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query' import { DiskMangementRestartRequiredSection } from './DiskManagementRestartRequiredSection' +import { BillingChangeBadge } from './ui/BillingChangeBadge' +import { DiskType } from './ui/DiskManagement.constants' +import { DiskMangementCoolDownSection } from './ui/DiskManagementCoolDownSection' const TableHeaderRow = () => ( @@ -249,7 +248,15 @@ export const DiskManagementReviewAndSubmitDialog = ({ Changes will be applied shortly once confirmed. - +
+ + {hasDiskConfigChanges && } +
+ @@ -314,23 +321,17 @@ export const DiskManagementReviewAndSubmitDialog = ({
-
- {form.formState.defaultValues?.computeSize !== form.getValues('computeSize') && ( - - )} - {hasDiskConfigChanges && } -
- {/* */} - + */} )} diff --git a/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx b/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx index 18a218303d1..78d12f36505 100644 --- a/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx +++ b/apps/studio/components/interfaces/DiskManagement/ui/DiskSpaceBar.tsx @@ -54,7 +54,7 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) { const databaseSizeBytes = data?.result[0].db_size ?? 0 return ( -
+
{usedSize.toFixed(2)} @@ -75,7 +75,7 @@ export default function DiskSpaceBar({ form }: DiskSpaceBarProps) {
diff --git a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx b/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx index dc5848692a3..aa2285b7745 100644 --- a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx +++ b/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx @@ -1,30 +1,40 @@ -import { Card, CardContent } from 'ui' -import { formatComputeName } from '../DiskManagement.utils' +import { AnimatePresence, motion } from 'framer-motion' import { LucideIcon } from 'lucide-react' +import { Card, CardContent } from 'ui' interface NoticeBarProps { title?: string description?: string icon?: LucideIcon + visible: boolean } export function NoticeBar({ + visible, title = 'Project about to restart', description = `This project is about to restart to change compute to.`, icon: Icon, }: NoticeBarProps) { return ( - - - {Icon && } -
-

{title}

-

{description}

-
-
-
+ + + {visible && ( + + + {Icon && } +
+

{title}

+

{description}

+
+
+
+ )} +
+
) } diff --git a/apps/studio/components/layouts/ProjectLayout/ResizingState.tsx b/apps/studio/components/layouts/ProjectLayout/ResizingState.tsx index d5bc190f251..9a2d96d34e5 100644 --- a/apps/studio/components/layouts/ProjectLayout/ResizingState.tsx +++ b/apps/studio/components/layouts/ProjectLayout/ResizingState.tsx @@ -24,13 +24,15 @@ export const ResizingState = () => {
- +
-
-

Resizing project...

+
+

Resizing Project Compute size

- Your project is being restarted to apply compute size changes. It can take a few - minutes. Your project will be offline while it is being restarted. + Your project is being restarted to apply compute size changes. +

+

+ This can take a few minutes. Project will be offline while it is being restarted.

diff --git a/apps/studio/components/ui/CountdownTimer/CountdownTimerSpan.tsx b/apps/studio/components/ui/CountdownTimer/CountdownTimerSpan.tsx index db91c93dec1..166e7818ae0 100644 --- a/apps/studio/components/ui/CountdownTimer/CountdownTimerSpan.tsx +++ b/apps/studio/components/ui/CountdownTimer/CountdownTimerSpan.tsx @@ -17,25 +17,27 @@ const CountdownTimerSpan = ({ seconds }: CountdownTimerSpanProps) => { const formatValue = (value: number) => value.toString().padStart(2, '0') return ( - - - hr - - m - - s + + Time remaining: + + + hr + + m + + ) }