The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: db settings form pattern (#41263)
Francesco Sansalvadore40af66c39d0e
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsxindex e9a580af50c..dc491e4902a 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx@@ -1,37 +1,48 @@import Link from 'next/link'import { useParams } from 'common'-import { FormHeader } from 'components/ui/Forms/FormHeader'import { DOCS_URL } from 'lib/constants'import { Button } from 'ui'import { NoticeBar } from './ui/NoticeBar'+import {+ PageSection,+ PageSectionContent,+ PageSectionMeta,+ PageSectionSummary,+ PageSectionTitle,+} from 'ui-patterns'+import { DocsButton } from '../../ui/DocsButton'// [Joshen] Only used for non AWS projectsexport function DiskManagementPanelForm() {const { ref: projectRef } = useParams()return (- <div id="disk-management">- <FormHeader- title="Disk Management"- docsUrl={`${DOCS_URL}/guides/platform/database-size#disk-management`}- />- <NoticeBar- visible={true}- type="default"- title="Disk Management has moved"- description="Disk configuration is now managed alongside Project Compute on the new Compute and Disk page."- actions={- <Button type="default" asChild>- <Link- href={`/project/${projectRef}/settings/compute-and-disk`}- className="!no-underline"- >- Go to Compute and Disk- </Link>- </Button>- }- />- </div>+ <PageSection id="disk-management">+ <PageSectionMeta>+ <PageSectionSummary>+ <PageSectionTitle>Disk Management</PageSectionTitle>+ </PageSectionSummary>+ <DocsButton href={`${DOCS_URL}/guides/platform/database-size#disk-management`} />+ </PageSectionMeta>+ <PageSectionContent>+ <NoticeBar+ visible={true}+ type="default"+ title="Disk Management has moved"+ description="Disk configuration is now managed alongside Project Compute on the new Compute and Disk page."+ actions={+ <Button type="default" asChild>+ <Link+ href={`/project/${projectRef}/settings/compute-and-disk`}+ className="!no-underline"+ >+ Go to Compute and Disk+ </Link>+ </Button>+ }+ />+ </PageSectionContent>+ </PageSection>)}diff --git a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsxindex b71f4ed2537..3d131b50ad9 100644--- a/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx+++ b/apps/studio/components/interfaces/Settings/Database/BannedIPs.tsx@@ -15,8 +15,16 @@ import { useUserIPAddressQuery } from 'data/misc/user-ip-address-query'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { DOCS_URL } from 'lib/constants'-import { Badge, Skeleton } from 'ui'+import { Badge, Card, CardContent, Skeleton } from 'ui'import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'+import {+ PageSection,+ PageSectionMeta,+ PageSectionSummary,+ PageSectionTitle,+ PageSectionContent,+ PageSectionDescription,+} from 'ui-patterns'const BannedIPs = () => {const { ref } = useParams()@@ -72,60 +80,68 @@ const BannedIPs = () => {}return (- <div id="banned-ips">- <div className="flex items-center justify-between mb-6">- <FormHeader- className="mb-0"- title="Network Bans"- description="List of IP addresses that are temporarily blocked if their traffic pattern looks abusive"- />- <DocsButton href={`${DOCS_URL}/reference/cli/supabase-network-bans`} />- </div>- <FormPanel>- {ipListLoading ? (- <div className="px-8 py-4 space-y-4">+ <>+ <PageSection id="banned-ips">+ <PageSectionMeta>+ <PageSectionSummary>+ <PageSectionTitle>Network Bans</PageSectionTitle>+ <PageSectionDescription>+ List of IP addresses that are temporarily blocked if their traffic pattern looks+ abusive+ </PageSectionDescription>+ </PageSectionSummary>+ <DocsButton href={`${DOCS_URL}/reference/cli/supabase-network-bans`} />+ </PageSectionMeta>+ <PageSectionContent></PageSectionContent>+ </PageSection>+ {/* TODO: Remove mockIpList usage - using mock data for UI testing */}+ {ipListLoading ? (+ <Card>+ <CardContent className="space-y-4"><Skeleton className="h-4 w-full" /><Skeleton className="h-4 w-full" />- </div>- ) : ipListError ? (- <AlertError- className="border-0 rounded-none"- error={ipListError}- subject="Failed to retrieve banned IP addresses"- />- ) : ipList && ipList.banned_ipv4_addresses.length > 0 ? (- ipList.banned_ipv4_addresses.map((ip) => (- <div key={ip} className="px-8 py-4 flex items-center justify-between">+ </CardContent>+ </Card>+ ) : ipListError ? (+ <AlertError+ className="border-0 rounded-none"+ error={ipListError}+ subject="Failed to retrieve banned IP addresses"+ />+ ) : ipList.banned_ipv4_addresses.length > 0 ? (+ <Card>+ {ipList.banned_ipv4_addresses.map((ip) => (+ <CardContent key={ip} className="flex items-center justify-between"><div className="flex items-center space-x-5"><Globe size={16} className="text-foreground-lighter" /><p className="text-sm font-mono">{ip}</p>{ip === userIPAddress && <Badge>Your IP address</Badge>}</div>- <div>- <ButtonTooltip- type="default"- disabled={!canUnbanNetworks}- onClick={() => openConfirmationModal(ip)}- tooltip={{- content: {- side: 'bottom',- text: !canUnbanNetworks- ? 'You need additional permissions to unban networks'- : undefined,- },- }}- >- Unban IP- </ButtonTooltip>- </div>- </div>- ))- ) : (- <p className="text-foreground-light text-sm px-8 py-4">+ <ButtonTooltip+ type="default"+ disabled={!canUnbanNetworks}+ onClick={() => openConfirmationModal(ip)}+ tooltip={{+ content: {+ side: 'bottom',+ text: !canUnbanNetworks+ ? 'You need additional permissions to unban networks'+ : undefined,+ },+ }}+ >+ Unban IP+ </ButtonTooltip>+ </CardContent>+ ))}+ </Card>+ ) : (+ <Card>+ <CardContent className="text-foreground-light text-sm">There are no banned IP addresses for your project.- </p>- )}- </FormPanel>+ </CardContent>+ </Card>+ )}<ConfirmationModalvariant="destructive"@@ -142,7 +158,7 @@ const BannedIPs = () => {description: `Are you sure you want to unban this IP address ${selectedIPToUnban}?`,}}/>- </div>+ </>)}diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsxindex 49f2a56007f..10b7e314630 100644--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx@@ -30,6 +30,7 @@ import {FormField_Shadcn_,Form_Shadcn_,Input_Shadcn_,+ PrePostTab,Separator,} from 'ui'import { Admonition } from 'ui-patterns'@@ -140,7 +141,7 @@ export const ConnectionPooling = () => {return (<section id="connection-pooler"><Panel- className="!mb-0"+ noMargintitle={<div className="w-full flex items-center justify-between"><div className="flex items-center gap-x-2">@@ -217,7 +218,7 @@ export const ConnectionPooling = () => {<Form_Shadcn_ {...form}><formid={formId}- className="flex flex-col gap-y-6 w-full"+ className="flex flex-col gap-y-4 w-full"onSubmit={form.handleSubmit(onSubmit)}><FormField_Shadcn_@@ -225,7 +226,7 @@ export const ConnectionPooling = () => {name="default_pool_size"render={({ field }) => (<FormItemLayout- layout="horizontal"+ layout="flex-row-reverse"label="Pool Size"description={<p>@@ -234,18 +235,21 @@ export const ConnectionPooling = () => {based on your compute size of {computeSize}.</p>}+ className="[&>div]:md:w-1/2 [&>div]:xl:w-2/5 [&>div>div]:w-full [&>div>div>div]:min-w-100"><FormControl_Shadcn_>- <Input_Shadcn_- {...field}- type="number"- className="w-full"- value={field.value || ''}- placeholder={defaultPoolSize.toString()}- {...form.register('default_pool_size', {- setValueAs: setValueAsNullableNumber,- })}- />+ <PrePostTab postTab="connections" className="uppercase">+ <Input_Shadcn_+ {...field}+ type="number"+ className="w-full"+ value={field.value || ''}+ placeholder={defaultPoolSize.toString()}+ {...form.register('default_pool_size', {+ setValueAs: setValueAsNullableNumber,+ })}+ />+ </PrePostTab></FormControl_Shadcn_>{!!maxConnData &&(default_pool_size ?? 15) > maxConnData.maxConnections * 0.8 && (@@ -264,13 +268,16 @@ export const ConnectionPooling = () => {)}/>+ <Separator className="bg-border -mx-6 w-[calc(100%+3rem)]" />+<FormField_Shadcn_control={form.control}name="max_client_conn"render={({ field }) => (<FormItemLayout- layout="horizontal"+ layout="flex-row-reverse"label="Max Client Connections"+ className="[&>div]:md:w-1/2 [&>div]:xl:w-2/5 [&>div>div]:w-full [&>div>div>div]:min-w-100"description={<><p>@@ -291,17 +298,19 @@ export const ConnectionPooling = () => {}><FormControl_Shadcn_>- <Input_Shadcn_- {...field}- type="number"- className="w-full"- value={pgbouncerConfig?.max_client_conn || ''}- disabled={true}- placeholder={defaultMaxClientConn.toString()}- {...form.register('max_client_conn', {- setValueAs: setValueAsNullableNumber,- })}- />+ <PrePostTab postTab="clients" className="uppercase">+ <Input_Shadcn_+ {...field}+ type="number"+ className="w-full"+ value={pgbouncerConfig?.max_client_conn || ''}+ disabled={true}+ placeholder={defaultMaxClientConn.toString()}+ {...form.register('max_client_conn', {+ setValueAs: setValueAsNullableNumber,+ })}+ />+ </PrePostTab></FormControl_Shadcn_></FormItemLayout>)}diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsxindex 6b6091715da..9be22d528c1 100644--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx@@ -5,7 +5,6 @@ import { toast } from 'sonner'import { useParams } from 'common'import { useIsProjectActive } from 'components/layouts/ProjectLayout/ProjectContext'import { ButtonTooltip } from 'components/ui/ButtonTooltip'-import Panel from 'components/ui/Panel'import PasswordStrengthBar from 'components/ui/PasswordStrengthBar'import { useDatabasePasswordResetMutation } from 'data/database/database-password-reset-mutation'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'@@ -13,7 +12,8 @@ import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { DEFAULT_MINIMUM_PASSWORD_STRENGTH } from 'lib/constants'import { passwordStrength } from 'lib/password-strength'import { generateStrongPassword } from 'lib/project'-import { Button, Input, Modal } from 'ui'+import { Button, Card, CardContent, Input, Modal } from 'ui'+import { FormLayout } from 'ui-patterns/form/Layout/FormLayout'const ResetDbPassword = ({ disabled = false }) => {const { ref } = useParams()@@ -86,18 +86,13 @@ const ResetDbPassword = ({ disabled = false }) => {return (<>- <Panel className="!m-0">- <Panel.Content>- <div- className="grid grid-cols-1 items-center lg:grid-cols-3 scroll-mt-6"- id="database-password"+ <Card id="database-password">+ <CardContent>+ <FormLayout+ layout="flex-row-reverse"+ label="Database password"+ description="You can use this password to connect directly to your Postgres database.">- <div className="col-span-2 space-y-1">- <p className="block">Database password</p>- <p className="text-sm opacity-50">- You can use this password to connect directly to your Postgres database.- </p>- </div><div className="flex items-end justify-end"><ButtonTooltiptype="default"@@ -117,9 +112,9 @@ const ResetDbPassword = ({ disabled = false }) => {Reset database password</ButtonTooltip></div>- </div>- </Panel.Content>- </Panel>+ </FormLayout>+ </CardContent>+ </Card><ModalhideFooterheader={<h5 className="text-foreground">Reset database password</h5>}diff --git a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsxindex 1bb38636ced..bc8dce9893d 100644--- a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfiguration.tsx@@ -8,7 +8,6 @@ import { useParams } from 'common'import { Markdown } from 'components/interfaces/Markdown'import DiskSizeConfigurationModal from 'components/interfaces/Settings/Database/DiskSizeConfigurationModal'import { ButtonTooltip } from 'components/ui/ButtonTooltip'-import { FormHeader } from 'components/ui/Forms/FormHeader'import Panel from 'components/ui/Panel'import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mutation'import { useDatabaseSizeQuery } from 'data/database/database-size-query'@@ -20,6 +19,14 @@ import { useUrlState } from 'hooks/ui/useUrlState'import { DOCS_URL } from 'lib/constants'import { formatBytes } from 'lib/helpers'import { AlertDescription_Shadcn_, AlertTitle_Shadcn_, Alert_Shadcn_, Button, InfoIcon } from 'ui'+import { DocsButton } from 'components/ui/DocsButton'+import {+ PageSection,+ PageSectionMeta,+ PageSectionSummary,+ PageSectionTitle,+ PageSectionContent,+} from 'ui-patterns'export interface DiskSizeConfigurationProps {disabled?: boolean@@ -66,78 +73,85 @@ const DiskSizeConfiguration = ({ disabled = false }: DiskSizeConfigurationProps)const databaseSizeBytesUsed = data ?? 0return (- <div id="diskManagement">- <FormHeader title="Disk Management" />- {organization?.usage_billing_enabled === true ? (- <div className="flex flex-col gap-3">- <Panel className="!m-0">- <Panel.Content>- <div>- <div>- {currentDiskSize && (- <span className="text-foreground-light flex gap-2 items-baseline">- <h4 className="text-foreground">Current Disk Storage</h4>- </span>- )}- <div className="grid grid-cols-2 items-center">- <p className="text-sm text-lighter max-w-lg">- Supabase employs auto-scaling storage and allows for manual disk size- adjustments when necessary- </p>- {!isAwsNimbus && (- <ButtonTooltip- type="default"- className="w-min ml-auto"- disabled={!canUpdateDiskSizeConfig || disabled}- onClick={() => setShowIncreaseDiskSizeModal(true)}- tooltip={{- content: {- side: 'bottom',- text: !canUpdateDiskSizeConfig- ? 'You need additional permissions to increase the disk size'- : undefined,- },- }}- >- Increase disk size- </ButtonTooltip>- )}- </div>-- <div className="grid grid-cols-12 gap-2 mt-12 items-start">- <div className="col-span-4 grid grid-cols-2 gap-x-12 gap-y-4 items-start">- <div className="grid gap-2 col-span-1">- <h5>Space used</h5>- <span className="text-lg">- {formatBytes(databaseSizeBytesUsed, 2, 'GB')}+ <>+ <PageSection id="disk-management">+ <PageSectionMeta>+ <PageSectionSummary>+ <PageSectionTitle>Disk Management</PageSectionTitle>+ </PageSectionSummary>+ <DocsButton href={`${DOCS_URL}/guides/platform/database-size#disk-management`} />+ </PageSectionMeta>+ <PageSectionContent>+ {organization?.usage_billing_enabled === true ? (+ <div className="flex flex-col gap-3">+ <Panel className="!m-0">+ <Panel.Content>+ <div>+ <div>+ {currentDiskSize && (+ <span className="text-foreground-light flex gap-2 items-baseline">+ <h4 className="text-foreground">Current Disk Storage</h4></span>- </div>- <div className="grid gap-2 col-span-1">- <h5>Total size</h5>- <span className="text-lg">{currentDiskSize} GB</span>+ )}+ <div className="grid grid-cols-2 items-center">+ <p className="text-sm text-lighter max-w-lg">+ Supabase employs auto-scaling storage and allows for manual disk size+ adjustments when necessary+ </p>+ {!isAwsNimbus && (+ <ButtonTooltip+ type="default"+ className="w-min ml-auto"+ disabled={!canUpdateDiskSizeConfig || disabled}+ onClick={() => setShowIncreaseDiskSizeModal(true)}+ tooltip={{+ content: {+ side: 'bottom',+ text: !canUpdateDiskSizeConfig+ ? 'You need additional permissions to increase the disk size'+ : undefined,+ },+ }}+ >+ Increase disk size+ </ButtonTooltip>+ )}</div>- {reportsAll && (- <div className="col-span-2 mt-4">- <Button asChild type="default" iconRight={<ExternalLink size={14} />}>- <Link- href={`/project/${projectRef}/reports/database#database-size-report`}- >- View detailed summary- </Link>- </Button>+ <div className="grid grid-cols-12 gap-2 mt-12 items-start">+ <div className="col-span-4 grid grid-cols-2 gap-x-12 gap-y-4 items-start">+ <div className="grid gap-2 col-span-1">+ <h5>Space used</h5>+ <span className="text-lg">+ {formatBytes(databaseSizeBytesUsed, 2, 'GB')}+ </span>+ </div>+ <div className="grid gap-2 col-span-1">+ <h5>Total size</h5>+ <span className="text-lg">{currentDiskSize} GB</span>+ </div>++ {reportsAll && (+ <div className="col-span-2 mt-4">+ <Button asChild type="default" iconRight={<ExternalLink size={14} />}>+ <Link+ href={`/project/${projectRef}/reports/database#database-size-report`}+ >+ View detailed summary+ </Link>+ </Button>+ </div>+ )}</div>- )}- </div>- <div className="col-span-8">- <Alert_Shadcn_>- <Info size={16} />- <AlertTitle_Shadcn_>Importing a lot of data?</AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- <Markdown- className="max-w-full"- content={`+ <div className="col-span-8">+ <Alert_Shadcn_>+ <Info size={16} />+ <AlertTitle_Shadcn_>Importing a lot of data?</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ <Markdown+ className="max-w-full"+ content={`We auto-scale your disk as you need more storage, but can only do this once every 6 hours.If you upload more than 1.5x the current size of your storage, your database will gointo read-only mode. If you know how big your database is going to be, you can@@ -145,56 +159,60 @@ manually increase the size here.Read more about [disk management](${DOCS_URL}/guides/platform/database-size#disk-management) and how to [free up storage space](${DOCS_URL}/guides/platform/database-size#vacuum-operations).`}- />- </AlertDescription_Shadcn_>- </Alert_Shadcn_>+ />+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ </div>+ </div></div></div>- </div>- </div>- </Panel.Content>- </Panel>- </div>- ) : (- <Alert_Shadcn_>- <InfoIcon />- <AlertTitle_Shadcn_>- {organization?.plan?.id === 'free'- ? 'Disk size configuration is not available for projects on the Free Plan'- : 'Disk size configuration is only available when the spend cap has been disabled'}- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- {organization?.plan?.id === 'free' ? (- <p>- If you are intending to use more than 500MB of disk space, then you will need to- upgrade to at least the Pro Plan.- </p>- ) : (- <p>- If you are intending to use more than 8GB of disk space, then you will need to- disable your spend cap.- </p>- )}- <Button asChild type="default" className="mt-3">- <Link- href={`/org/${organization?.slug}/billing?panel=${- organization?.plan?.id === 'free' ? 'subscriptionPlan' : 'costControl'- }`}- target="_blank"- >- {organization?.plan?.id === 'free' ? 'Upgrade subscription' : 'Disable spend cap'}- </Link>- </Button>- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- )}+ </Panel.Content>+ </Panel>+ </div>+ ) : (+ <Alert_Shadcn_>+ <InfoIcon />+ <AlertTitle_Shadcn_>+ {organization?.plan?.id === 'free'+ ? 'Disk size configuration is not available for projects on the Free Plan'+ : 'Disk size configuration is only available when the spend cap has been disabled'}+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ {organization?.plan?.id === 'free' ? (+ <p>+ If you are intending to use more than 500MB of disk space, then you will need to+ upgrade to at least the Pro Plan.+ </p>+ ) : (+ <p>+ If you are intending to use more than 8GB of disk space, then you will need to+ disable your spend cap.+ </p>+ )}+ <Button asChild type="default" className="mt-3">+ <Link+ href={`/org/${organization?.slug}/billing?panel=${+ organization?.plan?.id === 'free' ? 'subscriptionPlan' : 'costControl'+ }`}+ target="_blank"+ >+ {organization?.plan?.id === 'free'+ ? 'Upgrade subscription'+ : 'Disable spend cap'}+ </Link>+ </Button>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )}+ </PageSectionContent>+ </PageSection><DiskSizeConfigurationModalvisible={showIncreaseDiskSizeModal}loading={isUpdatingDiskSize}hideModal={setShowIncreaseDiskSizeModal}/>- </div>+ </>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsxindex 3cfba7f74b7..0d11d6dc1d0 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions.tsx@@ -5,9 +5,6 @@ import { useState } from 'react'import { useParams } from 'common'import { ButtonTooltip } from 'components/ui/ButtonTooltip'import { DocsButton } from 'components/ui/DocsButton'-import { FormHeader } from 'components/ui/Forms/FormHeader'-import { FormPanel } from 'components/ui/Forms/FormPanel'-import Panel from 'components/ui/Panel'import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { useNetworkRestrictionsQuery } from 'data/network-restrictions/network-restrictions-query'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'@@ -16,6 +13,10 @@ import { DOCS_URL } from 'lib/constants'import {Badge,Button,+ Card,+ CardContent,+ CardDescription,+ CardHeader,DropdownMenu,DropdownMenuContent,DropdownMenuItem,@@ -28,6 +29,14 @@ import AddRestrictionModal from './AddRestrictionModal'import AllowAllModal from './AllowAllModal'import DisallowAllModal from './DisallowAllModal'import RemoveRestrictionModal from './RemoveRestrictionModal'+import {+ PageSection,+ PageSectionAside,+ PageSectionContent,+ PageSectionMeta,+ PageSectionSummary,+ PageSectionTitle,+} from 'ui-patterns'interface AccessButtonProps {disabled: boolean@@ -102,14 +111,12 @@ export const NetworkRestrictions = () => {return (<>- <section id="network-restrictions">- <div className="flex items-center justify-between mb-6">- <FormHeader- className="mb-0"- title="Network Restrictions"- description="Allow specific IP ranges to have access to your database."- />- <div className="flex items-center gap-x-2">+ <PageSection id="network-restrictions">+ <PageSectionMeta>+ <PageSectionSummary>+ <PageSectionTitle>Network Restrictions</PageSectionTitle>+ </PageSectionSummary>+ <PageSectionAside className="flex items-center gap-x-2"><DocsButton href={`${DOCS_URL}/guides/platform/network-restrictions`} />{!canUpdateNetworkRestrictions ? (<ButtonTooltip@@ -153,104 +160,32 @@ export const NetworkRestrictions = () => {</DropdownMenuContent></DropdownMenu>)}- </div>- </div>- {isLoading ? (- <Panel>- <Panel.Content>- <div className="space-y-2">- <ShimmeringLoader />- <ShimmeringLoader className="w-[70%]" />- <ShimmeringLoader className="w-[50%]" />- </div>- </Panel.Content>- </Panel>- ) : hasApplyError ? (- <Panel>- <Panel.Content>- <div className="flex items-center justify-between">+ </PageSectionAside>+ </PageSectionMeta>+ <PageSectionContent>+ {isLoading ? (+ <Card>+ <CardContent><div className="space-y-2">- <div className="flex items-center space-x-2">- <AlertCircle size={20} strokeWidth={1.5} className="text-foreground-light" />- <p className="text-sm">Your network restrictions were not applied correctly</p>- </div>- <p className="text-sm text-foreground-light">- Please try to add your network restrictions again- </p>- </div>- <div className="flex items-center space-x-2">- <AllowAllAccessButton- disabled={!canUpdateNetworkRestrictions}- onClick={setIsAllowingAll}- />- <DisallowAllAccessButton- disabled={!canUpdateNetworkRestrictions}- onClick={setIsDisallowingAll}- />+ <ShimmeringLoader />+ <ShimmeringLoader className="w-[70%]" />+ <ShimmeringLoader className="w-[50%]" /></div>- </div>- </Panel.Content>- </Panel>- ) : (- <FormPanel>- {isUninitialized || isAllowedAll ? (- <div className="px-8 py-8 flex items-center justify-between">- <div className="flex items-start space-x-4">- <div className="space-y-1">- <p className="text-foreground-light text-sm">- Your database can be accessed by all IP addresses- </p>- <p className="text-foreground-light text-sm">- You may start limiting access to your database by adding a network- restriction.- </p>- </div>- </div>- <div>- <DisallowAllAccessButton- disabled={!canUpdateNetworkRestrictions}- onClick={setIsDisallowingAll}- />- </div>- </div>- ) : isDisallowedAll ? (- <div className="px-8 py-8 flex items-center justify-between">- <div className="flex items-start space-x-4">- <Lock size={20} className="text-foreground-light" strokeWidth={1.5} />- <div className="space-y-1">- <p className="text-foreground-light text-sm">- Your database <span className="text-amber-900 opacity-80">cannot</span> be- accessed externally- </p>- <p className="text-foreground-light text-sm">- All external IP addresses have been disallowed from accessing your project's- database.- </p>- <p className="text-foreground-light text-sm">- Note: Restrictions only apply to your database, and not to Supabase services- </p>- </div>- </div>- <div>- <AllowAllAccessButton- disabled={!canUpdateNetworkRestrictions}- onClick={setIsAllowingAll}- />- </div>- </div>- ) : (- <div className="divide-y">- <div className="px-8 py-3 flex items-center justify-between">- <div>- <p className="text-foreground-light text-sm">- Only the following IP addresses have access to your database- </p>- <p className="text-foreground-light text-sm">- You may remove all of them to allow all IP addresses to have access to your- database- </p>- <p className="text-foreground-light text-sm">- Note: Restrictions only apply to your database, and not to Supabase services+ </CardContent>+ </Card>+ ) : hasApplyError ? (+ <Card>+ <CardContent>+ <div className="flex items-center justify-between">+ <div className="space-y-2">+ <div className="flex items-center space-x-2">+ <AlertCircle size={20} strokeWidth={1.5} className="text-foreground-light" />+ <p className="text-sm">+ Your network restrictions were not applied correctly+ </p>+ </div>+ <p className="text-sm text-foreground-light">+ Please try to add your network restrictions again</p></div><div className="flex items-center space-x-2">@@ -264,25 +199,106 @@ export const NetworkRestrictions = () => {/></div></div>- {restrictedIps.map((ip) => {- return (- <div key={ip} className="px-8 py-4 flex items-center justify-between">- <div className="flex items-center space-x-5">- <Globe size={16} className="text-foreground-light" />- <Badge>{ipv4Restrictions.includes(ip) ? 'IPv4' : 'IPv6'}</Badge>- <p className="text-sm font-mono">{ip}</p>- </div>- <Button type="default" onClick={() => setSelectedRestrictionToRemove(ip)}>- Remove- </Button>+ </CardContent>+ </Card>+ ) : (+ <Card>+ {isUninitialized || isAllowedAll ? (+ <CardContent className="flex items-center justify-between">+ <div className="flex items-start space-x-4">+ <div className="space-y-1">+ <p className="text-foreground-light text-sm">+ Your database can be accessed by all IP addresses+ </p>+ <p className="text-foreground-light text-sm">+ You may start limiting access to your database by adding a network+ restriction.+ </p></div>- )- })}- </div>- )}- </FormPanel>- )}- </section>+ </div>+ <div>+ <DisallowAllAccessButton+ disabled={!canUpdateNetworkRestrictions}+ onClick={setIsDisallowingAll}+ />+ </div>+ </CardContent>+ ) : isDisallowedAll ? (+ <CardContent className="flex items-center justify-between">+ <div className="flex items-start space-x-4">+ <Lock size={20} className="text-foreground-light" strokeWidth={1.5} />+ <div className="space-y-1">+ <p className="text-foreground-light text-sm">+ Your database <span className="text-amber-900 opacity-80">cannot</span> be+ accessed externally+ </p>+ <p className="text-foreground-light text-sm">+ All external IP addresses have been disallowed from accessing your project's+ database.+ </p>+ <p className="text-foreground-light text-sm">+ Note: Restrictions only apply to your database, and not to Supabase services+ </p>+ </div>+ </div>+ <div>+ <AllowAllAccessButton+ disabled={!canUpdateNetworkRestrictions}+ onClick={setIsAllowingAll}+ />+ </div>+ </CardContent>+ ) : (+ <>+ <CardHeader className="md:flex-row md:items-center justify-between">+ <CardDescription className="text-foreground-light">+ <p>Only the following IP addresses have access to your database.</p>+ <p>+ You may remove all of them to allow all IP addresses to have access to your+ database.+ </p>+ <p>+ Note: Restrictions only apply to your database, and not to Supabase services+ </p>+ </CardDescription>+ <div className="flex items-center space-x-2">+ <AllowAllAccessButton+ disabled={!canUpdateNetworkRestrictions}+ onClick={setIsAllowingAll}+ />+ <DisallowAllAccessButton+ disabled={!canUpdateNetworkRestrictions}+ onClick={setIsDisallowingAll}+ />+ </div>+ </CardHeader>+ <CardContent className="py-0">+ <div className="divide-y">+ {restrictedIps.map((ip) => {+ return (+ <div key={ip} className="py-4 flex items-center justify-between">+ <div className="flex items-center space-x-5">+ <Globe size={16} className="text-foreground-lighter" />+ <Badge>{ipv4Restrictions.includes(ip) ? 'IPv4' : 'IPv6'}</Badge>+ <p className="text-sm font-mono">{ip}</p>+ </div>+ <Button+ type="default"+ onClick={() => setSelectedRestrictionToRemove(ip)}+ >+ Remove+ </Button>+ </div>+ )+ })}+ </div>+ </CardContent>+ </>+ )}+ </Card>+ )}+ </PageSectionContent>+ </PageSection><AllowAllModal visible={isAllowingAll} onClose={() => setIsAllowingAll(false)} /><DisallowAllModal visible={isDisallowingAll} onClose={() => setIsDisallowingAll(false)} />diff --git a/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx b/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsxindex 2065ccb2fc6..140b5bd2f09 100644--- a/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx+++ b/apps/studio/components/interfaces/Settings/Database/SSLConfiguration.tsx@@ -8,9 +8,6 @@ import { useParams } from 'common'import { SupportLink } from 'components/interfaces/Support/SupportLink'import { ButtonTooltip } from 'components/ui/ButtonTooltip'import { DocsButton } from 'components/ui/DocsButton'-import { FormHeader } from 'components/ui/Forms/FormHeader'-import { FormPanel } from 'components/ui/Forms/FormPanel'-import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms/FormSection'import { InlineLinkClassName } from 'components/ui/InlineLink'import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'import { useSSLEnforcementQuery } from 'data/ssl-enforcement/ssl-enforcement-query'@@ -19,7 +16,24 @@ import { useCustomContent } from 'hooks/custom-content/useCustomContent'import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'import { DOCS_URL } from 'lib/constants'-import { Alert, Button, Switch, Tooltip, TooltipContent, TooltipTrigger } from 'ui'+import {+ Alert,+ Button,+ Card,+ CardContent,+ Switch,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from 'ui'+import {+ PageSection,+ PageSectionMeta,+ PageSectionSummary,+ PageSectionTitle,+ PageSectionContent,+} from 'ui-patterns'+import { FormLayout } from 'ui-patterns/form/Layout/FormLayout'const SSLConfiguration = () => {const { ref } = useParams()@@ -88,111 +102,100 @@ const SSLConfiguration = () => {}return (- <div id="ssl-configuration">- <div className="flex items-center justify-between mb-6">- <FormHeader className="mb-0" title="SSL Configuration" description="" />+ <PageSection id="ssl-configuration">+ <PageSectionMeta>+ <PageSectionSummary>+ <PageSectionTitle>SSL Configuration</PageSectionTitle>+ </PageSectionSummary><DocsButton href={`${DOCS_URL}/guides/platform/ssl-enforcement`} />- </div>- <FormPanel>- <FormSection- header={- <FormSectionLabel- className="lg:col-span-7"- description={- <div className="space-y-4">- <p className="text-sm text-foreground-light">- Reject non-SSL connections to your database- </p>- {isSuccess && !sslEnforcementConfiguration?.appliedSuccessfully && (- <Alert- withIcon- variant="warning"- title="SSL enforcement was not updated successfully"- >- Please try updating again, or contact{' '}- <SupportLink className={InlineLinkClassName}>support</SupportLink> if this- error persists- </Alert>- )}- </div>- }+ </PageSectionMeta>+ <PageSectionContent>+ <Card>+ <CardContent className="space-y-4">+ <FormLayout+ layout="flex-row-reverse"+ label="Enforce SSL on incoming connections"+ description="Reject non-SSL connections to your database">- Enforce SSL on incoming connections- </FormSectionLabel>- }- >- <FormSectionContent loading={false} className="lg:!col-span-5">- <div className="flex items-center justify-end mt-2.5 space-x-2">- {(isLoading || isSubmitting) && (- <Loader2 className="animate-spin" strokeWidth={1.5} size={16} />- )}- {isSuccess && (- <Tooltip>- <TooltipTrigger asChild>- {/* [Joshen] Added div as tooltip is messing with data state property of toggle */}- <div>- <Switch- size="large"- checked={isEnforced}- disabled={- isLoading ||- isSubmitting ||- !canUpdateSSLEnforcement ||- !hasAccessToSSLEnforcement- }- onCheckedChange={toggleSSLEnforcement}- />- </div>- </TooltipTrigger>- {(!canUpdateSSLEnforcement || !hasAccessToSSLEnforcement) && (- <TooltipContent side="bottom" className="w-64 text-center">- {!canUpdateSSLEnforcement- ? 'You need additional permissions to update SSL enforcement for your project'- : !hasAccessToSSLEnforcement- ? 'Your project does not have access to SSL enforcement'- : undefined}- </TooltipContent>- )}- </Tooltip>- )}- </div>- </FormSectionContent>- </FormSection>-- <div className="grid grid-cols-1 items-center lg:grid-cols-2 p-8">- <div className="space-y-2">- <p className="block text-sm">SSL Certificate</p>- <div style={{ maxWidth: '420px' }}>- <p className="text-sm opacity-50">- Use this certificate when connecting to your database to prevent snooping and- man-in-the-middle attacks.- </p>- </div>- </div>- <div className="flex items-end justify-end">- {!hasSSLCertificate ? (- <ButtonTooltip- disabled- type="default"- icon={<Download />}- tooltip={{- content: {- side: 'bottom',- text: 'Projects before 15:08 (GMT+08), 29th April 2021 do not have SSL certificates installed',- },- }}+ <div className="flex items-center justify-end mt-2.5 space-x-2">+ {(isLoading || isSubmitting) && (+ <Loader2 className="animate-spin" strokeWidth={1.5} size={16} />+ )}+ {isSuccess && (+ <Tooltip>+ <TooltipTrigger asChild>+ {/* [Joshen] Added div as tooltip is messing with data state property of toggle */}+ <div>+ <Switch+ size="large"+ checked={isEnforced}+ disabled={+ isLoading ||+ isSubmitting ||+ !canUpdateSSLEnforcement ||+ !hasAccessToSSLEnforcement+ }+ onCheckedChange={toggleSSLEnforcement}+ />+ </div>+ </TooltipTrigger>+ {(!canUpdateSSLEnforcement || !hasAccessToSSLEnforcement) && (+ <TooltipContent side="bottom" className="w-64 text-center">+ {!canUpdateSSLEnforcement+ ? 'You need additional permissions to update SSL enforcement for your project'+ : !hasAccessToSSLEnforcement+ ? 'Your project does not have access to SSL enforcement'+ : undefined}+ </TooltipContent>+ )}+ </Tooltip>+ )}+ </div>+ </FormLayout>+ {isSuccess && !sslEnforcementConfiguration?.appliedSuccessfully && (+ <Alert+ withIcon+ variant="warning"+ title="SSL enforcement was not updated successfully">- Download certificate- </ButtonTooltip>- ) : (- <Button type="default" icon={<Download />}>- <a href={sslCertificateUrl}>Download certificate</a>- </Button>+ Please try updating again, or contact{' '}+ <SupportLink className={InlineLinkClassName}>support</SupportLink> if this error+ persists+ </Alert>)}- </div>- </div>- </FormPanel>- </div>+ </CardContent>+ <CardContent>+ <FormLayout+ layout="flex-row-reverse"+ label="SSL Certificate"+ description="Use this certificate when connecting to your database to prevent snooping and man-in-the-middle attacks."+ >+ <div className="flex items-end justify-end">+ {!hasSSLCertificate ? (+ <ButtonTooltip+ disabled+ type="default"+ icon={<Download />}+ tooltip={{+ content: {+ side: 'bottom',+ text: 'Projects before 15:08 (GMT+08), 29th April 2021 do not have SSL certificates installed',+ },+ }}+ >+ Download certificate+ </ButtonTooltip>+ ) : (+ <Button type="default" icon={<Download />}>+ <a href={sslCertificateUrl}>Download certificate</a>+ </Button>+ )}+ </div>+ </FormLayout>+ </CardContent>+ </Card>+ </PageSectionContent>+ </PageSection>)}diff --git a/apps/studio/pages/project/[ref]/database/settings.tsx b/apps/studio/pages/project/[ref]/database/settings.tsxindex 92e92c575fa..4be4dd1850d 100644--- a/apps/studio/pages/project/[ref]/database/settings.tsx+++ b/apps/studio/pages/project/[ref]/database/settings.tsx@@ -1,17 +1,12 @@-import { DiskManagementPanelForm } from 'components/interfaces/DiskManagement/DiskManagementPanelForm'-import BannedIPs from 'components/interfaces/Settings/Database/BannedIPs'+import dynamic from 'next/dynamic'import { ConnectionPooling } from 'components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling'import { DatabaseReadOnlyAlert } from 'components/interfaces/Settings/Database/DatabaseReadOnlyAlert'import ResetDbPassword from 'components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword'-import DiskSizeConfiguration from 'components/interfaces/Settings/Database/DiskSizeConfiguration'-import { NetworkRestrictions } from 'components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions'import { PoolingModesModal } from 'components/interfaces/Settings/Database/PoolingModesModal'-import SSLConfiguration from 'components/interfaces/Settings/Database/SSLConfiguration'import DatabaseLayout from 'components/layouts/DatabaseLayout/DatabaseLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import { useIsAwsCloudProvider, useIsAwsK8sCloudProvider } from 'hooks/misc/useSelectedProject'-import type { NextPageWithLayout } from 'types'import { PageContainer } from 'ui-patterns/PageContainer'import {PageHeader,@@ -20,13 +15,30 @@ import {PageHeaderTitle,} from 'ui-patterns/PageHeader'import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'+import type { NextPageWithLayout } from 'types'++const SSLConfiguration = dynamic(+ () => import('components/interfaces/Settings/Database/SSLConfiguration')+)+const DiskSizeConfiguration = dynamic(+ () => import('components/interfaces/Settings/Database/DiskSizeConfiguration')+)+const NetworkRestrictions = dynamic(() =>+ import('components/interfaces/Settings/Database/NetworkRestrictions/NetworkRestrictions').then(+ (mod) => mod.NetworkRestrictions+ )+)+const BannedIPs = dynamic(() => import('components/interfaces/Settings/Database/BannedIPs'))+const DiskManagementPanelForm = dynamic(() =>+ import('components/interfaces/DiskManagement/DiskManagementPanelForm').then(+ (mod) => mod.DiskManagementPanelForm+ )+)const ProjectSettings: NextPageWithLayout = () => {const isAws = useIsAwsCloudProvider()const isAwsK8s = useIsAwsK8sCloudProvider()-const showNewDiskManagementUI = isAws || isAwsK8s-const { databaseNetworkRestrictions } = useIsFeatureEnabled(['database:network_restrictions'])return (@@ -38,28 +50,23 @@ const ProjectSettings: NextPageWithLayout = () => {</PageHeaderSummary></PageHeaderMeta></PageHeader>- <PageContainer>+ <PageContainer className="pb-12"><PageSection>- <PageSectionContent>- <div className="space-y-10">- <div className="flex flex-col gap-y-10">- <DatabaseReadOnlyAlert />- <ResetDbPassword />- <ConnectionPooling />- </div>-- <SSLConfiguration />- {showNewDiskManagementUI ? (- // This form is hidden if Disk and Compute form is enabled, new form is on ./settings/compute-and-disk- <DiskManagementPanelForm />- ) : (- <DiskSizeConfiguration />- )}- {databaseNetworkRestrictions && <NetworkRestrictions />}- <BannedIPs />- </div>+ <PageSectionContent className="space-y-4 md:space-y-8">+ <DatabaseReadOnlyAlert />+ <ResetDbPassword />+ <ConnectionPooling /></PageSectionContent></PageSection>+ <SSLConfiguration />+ {showNewDiskManagementUI ? (+ // This form is hidden if Disk and Compute form is enabled, new form is on ./settings/compute-and-disk+ <DiskManagementPanelForm />+ ) : (+ <DiskSizeConfiguration />+ )}+ {databaseNetworkRestrictions && <NetworkRestrictions />}+ <BannedIPs /></PageContainer><PoolingModesModal /></>diff --git a/packages/ui-patterns/src/form/Layout/FormLayout.tsx b/packages/ui-patterns/src/form/Layout/FormLayout.tsxindex 065be23a480..a92a60f449d 100644--- a/packages/ui-patterns/src/form/Layout/FormLayout.tsx+++ b/packages/ui-patterns/src/form/Layout/FormLayout.tsx@@ -82,7 +82,7 @@ const LabelContainerVariants = cva('transition-all duration-500 ease-in-out', {horizontal: 'flex flex-col gap-2 col-span-4',vertical: 'flex flex-row gap-2 justify-between',flex: 'flex flex-col gap-0 min-w-0',- 'flex-row-reverse': 'flex flex-col min-w-0',+ 'flex-row-reverse': 'flex flex-col min-w-0 flex-grow',},labelLayout: {horizontal: '',diff --git a/packages/ui/src/components/PrePostTab/PrePostTab.tsx b/packages/ui/src/components/PrePostTab/PrePostTab.tsxindex be2180673f6..d8ce22fcc50 100644--- a/packages/ui/src/components/PrePostTab/PrePostTab.tsx+++ b/packages/ui/src/components/PrePostTab/PrePostTab.tsx@@ -12,7 +12,7 @@ export const PrePostTab = forwardRef<HTMLDivElement, PropsWithChildren<PrePostTa<div ref={ref} {...props} className={cn('flex -space-x-px', className)}>{preTab && (<div className="border border-strong bg-surface-300 rounded-l-md px-3 flex items-center justify-center">- <span className="text-foreground-lighter text-xs font-mono">{preTab}</span>+ <span className="text-foreground-light text-xs font-mono">{preTab}</span></div>)}<div@@ -27,7 +27,7 @@ export const PrePostTab = forwardRef<HTMLDivElement, PropsWithChildren<PrePostTa</div>{postTab && (<div className="border border-strong bg-surface-300 rounded-r-md px-3 flex items-center justify-center">- <span className="text-foreground-lighter text-xs font-mono">{postTab}</span>+ <span className="text-foreground-light text-xs font-mono">{postTab}</span></div>)}</div>diff --git a/packages/ui/src/components/shadcn/ui/card.tsx b/packages/ui/src/components/shadcn/ui/card.tsxindex 19db1bd8de6..53fc99db2f2 100644--- a/packages/ui/src/components/shadcn/ui/card.tsx+++ b/packages/ui/src/components/shadcn/ui/card.tsx@@ -41,7 +41,7 @@ const CardDescription = React.forwardRef<HTMLParagraphElement,React.HTMLAttributes<HTMLParagraphElement>>(({ className, ...props }, ref) => (- <p ref={ref} className={cn('text-sm text-foreground-muted', className)} {...props} />+ <p ref={ref} className={cn('text-sm text-foreground-lighter', className)} {...props} />))CardDescription.displayName = 'CardDescription'