The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: migrate auth `Modal` to `Dialog` (#46392)
Gildas Garciaa6bfa0478cf5
diff --git a/apps/studio/components/interfaces/Auth/RedirectUrls/AddNewURLModal.tsx b/apps/studio/components/interfaces/Auth/RedirectUrls/AddNewURLModal.tsxindex e095c396017..de870593bfd 100644--- a/apps/studio/components/interfaces/Auth/RedirectUrls/AddNewURLModal.tsx+++ b/apps/studio/components/interfaces/Auth/RedirectUrls/AddNewURLModal.tsx@@ -4,7 +4,20 @@ import { useParams } from 'common'import { useEffect } from 'react'import { useForm } from 'react-hook-form'import { toast } from 'sonner'-import { Button, cn, DialogSectionSeparator, Form, Modal, ScrollArea } from 'ui'+import {+ Button,+ cn,+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,+ Form,+ ScrollArea,+} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import { SingleValueFieldArray } from 'ui-patterns/form/SingleValueFieldArray/SingleValueFieldArray'import * as z from 'zod'@@ -82,55 +95,59 @@ export const AddNewURLModal = ({ visible, allowList, onClose }: AddNewURLModalPr}, [visible])return (- <Modal- hideFooter- size="medium"- className="max-w-[440px]!"- visible={visible}- onCancel={() => {+ <Dialog+ open={visible}+ onOpenChange={() => {form.reset(initialValues)onClose()}}- header="Add new redirect URLs"- description="This will add a URL to a list of allowed URLs that can interact with your Authentication services for this project.">- <Form {...form}>- <form onSubmit={form.handleSubmit(onSubmit)}>- <Modal.Content className="flex flex-col gap-y-2 px-0">- <Label className="px-5">URL</Label>- <ScrollArea className={cn(urls.length > 4 ? 'h-[220px]' : '')}>- <div className="px-5 py-1">- <FormItemLayout className="[&>div>div]:mt-0">- <SingleValueFieldArray- control={form.control}- name="urls"- valueFieldName="value"- createEmptyRow={() => ({ value: '' })}- placeholder="https://mydomain.com"- addLabel="Add URL"- removeLabel="Remove URL"- minimumRows={1}- rowsClassName="space-y-2"- addButtonClassName="w-min"- />- </FormItemLayout>- </div>- </ScrollArea>- </Modal.Content>- <DialogSectionSeparator />- <Modal.Content>- <Button- block- htmlType="submit"- size="small"- disabled={isUpdatingConfig}- loading={isUpdatingConfig}- >- Save URLs- </Button>- </Modal.Content>- </form>- </Form>- </Modal>+ <DialogContent size="medium" className="max-w-[440px]!">+ <DialogHeader>+ <DialogTitle>Add new redirect URLs</DialogTitle>+ <DialogDescription>+ This will add a URL to a list of allowed URLs that can interact with your Authentication+ services for this project.+ </DialogDescription>+ </DialogHeader>+ <DialogSectionSeparator />+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)}>+ <DialogSection className="flex flex-col gap-y-2 px-0">+ <Label className="px-5">URL</Label>+ <ScrollArea className={cn(urls.length > 4 ? 'h-[220px]' : '')}>+ <div className="px-5 py-1">+ <FormItemLayout className="[&>div>div]:mt-0">+ <SingleValueFieldArray+ control={form.control}+ name="urls"+ valueFieldName="value"+ createEmptyRow={() => ({ value: '' })}+ placeholder="https://mydomain.com"+ addLabel="Add URL"+ removeLabel="Remove URL"+ minimumRows={1}+ rowsClassName="space-y-2"+ addButtonClassName="w-min"+ />+ </FormItemLayout>+ </div>+ </ScrollArea>+ </DialogSection>+ <DialogFooter>+ <Button+ block+ htmlType="submit"+ size="small"+ disabled={isUpdatingConfig}+ loading={isUpdatingConfig}+ >+ Save URLs+ </Button>+ </DialogFooter>+ </form>+ </Form>+ </DialogContent>+ </Dialog>)}diff --git a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsxindex 8a9cc0ab394..5819985f817 100644--- a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx+++ b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrls.tsx@@ -1,7 +1,18 @@import { useParams } from 'common'import { useMemo, useState } from 'react'import { toast } from 'sonner'-import { Button, cn, Modal, ScrollArea } from 'ui'+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ cn,+ ScrollArea,+} from 'ui'import {PageSection,PageSectionAside,@@ -31,7 +42,8 @@ export const RedirectUrls = () => {isError,isSuccess,} = useAuthConfigQuery({ projectRef })- const { mutate: updateAuthConfig, isPending: isUpdatingConfig } = useAuthConfigUpdateMutation()+ const { mutateAsync: updateAuthConfig, isPending: isUpdatingConfig } =+ useAuthConfigUpdateMutation()const URI_ALLOW_LIST_ARRAY = useMemo(() => {return authConfig?.URI_ALLOW_LIST@@ -49,7 +61,7 @@ export const RedirectUrls = () => {// Remove selectedUrl from array and updateconst payload = URI_ALLOW_LIST_ARRAY.filter((url: string) => !selectedUrls.includes(url))const payloadString = payload.join(',')- updateAuthConfig(+ await updateAuthConfig({ projectRef: projectRef!, config: { URI_ALLOW_LIST: payloadString } },{onError: (error) => {@@ -111,60 +123,48 @@ export const RedirectUrls = () => {onClose={() => setOpen(false)}/>- <Modal- hideFooter- size="large"- visible={openRemoveSelected}- header="Remove URLs"- onCancel={() => {+ <AlertDialog+ open={openRemoveSelected}+ onOpenChange={() => {setSelectedUrls([])setOpenRemoveSelected(false)}}>- <Modal.Content className="flex flex-col gap-y-2">- <p className="mb-2 text-sm text-foreground-light">- Are you sure you want to remove the following {selectedUrls.length} URL- {selectedUrls.length > 1 ? 's' : ''}?- </p>- <ScrollArea className={cn(selectedUrls.length > 4 ? 'h-[250px]' : '')}>- <div className="flex flex-col -space-y-1">- {selectedUrls.map((url) => {- return (- <ValueContainer key={url} className="px-4 py-3 hover:bg-surface-100">- {url}- </ValueContainer>- )- })}- </div>- </ScrollArea>- <p className="text-foreground-light text-sm">- These URLs will no longer work with your authentication configuration.- </p>- </Modal.Content>- <Modal.Separator />- <Modal.Content className="flex items-center gap-x-2">- <Button- block- type="default"- size="medium"- onClick={() => {- setSelectedUrls([])- setOpenRemoveSelected(false)- }}- >- Cancel- </Button>- <Button- block- size="medium"- type="warning"- loading={isUpdatingConfig}- onClick={() => onConfirmDeleteUrl(selectedUrls)}- >- {isUpdatingConfig ? 'Removing...' : 'Remove URL'}- </Button>- </Modal.Content>- </Modal>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Remove URLs</AlertDialogTitle>+ <AlertDialogDescription asChild>+ <div className="flex flex-col gap-y-2">+ <p className="mb-2 text-sm text-foreground-light">+ Are you sure you want to remove the following {selectedUrls.length} URL+ {selectedUrls.length > 1 ? 's' : ''}?+ </p>+ <ScrollArea className={cn(selectedUrls.length > 4 ? 'h-[250px]' : '')}>+ <div className="flex flex-col -space-y-1">+ {selectedUrls.map((url) => {+ return (+ <ValueContainer key={url} className="px-4 py-3 hover:bg-surface-100">+ {url}+ </ValueContainer>+ )+ })}+ </div>+ </ScrollArea>+ <p className="text-foreground-light text-sm">+ These URLs will no longer work with your authentication configuration.+ </p>+ </div>+ </AlertDialogDescription>+ </AlertDialogHeader>++ <AlertDialogFooter className="flex items-center gap-x-2">+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction variant="warning" onClick={() => onConfirmDeleteUrl(selectedUrls)}>+ {isUpdatingConfig ? 'Removing...' : 'Remove URL'}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog></PageSectionContent></PageSection>)diff --git a/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsxindex 7ab5b0c9017..dc56752b054 100644--- a/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx+++ b/apps/studio/components/interfaces/Auth/Users/BanUserModal.tsx@@ -7,16 +7,21 @@ import { toast } from 'sonner'import {Button,cn,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,Form,FormControl,FormField,Input,- Modal,Select,SelectContent,SelectItem,SelectTrigger,- Separator,} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import * as z from 'zod'@@ -80,75 +85,77 @@ export const BanUserModal = ({ visible, user, onClose }: BanUserModalProps) => {}, [visible])return (- <Modal- hideFooter- visible={visible}- size="small"- header="Confirm to ban user"- onCancel={() => onClose()}- >- <Form {...form}>- <form onSubmit={form.handleSubmit(onSubmit)}>- <Modal.Content className="flex flex-col gap-y-3">- <p className="text-sm">- This will revoke the user's access to your project and prevent them from logging in- for a specified duration.- </p>- <div className="flex items-start gap-x-2 [&>div:first-child]:grow">- <FormField- control={form.control}- name="value"- render={({ field }) => (- <FormItemLayout className="[&>div>div]:mt-0" label="Set a ban duration">- <FormControl>- <Input {...field} />- </FormControl>- </FormItemLayout>- )}- />- <FormField- control={form.control}- name="unit"- render={({ field }) => (- <FormItemLayout className="[&>div>div]:mt-0 mt-[33px]">- <FormControl>- <Select- {...field}- value={field.value}- onValueChange={(value) => form.setValue('unit', value as 'hours' | 'days')}- >- <SelectTrigger className="capitalize w-24">{field.value}</SelectTrigger>- <SelectContent>- <SelectItem value="hours">Hours</SelectItem>- <SelectItem value="days">Days</SelectItem>- </SelectContent>- </Select>- </FormControl>- </FormItemLayout>- )}- />- </div>-- <div>- <p className="text-sm text-foreground-lighter">- This user will not be able to log in until:- </p>- <p className={cn('text-sm', !value && 'text-foreground-light')}>- {!!value ? bannedUntil : 'Invalid duration set'}+ <Dialog open={visible} onOpenChange={() => onClose()}>+ <DialogContent size="small">+ <DialogHeader>+ <DialogTitle>Confirm to ban user</DialogTitle>+ </DialogHeader>+ <DialogSectionSeparator />+ <Form {...form}>+ <form onSubmit={form.handleSubmit(onSubmit)}>+ <DialogSection className="flex flex-col gap-y-3">+ <p className="text-sm">+ This will revoke the user's access to your project and prevent them from logging in+ for a specified duration.</p>- </div>- </Modal.Content>- <Separator />- <Modal.Content className="flex justify-end gap-2">- <Button type="default" disabled={isBanningUser} onClick={() => onClose()}>- Cancel- </Button>- <Button type="warning" htmlType="submit" loading={isBanningUser}>- Confirm ban- </Button>- </Modal.Content>- </form>- </Form>- </Modal>+ <div className="flex items-start gap-x-2 [&>div:first-child]:grow">+ <FormField+ control={form.control}+ name="value"+ render={({ field }) => (+ <FormItemLayout label="Set a ban duration">+ <FormControl>+ <Input {...field} />+ </FormControl>+ </FormItemLayout>+ )}+ />+ <FormField+ control={form.control}+ name="unit"+ render={({ field }) => (+ <FormItemLayout className="[&>div>div]:mt-0 mt-[29px]">+ <FormControl>+ <Select+ {...field}+ aria-label="Duration unit"+ value={field.value}+ onValueChange={(value) =>+ form.setValue('unit', value as 'hours' | 'days')+ }+ >+ <SelectTrigger className="capitalize w-24">{field.value}</SelectTrigger>+ <SelectContent>+ <SelectItem value="hours">Hours</SelectItem>+ <SelectItem value="days">Days</SelectItem>+ </SelectContent>+ </Select>+ </FormControl>+ </FormItemLayout>+ )}+ />+ </div>++ <div>+ <p className="text-sm text-foreground-lighter">+ This user will not be able to log in until:+ </p>+ <p className={cn('text-sm', !value && 'text-foreground-light')}>+ {!!value ? bannedUntil : 'Invalid duration set'}+ </p>+ </div>+ </DialogSection>+ <DialogFooter>+ <Button type="default" disabled={isBanningUser} onClick={() => onClose()}>+ Cancel+ </Button>+ <Button type="warning" htmlType="submit" loading={isBanningUser}>+ Confirm ban+ </Button>+ </DialogFooter>+ </form>+ </Form>+ </DialogContent>+ </Dialog>)}diff --git a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsxindex 721243e7b50..30548241eef 100644--- a/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx+++ b/apps/studio/components/interfaces/Auth/Users/InviteUserModal.tsx@@ -3,7 +3,20 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useParams } from 'common'import { SubmitHandler, useForm } from 'react-hook-form'import { toast } from 'sonner'-import { Button, Form, FormControl, FormField, Input, Modal } from 'ui'+import {+ Button,+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,+ Form,+ FormControl,+ FormField,+ Input,+} from 'ui'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import * as z from 'zod'@@ -54,45 +67,45 @@ const InviteUserModal = ({ visible, setVisible }: InviteUserModalProps) => {}return (- <Modal- hideFooter- size="small"- key="invite-user-modal"- visible={visible}- header="Invite a new user"- onCancel={handleToggle}- >- <Form {...form}>- <Modal.Content>- <form id={formId} onSubmit={form.handleSubmit(onInviteUser)} noValidate>- <FormField- control={form.control}- name="email"- render={({ field }) => (- <FormItemLayout layout="vertical" label="User email">- <FormControl className="relative col-span-6">- <Input {...field} />- </FormControl>- </FormItemLayout>- )}- />- </form>- </Modal.Content>+ <Dialog key="invite-user-modal" open={visible} onOpenChange={handleToggle}>+ <DialogContent size="small">+ <DialogHeader>+ <DialogTitle>Invite a new user</DialogTitle>+ </DialogHeader>+ <DialogSectionSeparator />+ <Form {...form}>+ <DialogSection>+ <form id={formId} onSubmit={form.handleSubmit(onInviteUser)} noValidate>+ <FormField+ control={form.control}+ name="email"+ render={({ field }) => (+ <FormItemLayout layout="vertical" label="User email">+ <FormControl className="relative col-span-6">+ <Input {...field} />+ </FormControl>+ </FormItemLayout>+ )}+ />+ </form>+ </DialogSection>- <Modal.Content>- <Button- form={formId}- block- size="small"- htmlType="submit"- loading={isInviting}- disabled={!canInviteUsers || isInviting}- >- Invite user- </Button>- </Modal.Content>- </Form>- </Modal>+ <DialogFooter>+ <Button type="default" onClick={handleToggle}>+ Cancel+ </Button>+ <Button+ form={formId}+ htmlType="submit"+ loading={isInviting}+ disabled={!canInviteUsers || isInviting}+ >+ Invite user+ </Button>+ </DialogFooter>+ </Form>+ </DialogContent>+ </Dialog>)}