Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

use `Admonition` instead of deprecated `NoticeBar` (#47262)

Gildas Garcia1059b726cee3
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
index fcd531e1c8c..46823e64c10 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
@@ -41,7 +41,6 @@ import {
PLAN_DETAILS,
RESTRICTED_COMPUTE_FOR_THROUGHPUT_ON_GP3,
} from './ui/DiskManagement.constants'
-import { NoticeBar } from './ui/NoticeBar'
import { SpendCapDisabledSection } from './ui/SpendCapDisabledSection'
import {
MAX_WIDTH_CLASSES,
@@ -396,18 +395,22 @@ export function DiskManagementForm() {
title="Your project will now automatically restart."
description="Your project will be unavailable for up to 2 mins."
/>
- <NoticeBar
- type="default"
- visible={isProjectRequestingDiskChanges}
- title="Disk configuration changes have been requested"
- description="The requested changes will be applied to your disk shortly"
- />
- <NoticeBar
- type="default"
- visible={isEntitlementsLoaded && !isPlanUpgradeRequired && noPermissions}
- title="You do not have permission to update disk configuration"
- description="Please contact your organization administrator to update your disk configuration"
- />
+ {isProjectRequestingDiskChanges && (
+ <Admonition
+ type="default"
+ layout="horizontal"
+ title="Disk configuration changes have been requested"
+ description="The requested changes will be applied to your disk shortly"
+ />
+ )}
+ {isEntitlementsLoaded && !isPlanUpgradeRequired && noPermissions && (
+ <Admonition
+ type="default"
+ layout="horizontal"
+ title="You do not have permission to update disk configuration"
+ description="Please contact your organization administrator to update your disk configuration"
+ />
+ )}
</div>
)}
@@ -428,19 +431,20 @@ export function DiskManagementForm() {
<SpendCapDisabledSection currentDiskSizeGb={defaultValues.totalSize} />
<div className="flex flex-col gap-y-4">
- <NoticeBar
- type="default"
- visible={isDiskNoticeVisible}
- title="Disk configuration is only available for projects in the AWS cloud provider"
- description={
- isAwsK8s
- ? 'Configuring your disk for AWS (Revamped) projects is unavailable for now.'
- : isBranch
- ? 'Delete and recreate your Preview Branch to configure disk size. It was deployed on an older branching infrastructure.'
- : 'The Fly Postgres offering is deprecated - please migrate your instance to the AWS cloud prov to configure your disk.'
- }
- />
-
+ {isDiskNoticeVisible && (
+ <Admonition
+ type="default"
+ layout="horizontal"
+ title="Disk configuration is only available for projects in the AWS cloud provider"
+ description={
+ isAwsK8s
+ ? 'Configuring your disk for AWS (Revamped) projects is unavailable for now.'
+ : isBranch
+ ? 'Delete and recreate your Preview Branch to configure disk size. It was deployed on an older branching infrastructure.'
+ : 'The Fly Postgres offering is deprecated - please migrate your instance to the AWS cloud prov to configure your disk.'
+ }
+ />
+ )}
{isAws && (
<>
<div className="flex flex-col gap-y-3">
@@ -517,54 +521,54 @@ export function DiskManagementForm() {
</div>
<DialogSectionSeparator />
<div className="px-card flex flex-col gap-y-8">
- <NoticeBar
- type="default"
- visible={!!disableIopsThroughputConfig}
- title="Adjusting disk configuration requires LARGE Compute size or above"
- description={`Increase your compute size to adjust your disk's storage type, ${form.getValues('storageType') === 'gp3' ? 'IOPS, ' : ''} and throughput`}
- actions={
- canUpdateDiskConfiguration ? (
- <Button
- variant="default"
- onClick={() => {
- form.setValue('computeSize', 'ci_large')
- }}
- >
- Change to LARGE Compute
- </Button>
- ) : (
- <RequestUpgradeToBillingOwners
- addon="computeSize"
- featureProposition="adjust disk configuration"
- />
- )
- }
- />
- <NoticeBar
- type="default"
- visible={
- isDiskTooSmallForCustomIops &&
- !disableIopsThroughputConfig &&
- !disableDiskInputs
- }
- title={`Increase disk size to adjust IOPS or throughput`}
- description={`This disk is too small to update IOPS or throughput, since gp3 volumes are capped at 500 IOPS per GB with a 3,000 IOPS minimum. Resizing to ${suggestedDiskSizeForCustomIops} GB unlocks custom IOPS and throughput, and leaves headroom for further adjustments (disk config changes are locked for 4 hours after each resize).`}
- actions={
- !disableDiskSizeInput ? (
- <Button
- variant="default"
- onClick={() => {
- form.setValue('totalSize', suggestedDiskSizeForCustomIops, {
- shouldDirty: true,
- shouldValidate: true,
- })
- }}
- >
- Increase to {suggestedDiskSizeForCustomIops} GB
- </Button>
- ) : undefined
- }
- />
+ {!!disableIopsThroughputConfig && (
+ <Admonition
+ type="default"
+ title="Adjusting disk configuration requires LARGE Compute size or above"
+ description={`Increase your compute size to adjust your disk's storage type, ${form.getValues('storageType') === 'gp3' ? 'IOPS, ' : ''} and throughput`}
+ actions={
+ canUpdateDiskConfiguration ? (
+ <Button
+ variant="default"
+ onClick={() => {
+ form.setValue('computeSize', 'ci_large')
+ }}
+ >
+ Change to LARGE Compute
+ </Button>
+ ) : (
+ <RequestUpgradeToBillingOwners
+ addon="computeSize"
+ featureProposition="adjust disk configuration"
+ />
+ )
+ }
+ />
+ )}
+ {isDiskTooSmallForCustomIops &&
+ !disableIopsThroughputConfig &&
+ !disableDiskInputs && (
+ <Admonition
+ type="default"
+ title="Increase disk size to adjust IOPS or throughput"
+ description={`This disk is too small to update IOPS or throughput, since gp3 volumes are capped at 500 IOPS per GB with a 3,000 IOPS minimum. Resizing to ${suggestedDiskSizeForCustomIops} GB unlocks custom IOPS and throughput, and leaves headroom for further adjustments (disk config changes are locked for 4 hours after each resize).`}
+ actions={
+ !disableDiskSizeInput ? (
+ <Button
+ variant="default"
+ onClick={() => {
+ form.setValue('totalSize', suggestedDiskSizeForCustomIops, {
+ shouldDirty: true,
+ shouldValidate: true,
+ })
+ }}
+ >
+ Increase to {suggestedDiskSizeForCustomIops} GB
+ </Button>
+ ) : undefined
+ }
+ />
+ )}
<StorageTypeField
form={form}
disableInput={disableIopsThroughputConfig || disableDiskInputs}
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
index a1ec081b884..3782edbadd4 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
@@ -14,7 +14,7 @@ import {
TooltipContent,
TooltipTrigger,
} from 'ui'
-import { ComputeBadge } from 'ui-patterns'
+import { Admonition, ComputeBadge } from 'ui-patterns'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { DiskStorageSchemaType } from '../DiskManagement.schema'
@@ -26,7 +26,6 @@ import {
} from '../DiskManagement.utils'
import { BillingChangeBadge } from '../ui/BillingChangeBadge'
import FormMessage from '../ui/FormMessage'
-import { NoticeBar } from '../ui/NoticeBar'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { DocsButton } from '@/components/ui/DocsButton'
import { InlineLink } from '@/components/ui/InlineLink'
@@ -167,14 +166,15 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
/>
</div>
- <NoticeBar
- showIcon={false}
- type="default"
- className="mt-3 border-violet-900 bg-violet-200 [&_h5]:text-violet-1100"
- visible={showUpgradeBadge && form.watch('computeSize') === 'ci_nano'}
- title={'Upgrade to Micro Compute'}
- description="This Project is already paying for Micro Compute. You can upgrade to Micro Compute at any time when convenient."
- />
+ {showUpgradeBadge && form.watch('computeSize') === 'ci_nano' && (
+ <Admonition
+ showIcon={false}
+ type="default"
+ className="mt-3 border-violet-900 bg-violet-200 [&_h5]:text-violet-1100"
+ title="Upgrade to Micro Compute"
+ description="This Project is already paying for Micro Compute. You can upgrade to Micro Compute at any time when convenient."
+ />
+ )}
</>
}
>
diff --git a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx b/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx
deleted file mode 100644
index 388289c7e03..00000000000
--- a/apps/studio/components/interfaces/DiskManagement/ui/NoticeBar.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { AnimatePresence, motion } from 'framer-motion'
-import { type ComponentProps, type ReactNode } from 'react'
-import { cn } from 'ui'
-import { Admonition } from 'ui-patterns'
-
-/**
- * @deprecated Use Admonition from ui-patterns instead
- * Pass actions as a prop to the Admonition component
- */
-
-interface NoticeBarProps extends Omit<ComponentProps<typeof Admonition>, 'description'> {
- title?: string
- description?: string
- icon?: ReactNode
- visible: boolean
- actions?: ReactNode
-}
-export function NoticeBar({ visible, description, actions, ...props }: NoticeBarProps) {
- return (
- <AnimatePresence>
- {visible && (
- <motion.div
- initial={{ opacity: 0, height: 0, y: 4 }}
- animate={{ opacity: 1, height: 'auto', y: 0 }}
- exit={{ opacity: 0, height: 0, y: 4 }}
- transition={{ duration: 0.15 }}
- >
- <Admonition {...props} className={cn(props.className, 'mb-0')}>
- {description}
- <div className="flex flex-col gap-2">
- {actions && <div className="mt-2">{actions}</div>}
- </div>
- </Admonition>
- </motion.div>
- )}
- </AnimatePresence>
- )
-}