The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: migrate database settings `Modal` to `Dialog` (#46270)
Gildas Garcia3c2255c27c43
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModal.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModal.tsxindex 93753a94739..6d1086a1941 100644--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ConfirmDisableReadOnlyModal.tsx@@ -1,6 +1,15 @@import { useParams } from 'common'import { toast } from 'sonner'-import { Modal } from 'ui'+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from 'ui'import { useDisableReadOnlyModeMutation } from '@/data/config/project-temp-disable-read-only-mutation'@@ -14,7 +23,7 @@ const ConfirmDisableReadOnlyModeModal = ({onClose,}: ConfirmDisableReadOnlyModeModalProps) => {const { ref } = useParams()- const { mutate: disableReadOnlyMode, isPending } = useDisableReadOnlyModeMutation({+ const { mutateAsync: disableReadOnlyMode, isPending } = useDisableReadOnlyModeMutation({onSuccess: () => {toast.success('Successfully disabled read-only mode for 15 minutes')onClose()@@ -22,31 +31,40 @@ const ConfirmDisableReadOnlyModeModal = ({})return (- <Modal- alignFooter="right"- visible={visible}- onCancel={onClose}- loading={isPending}- confirmText="Disable read-only mode"- header="Confirm to temporarily disable read-only mode"- onConfirm={() => {- if (!ref) return console.error('Project ref is required')- disableReadOnlyMode({ projectRef: ref })- }}- >- <Modal.Content className="space-y-2">- <p className="text-sm">- This will temporarily allow writes to your database for the{' '}- <span className="text-amber-900">next 15 minutes</span>, during which you can reduce your- database size. After deleting data, you should run a vacuum to reclaim as much space as- possible.- </p>- <p className="text-sm">- If your database size has not been sufficiently reduced after 15 minutes, read-only mode- will be toggled back on. Otherwise, it will stay disabled.- </p>- </Modal.Content>- </Modal>+ <AlertDialog open={visible} onOpenChange={onClose}>+ <AlertDialogContent size="medium">+ <AlertDialogHeader>+ <AlertDialogTitle>Confirm to temporarily disable read-only mode</AlertDialogTitle>+ <AlertDialogDescription>+ <div className="flex flex-col space-y-2">+ <p className="text-sm">+ This will temporarily allow writes to your database for the{' '}+ <span className="text-amber-900">next 15 minutes</span>, during which you can reduce+ your database size. After deleting data, you should run a vacuum to reclaim as much+ space as possible.+ </p>+ <p className="text-sm">+ If your database size has not been sufficiently reduced after 15 minutes, read-only+ mode will be toggled back on. Otherwise, it will stay disabled.+ </p>+ </div>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel disabled={isPending}>Cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={async () => {+ if (!ref) return console.error('Project ref is required')+ await disableReadOnlyMode({ projectRef: ref })+ }}+ disabled={isPending}+ loading={isPending}+ >+ Disable read-only mode+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>)}diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsxindex ae8f3d56825..502d5c4485d 100644--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx@@ -2,7 +2,19 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useParams } from 'common'import { useEffect, useState } from 'react'import { toast } from 'sonner'-import { Button, Card, CardContent, Modal } from 'ui'+import {+ Button,+ Card,+ CardContent,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,+ DialogTrigger,+} from 'ui'import { Input } from 'ui-patterns/DataInputs/Input'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import {@@ -112,81 +124,78 @@ const ResetDbPassword = ({ disabled = false }) => {existing connections.</p></div>-- <ButtonTooltip- type="default"- disabled={!canResetDbPassword || !isProjectActive || disabled}- onClick={() => setShowResetDbPass(true)}- tooltip={{- content: {- side: 'bottom',- text: !canResetDbPassword- ? 'You need additional permissions to reset the database password'- : !isProjectActive- ? 'Unable to reset database password as project is not active'- : undefined,- },- }}- >- Reset password- </ButtonTooltip>+ <Dialog open={showResetDbPass} onOpenChange={(open) => setShowResetDbPass(open)}>+ <DialogTrigger asChild>+ <ButtonTooltip+ type="default"+ disabled={!canResetDbPassword || !isProjectActive || disabled}+ tooltip={{+ content: {+ side: 'bottom',+ text: !canResetDbPassword+ ? 'You need additional permissions to reset the database password'+ : !isProjectActive+ ? 'Unable to reset database password as project is not active'+ : undefined,+ },+ }}+ >+ Reset password+ </ButtonTooltip>+ </DialogTrigger>+ <DialogContent size="medium">+ <DialogHeader>+ <DialogTitle>Reset database password</DialogTitle>+ </DialogHeader>+ <DialogSectionSeparator />+ <DialogSection className="w-full space-y-8">+ <FormItemLayout+ layout="vertical"+ isReactForm={false}+ error={passwordStrengthWarning}+ description={+ <PasswordStrengthBar+ passwordStrengthScore={passwordStrengthScore as PasswordStrengthScore}+ passwordStrengthMessage={passwordStrengthMessage}+ password={password}+ generateStrongPassword={generatePassword}+ />+ }+ >+ <Input+ copy={password.length > 0}+ aria-invalid={!!passwordStrengthWarning}+ type="password"+ placeholder="Type in a strong password"+ value={password}+ autoComplete="off"+ onChange={onDbPassChange}+ />+ </FormItemLayout>+ </DialogSection>+ <DialogFooter>+ <Button+ type="default"+ disabled={isUpdatingPassword}+ onClick={() => setShowResetDbPass(false)}+ >+ Cancel+ </Button>+ <Button+ type="primary"+ loading={isUpdatingPassword}+ disabled={isUpdatingPassword}+ onClick={() => confirmResetDbPass()}+ >+ Reset password+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog></CardContent></Card></PageSectionContent></PageSection>- <Modal- hideFooter- header="Reset database password"- confirmText="Reset password"- size="medium"- visible={showResetDbPass}- loading={isUpdatingPassword}- onCancel={() => setShowResetDbPass(false)}- >- <Modal.Content className="w-full space-y-8">- <FormItemLayout- layout="vertical"- isReactForm={false}- error={passwordStrengthWarning}- description={- <PasswordStrengthBar- passwordStrengthScore={passwordStrengthScore as PasswordStrengthScore}- passwordStrengthMessage={passwordStrengthMessage}- password={password}- generateStrongPassword={generatePassword}- />- }- >- <Input- copy={password.length > 0}- aria-invalid={!!passwordStrengthWarning}- type="password"- placeholder="Type in a strong password"- value={password}- autoComplete="off"- onChange={onDbPassChange}- />- </FormItemLayout>- </Modal.Content>- <Modal.Separator />- <Modal.Content className="flex items-center justify-end space-x-2">- <Button- type="default"- disabled={isUpdatingPassword}- onClick={() => setShowResetDbPass(false)}- >- Cancel- </Button>- <Button- type="primary"- loading={isUpdatingPassword}- disabled={isUpdatingPassword}- onClick={() => confirmResetDbPass()}- >- Reset password- </Button>- </Modal.Content>- </Modal></>)}diff --git a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsx b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsxindex 94490aa5b08..37122e8b739 100644--- a/apps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/DiskSizeConfigurationModal.tsx@@ -12,6 +12,13 @@ import {AlertDescription,AlertTitle,Button,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,Form,FormControl,FormField,@@ -20,7 +27,6 @@ import {InputGroup,InputGroupAddon,InputGroupText,- Modal,WarningIcon,} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'@@ -120,152 +126,150 @@ const DiskSizeConfigurationModal = ({}, [INITIAL_VALUES, isDirty, reset])return (- <Modal- header="Increase Disk Storage Size"- size="medium"- visible={visible}- loading={loading}- onCancel={() => hideModal(false)}- hideFooter- >- {isLoading ? (- <div className="flex flex-col gap-4 p-4">- <ShimmeringLoader />- <ShimmeringLoader />- </div>- ) : projectSubscriptionData?.usage_billing_enabled === true &&- hasAccessToDiskModifications ? (- <>- {currentDiskSize >= maxDiskSize ? (- <Alert variant="warning" className="rounded-t-none border-0">- <WarningIcon />- <AlertTitle>Maximum manual disk size increase reached</AlertTitle>- <AlertDescription>+ <Dialog open={visible} onOpenChange={(open) => hideModal(open)}>+ <DialogContent size="medium">+ <DialogHeader>+ <DialogTitle>Increase Disk Storage Size</DialogTitle>+ </DialogHeader>+ <DialogSectionSeparator />+ {isLoading ? (+ <div className="flex flex-col gap-4 p-4">+ <ShimmeringLoader />+ <ShimmeringLoader />+ </div>+ ) : projectSubscriptionData?.usage_billing_enabled === true &&+ hasAccessToDiskModifications ? (+ <>+ {currentDiskSize >= maxDiskSize ? (+ <Alert variant="warning" className="rounded-t-none border-0">+ <WarningIcon />+ <AlertTitle>Maximum manual disk size increase reached</AlertTitle>+ <AlertDescription>+ <p>+ You cannot manually expand the disk size any more than {maxDiskSize}GB. If you+ need more than this, contact us via support for help.+ </p>+ <Button asChild type="default" className="mt-3">+ <SupportLink+ queryParams={{+ projectRef,+ category: SupportCategories.PERFORMANCE_ISSUES,+ subject: 'Increase disk size beyond 200GB',+ }}+ >+ Contact support+ </SupportLink>+ </Button>+ </AlertDescription>+ </Alert>+ ) : (+ <>+ <DialogSection className="w-full space-y-4">+ <Alert variant={isAbleToResizeDatabase ? 'default' : 'warning'}>+ <Info size={16} />+ <AlertTitle>This operation is only possible every 4 hours</AlertTitle>+ <AlertDescription>+ <div className="mb-4">+ {isAbleToResizeDatabase+ ? `Upon updating your disk size, the next disk size update will only be available from ${dayjs().format(+ 'DD MMM YYYY, HH:mm (ZZ)'+ )}`+ : `Your database was last resized at ${dayjs(lastDatabaseResizeAt).format(+ 'DD MMM YYYY, HH:mm (ZZ)'+ )}. You can resize your database again in approximately ${formattedTimeTillNextAvailableResize}`}+ </div>+ <Button asChild type="default" iconRight={<ExternalLink size={14} />}>+ <Link href={`${DOCS_URL}/guides/platform/database-size#disk-management`}>+ Read more about disk management+ </Link>+ </Button>+ </AlertDescription>+ </Alert>+ <Form {...form}>+ <form id={formId} onSubmit={form.handleSubmit(handleSubmit)} noValidate>+ <FormField+ control={form.control}+ name="new-disk-size"+ disabled={!isAbleToResizeDatabase}+ render={({ field }) => (+ <FormItemLayout+ name="new-disk-size"+ layout="vertical"+ label="New disk size"+ >+ <FormControl>+ <InputGroup>+ <FormInputGroupInput+ {...field}+ id="new-disk-size"+ type="number"+ onChange={(e) => field.onChange(Number(e.target.value))}+ />+ <InputGroupAddon align="inline-end">+ <InputGroupText>GB</InputGroupText>+ </InputGroupAddon>+ </InputGroup>+ </FormControl>+ </FormItemLayout>+ )}+ />+ </form>+ </Form>+ </DialogSection>+ <DialogFooter>+ <Button type="default" onClick={() => hideModal(false)}>+ Cancel+ </Button>+ <Button+ form={formId}+ htmlType="submit"+ type="primary"+ disabled={!isAbleToResizeDatabase || isUpdatingDiskSize || !isDirty || loading}+ loading={isUpdatingDiskSize || loading}+ >+ Update disk size+ </Button>+ </DialogFooter>+ </>+ )}+ </>+ ) : (+ <Alert className="border-none">+ <InfoIcon />+ <AlertTitle>+ {hasAccessToDiskModifications === false+ ? '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>+ <AlertDescription>+ {hasAccessToDiskModifications === false ? (<p>- You cannot manually expand the disk size any more than {maxDiskSize}GB. If you- need more than this, contact us via support for help.+ 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>- <Button asChild type="default" className="mt-3">- <SupportLink- queryParams={{- projectRef,- category: SupportCategories.PERFORMANCE_ISSUES,- subject: 'Increase disk size beyond 200GB',- }}- >- Contact support- </SupportLink>- </Button>- </AlertDescription>- </Alert>- ) : (- <>- <Modal.Content className="w-full space-y-4">- <Alert variant={isAbleToResizeDatabase ? 'default' : 'warning'}>- <Info size={16} />- <AlertTitle>This operation is only possible every 4 hours</AlertTitle>- <AlertDescription>- <div className="mb-4">- {isAbleToResizeDatabase- ? `Upon updating your disk size, the next disk size update will only be available from ${dayjs().format(- 'DD MMM YYYY, HH:mm (ZZ)'- )}`- : `Your database was last resized at ${dayjs(lastDatabaseResizeAt).format(- 'DD MMM YYYY, HH:mm (ZZ)'- )}. You can resize your database again in approximately ${formattedTimeTillNextAvailableResize}`}- </div>- <Button asChild type="default" iconRight={<ExternalLink size={14} />}>- <Link href={`${DOCS_URL}/guides/platform/database-size#disk-management`}>- Read more about disk management- </Link>- </Button>- </AlertDescription>- </Alert>- <Form {...form}>- <form id={formId} onSubmit={form.handleSubmit(handleSubmit)} noValidate>- <FormField- control={form.control}- name="new-disk-size"- disabled={!isAbleToResizeDatabase}- render={({ field }) => (- <FormItemLayout- name="new-disk-size"- layout="vertical"- label="New disk size"- >- <FormControl>- <InputGroup>- <FormInputGroupInput- {...field}- id="new-disk-size"- type="number"- onChange={(e) => field.onChange(Number(e.target.value))}- />- <InputGroupAddon align="inline-end">- <InputGroupText>GB</InputGroupText>- </InputGroupAddon>- </InputGroup>- </FormControl>- </FormItemLayout>- )}- />- </form>- </Form>- </Modal.Content>- <Modal.Separator />- <Modal.Content className="flex space-x-2 justify-end">- <Button type="default" onClick={() => hideModal(false)}>- Cancel- </Button>- <Button- form={formId}- htmlType="submit"- type="primary"- disabled={!isAbleToResizeDatabase || isUpdatingDiskSize || !isDirty}- loading={isUpdatingDiskSize}+ ) : (+ <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=${+ hasAccessToDiskModifications === false ? 'subscriptionPlan' : 'costControl'+ }`}+ target="_blank">- Update disk size- </Button>- </Modal.Content>- </>- )}- </>- ) : (- <Alert className="border-none">- <InfoIcon />- <AlertTitle>- {hasAccessToDiskModifications === false- ? '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>- <AlertDescription>- {hasAccessToDiskModifications === false ? (- <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=${- hasAccessToDiskModifications === false ? 'subscriptionPlan' : 'costControl'- }`}- target="_blank"- >- {hasAccessToDiskModifications === false- ? 'Upgrade subscription'- : 'Disable spend cap'}- </Link>- </Button>- </AlertDescription>- </Alert>- )}- </Modal>+ {hasAccessToDiskModifications === false+ ? 'Upgrade subscription'+ : 'Disable spend cap'}+ </Link>+ </Button>+ </AlertDescription>+ </Alert>+ )}+ </DialogContent>+ </Dialog>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsxindex 8e97b4b58fd..59e30653b91 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx@@ -6,11 +6,17 @@ import { useForm, useWatch } from 'react-hook-form'import { toast } from 'sonner'import {Button,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,Form,FormControl,FormField,Input,- Modal,Tooltip,TooltipContent,TooltipTrigger,@@ -140,125 +146,130 @@ const AddRestrictionModal = ({: `${ipAddress}/${cidrBlockSize}`return (- <Modal- hideFooter- size="medium"- visible={type !== undefined}- onCancel={onClose}- header={`Add a new ${type} restriction`}- >- <Form {...form}>- <Modal.Content className="space-y-4">- <p className="text-sm text-foreground-light">- This will add an IP address range to a list of allowed ranges that can access your- database.- </p>- <InformationBox- title="Note: Restrictions only apply to direct connections to your database and connection pooler"- description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."- urlLabel="Learn more"- url={`${DOCS_URL}/guides/platform/network-restrictions#limitations`}- />- <form- id={formId}- onSubmit={form.handleSubmit(onSubmit)}- noValidate- className="flex space-x-4"- >- <div className="w-[55%]">- <FormField- control={form.control}- name="ipAddress"- render={({ field }) => (- <FormItemLayout layout="vertical" label={`${type} address`}>- <FormControl>- <Input {...field} placeholder={type === 'IPv4' ? '0.0.0.0' : '::0'} />- </FormControl>- </FormItemLayout>- )}- />- </div>- <div className="grow">- <FormField- control={form.control}- name="cidrBlockSize"- render={({ field }) => (- <FormItemLayout- layout="vertical"- label={- <div className="flex items-center space-x-2">- <p>CIDR Block Size</p>- <Tooltip>- <TooltipTrigger>- <HelpCircle size="14" strokeWidth={2} />- </TooltipTrigger>- <TooltipContent side="bottom" className="w-80">- Classless inter-domain routing (CIDR) notation is the notation used to- identify networks and hosts in the networks. The block size tells us how- many bits we need to take for the network prefix, and is a value between- 0 to{' '}- {type === 'IPv4' ? IPV4_MAX_CIDR_BLOCK_SIZE : IPV6_MAX_CIDR_BLOCK_SIZE}.- </TooltipContent>- </Tooltip>- </div>- }- >- <FormControl>- <Input- {...field}- type="number"- min={0}- max={type === 'IPv4' ? IPV4_MAX_CIDR_BLOCK_SIZE : IPV6_MAX_CIDR_BLOCK_SIZE}- onChange={(e) => field.onChange(Number(e.target.value))}- placeholder={- type === 'IPv4'- ? IPV4_MAX_CIDR_BLOCK_SIZE.toString()- : IPV6_MAX_CIDR_BLOCK_SIZE.toString()- }- />- </FormControl>- </FormItemLayout>- )}- />- </div>- </form>- </Modal.Content>- <Modal.Separator />- {isValidCIDR ? (- <Modal.Content className="space-y-1">- <p className="text-sm">- The address range <code className="text-code-inline">{normalizedAddress}</code> will- be restricted- </p>- <p className="text-sm text-foreground-light">- Selected address space: <code className="text-code-inline">{addressRange.start}</code>{' '}- to <code className="text-code-inline">{addressRange.end}</code>{' '}- </p>+ <Dialog open={type !== undefined} onOpenChange={onClose}>+ <DialogContent size="medium">+ <DialogHeader>+ <DialogTitle>{`Add a new ${type} restriction`}</DialogTitle>+ </DialogHeader>+ <DialogSectionSeparator />+ <Form {...form}>+ <DialogSection className="space-y-4"><p className="text-sm text-foreground-light">- Number of addresses: {availableAddresses}+ This will add an IP address range to a list of allowed ranges that can access your+ database.</p>- </Modal.Content>- ) : (- <Modal.Content>- <div className="h-[68px] flex items-center">+ <InformationBox+ title="Note: Restrictions only apply to direct connections to your database and connection pooler"+ description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."+ urlLabel="Learn more"+ url={`${DOCS_URL}/guides/platform/network-restrictions#limitations`}+ />+ <form+ id={formId}+ onSubmit={form.handleSubmit(onSubmit)}+ noValidate+ className="flex space-x-4"+ >+ <div className="w-[55%]">+ <FormField+ control={form.control}+ name="ipAddress"+ render={({ field }) => (+ <FormItemLayout layout="vertical" label={`${type} address`}>+ <FormControl>+ <Input {...field} placeholder={type === 'IPv4' ? '0.0.0.0' : '::0'} />+ </FormControl>+ </FormItemLayout>+ )}+ />+ </div>+ <div className="grow">+ <FormField+ control={form.control}+ name="cidrBlockSize"+ render={({ field }) => (+ <FormItemLayout+ layout="vertical"+ label={+ <div className="flex items-center space-x-2">+ <p>CIDR Block Size</p>+ <Tooltip>+ <TooltipTrigger>+ <HelpCircle size="14" strokeWidth={2} />+ </TooltipTrigger>+ <TooltipContent side="bottom" className="w-80">+ Classless inter-domain routing (CIDR) notation is the notation used to+ identify networks and hosts in the networks. The block size tells us+ how many bits we need to take for the network prefix, and is a value+ between 0 to{' '}+ {type === 'IPv4'+ ? IPV4_MAX_CIDR_BLOCK_SIZE+ : IPV6_MAX_CIDR_BLOCK_SIZE}+ .+ </TooltipContent>+ </Tooltip>+ </div>+ }+ >+ <FormControl>+ <Input+ {...field}+ type="number"+ min={0}+ max={+ type === 'IPv4' ? IPV4_MAX_CIDR_BLOCK_SIZE : IPV6_MAX_CIDR_BLOCK_SIZE+ }+ onChange={(e) => field.onChange(Number(e.target.value))}+ placeholder={+ type === 'IPv4'+ ? IPV4_MAX_CIDR_BLOCK_SIZE.toString()+ : IPV6_MAX_CIDR_BLOCK_SIZE.toString()+ }+ />+ </FormControl>+ </FormItemLayout>+ )}+ />+ </div>+ </form>+ </DialogSection>+ <DialogSectionSeparator />+ {isValidCIDR ? (+ <DialogSection className="space-y-1">+ <p className="text-sm">+ The address range <code className="text-code-inline">{normalizedAddress}</code> will+ be restricted+ </p>+ <p className="text-sm text-foreground-light">+ Selected address space:{' '}+ <code className="text-code-inline">{addressRange.start}</code> to{' '}+ <code className="text-code-inline">{addressRange.end}</code>{' '}+ </p><p className="text-sm text-foreground-light">- A summary of your restriction will be shown here after entering a valid IP address- and CIDR block size. IP addresses will also be normalized.+ Number of addresses: {availableAddresses}</p>- </div>- </Modal.Content>- )}- <Modal.Separator />- <Modal.Content className="flex items-center justify-end space-x-2">- <Button type="default" disabled={isApplying} onClick={() => onClose()}>- Cancel- </Button>- <Button form={formId} htmlType="submit" loading={isApplying} disabled={isApplying}>- Save restriction- </Button>- </Modal.Content>- </Form>- </Modal>+ </DialogSection>+ ) : (+ <DialogSection>+ <div className="h-[68px] flex items-center">+ <p className="text-sm text-foreground-light">+ A summary of your restriction will be shown here after entering a valid IP address+ and CIDR block size. IP addresses will also be normalized.+ </p>+ </div>+ </DialogSection>+ )}+ <DialogFooter>+ <Button type="default" disabled={isApplying} onClick={() => onClose()}>+ Cancel+ </Button>+ <Button form={formId} htmlType="submit" loading={isApplying} disabled={isApplying}>+ Save restriction+ </Button>+ </DialogFooter>+ </Form>+ </DialogContent>+ </Dialog>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsxindex adb3d92592b..e494af08d6d 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AllowAllModal.tsx@@ -1,5 +1,14 @@import { useParams } from 'common/hooks'-import { Button, Modal } from 'ui'+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from 'ui'import { useNetworkRestrictionsApplyMutation } from '@/data/network-restrictions/network-retrictions-apply-mutation'@@ -10,14 +19,14 @@ interface AllowAllModalProps {const AllowAllModal = ({ visible, onClose }: AllowAllModalProps) => {const { ref } = useParams()- const { mutate: applyNetworkRestrictions, isPending: isApplying } =+ const { mutateAsync: applyNetworkRestrictions, isPending: isApplying } =useNetworkRestrictionsApplyMutation({onSuccess: () => onClose(),})const onSubmit = async () => {if (!ref) return console.error('Project ref is required')- applyNetworkRestrictions({+ await applyNetworkRestrictions({projectRef: ref,dbAllowedCidrs: ['0.0.0.0/0'],dbAllowedCidrsV6: ['::/0'],@@ -25,28 +34,22 @@ const AllowAllModal = ({ visible, onClose }: AllowAllModalProps) => {}return (- <Modal- hideFooter- size="small"- visible={visible}- onCancel={onClose}- header="Allow access from all IP addresses"- >- <Modal.Content className="space-y-4">- <p className="text-sm text-foreground-light">- This will allow any IP address to access your project's database. Are you sure?- </p>- </Modal.Content>- <Modal.Separator />- <Modal.Content className="flex items-center justify-end space-x-2">- <Button type="default" disabled={isApplying} onClick={() => onClose()}>- Cancel- </Button>- <Button loading={isApplying} disabled={isApplying} onClick={() => onSubmit()}>- Confirm- </Button>- </Modal.Content>- </Modal>+ <AlertDialog open={visible} onOpenChange={onClose}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Allow access from all IP addresses</AlertDialogTitle>+ <AlertDialogDescription>+ This will allow any IP address to access your project's database. Are you sure?+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel disabled={isApplying}>Cancel</AlertDialogCancel>+ <AlertDialogAction onClick={onSubmit} disabled={isApplying} loading={isApplying}>+ Confirm+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsxindex d88aaa1d904..2d1fa246135 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx@@ -1,5 +1,14 @@import { useParams } from 'common'-import { Button, Modal } from 'ui'+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from 'ui'import InformationBox from '@/components/ui/InformationBox'import { useNetworkRestrictionsApplyMutation } from '@/data/network-restrictions/network-retrictions-apply-mutation'@@ -11,7 +20,7 @@ interface DisallowAllModalProps {const DisallowAllModal = ({ visible, onClose }: DisallowAllModalProps) => {const { ref } = useParams()- const { mutate: applyNetworkRestrictions, isPending: isApplying } =+ const { mutateAsync: applyNetworkRestrictions, isPending: isApplying } =useNetworkRestrictionsApplyMutation({ onSuccess: () => onClose() })const onSubmit = async () => {@@ -24,35 +33,33 @@ const DisallowAllModal = ({ visible, onClose }: DisallowAllModalProps) => {}return (- <Modal- hideFooter- size="medium"- visible={visible}- onCancel={onClose}- header="Restrict access from all IP addresses"- >- <Modal.Content className="space-y-4">- <p className="text-sm text-foreground-light">- This will prevent any external IP addresses from accessing your project's database. Are- you sure?- </p>- <InformationBox- defaultVisibility- hideCollapse- title="Note: Restrictions only apply to direct connections to your database and connection pooler"- description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."- />- </Modal.Content>- <Modal.Separator />- <Modal.Content className="flex items-center justify-end space-x-2">- <Button type="default" disabled={isApplying} onClick={() => onClose()}>- Cancel- </Button>- <Button loading={isApplying} disabled={isApplying} onClick={() => onSubmit()}>- Confirm- </Button>- </Modal.Content>- </Modal>+ <AlertDialog open={visible} onOpenChange={onClose}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Restrict access from all IP addresses</AlertDialogTitle>+ <AlertDialogDescription>+ <div className="flex flex-col space-y-4">+ <p>+ This will prevent any external IP addresses from accessing your project's database.+ Are you sure?+ </p>+ <InformationBox+ defaultVisibility+ hideCollapse+ title="Note: Restrictions only apply to direct connections to your database and connection pooler"+ description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."+ />+ </div>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel disabled={isApplying}>Cancel</AlertDialogCancel>+ <AlertDialogAction onClick={onSubmit} disabled={isApplying} loading={isApplying}>+ Confirm+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsxindex 6026e290796..4dea1c1814b 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/RemoveRestrictionModal.tsx@@ -1,6 +1,15 @@import { useParams } from 'common'import { toast } from 'sonner'-import { Button, Modal } from 'ui'+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from 'ui'import { Admonition } from 'ui-patterns'import { useNetworkRestrictionsQuery } from '@/data/network-restrictions/network-restrictions-query'@@ -25,7 +34,7 @@ const RemoveRestrictionModal = ({const ipv6Restrictions: string[] = data?.config?.dbAllowedCidrsV6 ?? []const restrictedIps = ipv4Restrictions.concat(ipv6Restrictions)- const { mutate: applyNetworkRestrictions, isPending: isApplying } =+ const { mutateAsync: applyNetworkRestrictions, isPending: isApplying } =useNetworkRestrictionsApplyMutation({onSuccess: () => onClose(),onError: (error) => {@@ -48,50 +57,54 @@ const RemoveRestrictionModal = ({: ipv6Restrictionsif (dbAllowedCidrs.length === 0 && dbAllowedCidrsV6.length === 0) {- applyNetworkRestrictions({+ await applyNetworkRestrictions({projectRef: ref,dbAllowedCidrs: ['0.0.0.0/0'],dbAllowedCidrsV6: ['::/0'],})} else {- applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs, dbAllowedCidrsV6 })+ await applyNetworkRestrictions({ projectRef: ref, dbAllowedCidrs, dbAllowedCidrsV6 })}}return (- <Modal- hideFooter- size="medium"- visible={visible}- onCancel={onClose}- header="Confirm to remove restriction"- >- <Modal.Content className="space-y-4">- <p className="text-sm text-foreground-light">- The IPv4 address <code className="text-code-inline">{selectedRestriction}</code> will be- removed from your list of network restrictions- {isRemovingOnlyRestriction- ? '.'- : ", and no longer have access to your project's database."}- </p>- {isRemovingOnlyRestriction && (- <Admonition- type="warning"- title="Database access will no longer be restricted"- description="Removing all network restrictions will default to your database being accessible from- all IP addresses."- />- )}- </Modal.Content>- <Modal.Content className="flex items-center justify-end space-x-2">- <Button type="default" disabled={isApplying} onClick={() => onClose()}>- Cancel- </Button>- <Button loading={isApplying} disabled={isApplying} onClick={() => onSubmit()}>- Remove restriction- </Button>- </Modal.Content>- </Modal>+ <AlertDialog open={visible} onOpenChange={onClose}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Confirm to remove restriction</AlertDialogTitle>+ <AlertDialogDescription>+ <div className="flex flex-col space-y-4">+ <p>+ The IPv4 address <code className="text-code-inline">{selectedRestriction}</code>{' '}+ will be removed from your list of network restrictions+ {isRemovingOnlyRestriction+ ? '.'+ : ", and no longer have access to your project's database."}+ </p>+ {isRemovingOnlyRestriction && (+ <Admonition+ type="warning"+ title="Database access will no longer be restricted"+ description="Removing all network restrictions will default to your database being accessible from+ all IP addresses."+ />+ )}+ </div>+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel disabled={isApplying}>Cancel</AlertDialogCancel>+ <AlertDialogAction+ onClick={onSubmit}+ disabled={isApplying}+ loading={isApplying}+ variant="danger"+ >+ Remove restriction+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>)}