The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/tidy s3 creds (#25871)
Jonathan Summers-Muire19b3f53bff1
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsxindex 3892991bcba..5b8c3d0def5 100644--- a/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx+++ b/apps/studio/components/to-be-cleaned/Storage/StorageSettings/S3Connection.tsx@@ -1,7 +1,4 @@-import { differenceInDays } from 'date-fns'-import React from 'react'-import toast from 'react-hot-toast'-+import { AlertTitle } from '@ui/components/shadcn/ui/alert'import { useParams } from 'common'import {useIsProjectActive,@@ -15,6 +12,11 @@ import { useProjectApiQuery } from 'data/config/project-api-query'import { useS3AccessKeyCreateMutation } from 'data/storage/s3-access-key-create-mutation'import { useS3AccessKeyDeleteMutation } from 'data/storage/s3-access-key-delete-mutation'import { useStorageCredentialsQuery } from 'data/storage/s3-access-key-query'+import { differenceInDays } from 'date-fns'+import { AlertCircle, MoreVertical, TrashIcon } from 'lucide-react'+import Link from 'next/link'+import React from 'react'+import toast from 'react-hot-toast'import {AlertDescription_Shadcn_,Alert_Shadcn_,@@ -22,33 +24,32 @@ import {Dialog,DialogContent,DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,DialogTitle,DialogTrigger,DropdownMenu,DropdownMenuContent,DropdownMenuItem,DropdownMenuTrigger,- IconMoreVertical,+ TooltipContent_Shadcn_,+ TooltipTrigger_Shadcn_,+ Tooltip_Shadcn_,cn,} from 'ui'import { GenericSkeletonLoader } from 'ui-patterns'import { Input } from 'ui-patterns/DataInputs/Input'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'-import { AlertTitle } from '@ui/components/shadcn/ui/alert'-import Link from 'next/link'-import { AlertCircle, TrashIcon } from 'lucide-react'-import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,-} from '@ui/components/shadcn/ui/tooltip'export const S3Connection = () => {const [openCreateCred, setOpenCreateCred] = React.useState(false)const [showSuccess, setShowSuccess] = React.useState(false)const [openDeleteDialog, setOpenDeleteDialog] = React.useState(false)- const [deleteCredId, setDeleteCredId] = React.useState<string | null>(null)+ const [deleteCred, setDeleteCred] = React.useState<{ id: string; description: string } | null>(+ null+ )const { ref: projectRef } = useParams()const { project, isLoading: projectIsLoading } = useProjectContext()@@ -130,23 +131,22 @@ export const S3Connection = () => {if (!open) setShowSuccess(false)}}>- <DialogTrigger asChild>- <Button disabled={!isProjectActive} type="outline">- <TooltipProvider>- <Tooltip>- <TooltipTrigger>New access key</TooltipTrigger>- {!isProjectActive && (- <TooltipContent>- Restore your project to create new access keys- </TooltipContent>- )}- </Tooltip>- </TooltipProvider>- </Button>- </DialogTrigger>+ <Tooltip_Shadcn_>+ <TooltipTrigger_Shadcn_ asChild>+ <DialogTrigger asChild>+ <Button type="default" disabled={!isProjectActive}>+ New access key+ </Button>+ </DialogTrigger>+ </TooltipTrigger_Shadcn_>+ {!isProjectActive && (+ <TooltipContent_Shadcn_>+ Restore your project to create new access keys+ </TooltipContent_Shadcn_>+ )}+ </Tooltip_Shadcn_><DialogContent- className="p-4"onInteractOutside={(e) => {if (showSuccess) {e.preventDefault()@@ -155,33 +155,35 @@ export const S3Connection = () => {>{showSuccess ? (<>- <div className="flex flex-col gap-y-2">+ <DialogHeader><DialogTitle>Save your new S3 access keys</DialogTitle><DialogDescription>You won't be able to see them again. If you lose these access keys, you'llneed to create a new ones.</DialogDescription>- </div>-- <FormItemLayout label="Access key ID" isReactForm={false}>- <Input- className="input-mono"- readOnly- copy- disabled- value={createS3AccessKey.data?.data?.access_key}- />- </FormItemLayout>- <FormItemLayout label={'Secret access key'} isReactForm={false}>- <Input- className="input-mono"- readOnly- copy- disabled- value={createS3AccessKey.data?.data?.secret_key}- />- </FormItemLayout>- <div className="flex justify-end">+ </DialogHeader>+ <DialogSectionSeparator />+ <DialogSection className="flex flex-col gap-4">+ <FormItemLayout label="Access key ID" isReactForm={false}>+ <Input+ className="input-mono"+ readOnly+ copy+ disabled+ value={createS3AccessKey.data?.data?.access_key}+ />+ </FormItemLayout>+ <FormItemLayout label={'Secret access key'} isReactForm={false}>+ <Input+ className="input-mono"+ readOnly+ copy+ disabled+ value={createS3AccessKey.data?.data?.secret_key}+ />+ </FormItemLayout>+ </DialogSection>+ <DialogFooter><ButtononClick={() => {setOpenCreateCred(false)@@ -190,17 +192,18 @@ export const S3Connection = () => {>Done</Button>- </div>+ </DialogFooter></>) : (<>- <div className="flex flex-col gap-y-2">+ <DialogHeader><DialogTitle>Create new S3 access keys</DialogTitle><DialogDescription>S3 access keys provide full access to all S3 operations across all bucketsand bypass any existing RLS policies.</DialogDescription>- </div>+ </DialogHeader>+ <DialogSectionSeparator /><formonSubmit={async (e) => {e.preventDefault()@@ -212,25 +215,23 @@ export const S3Connection = () => {setShowSuccess(true)}}>- <FormItemLayout label="Description" isReactForm={false}>- <Input- autoComplete="off"- placeholder="My test key"- type="text"- name="description"- required- />- </FormItemLayout>+ <DialogSection>+ <FormItemLayout label="Description" isReactForm={false}>+ <Input+ autoComplete="off"+ placeholder="My test key"+ type="text"+ name="description"+ required+ />+ </FormItemLayout>+ </DialogSection>- <div className="flex justify-end">- <Button- className="mt-4"- htmlType="submit"- loading={createS3AccessKey.isLoading}- >+ <DialogFooter>+ <Button htmlType="submit" loading={createS3AccessKey.isLoading}>Create access key</Button>- </div>+ </DialogFooter></form></>)}@@ -284,7 +285,7 @@ export const S3Connection = () => {description={cred.description}id={cred.id}onDeleteClick={() => {- setDeleteCredId(cred.id)+ setDeleteCred(cred)setOpenDeleteDialog(true)}}/>@@ -309,17 +310,22 @@ export const S3Connection = () => {</div><Dialog open={openDeleteDialog} onOpenChange={setOpenDeleteDialog}>- <DialogContent className="p-4">- <DialogTitle>Revoke S3 access keys</DialogTitle>- <DialogDescription>- This action is irreversible and requests made with these access keys will stop working.- </DialogDescription>- <div className="flex justify-end gap-2">+ <DialogContent>+ <DialogHeader>+ <DialogTitle>+ Revoke <code>{deleteCred?.description}</code> credential+ </DialogTitle>+ <DialogDescription>+ This action is irreversible and requests made with these access keys will stop+ working.+ </DialogDescription>+ </DialogHeader>+ <DialogFooter className="flex justify-end gap-1"><Buttontype="outline"onClick={() => {setOpenDeleteDialog(false)- setDeleteCredId(null)+ setDeleteCred(null)}}>Cancel@@ -328,15 +334,15 @@ export const S3Connection = () => {type="danger"loading={deleteS3AccessKey.isLoading}onClick={async () => {- if (!deleteCredId) return- await deleteS3AccessKey.mutateAsync({ id: deleteCredId })+ if (!deleteCred) return+ await deleteS3AccessKey.mutateAsync({ id: deleteCred.id })setOpenDeleteDialog(false)toast.success('S3 access keys revoked')}}>Yes, revoke access keys</Button>- </div>+ </DialogFooter></DialogContent></Dialog></>@@ -372,22 +378,28 @@ function StorageCredItem({return (<tr className="h-8 text-ellipsis group">- <td>{description}</td>+ <td>+ <span className="text-foreground">{description}</span>+ </td><td><div className="flex items-center justify-between"><span className="text-ellipsis font-mono cursor-default">{access_key}</span><span className="w-24 text-right opacity-0 group-hover:opacity-100 transition-opacity">- <CopyButton text={access_key} type="outline" />+ <CopyButton text={access_key} type="default" /></span></div></td><td>{daysSince(created_at)}</td>- <td>+ <td className="text-right"><DropdownMenu>- <DropdownMenuTrigger className="flex items-center justify-end w-full">- <IconMoreVertical />+ <DropdownMenuTrigger asChild>+ <Button+ icon={<MoreVertical size={14} strokeWidth={1} />}+ type="text"+ className="px-1.5 text-foreground-lighter hover:text-foreground"+ ></Button></DropdownMenuTrigger>- <DropdownMenuContent className="max-w-40">+ <DropdownMenuContent className="max-w-40" align="end"><DropdownMenuItemclassName="flex gap-1.5 "onClick={(e) => {@@ -396,7 +408,7 @@ function StorageCredItem({}}><TrashIcon size="14" />- Revoke keys+ Revoke key</DropdownMenuItem></DropdownMenuContent></DropdownMenu>diff --git a/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx b/packages/ui/src/components/shadcn/stories/Dialog.stories.tsxindex 461d967f265..4aaaafd214e 100644--- a/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx+++ b/packages/ui/src/components/shadcn/stories/Dialog.stories.tsx@@ -9,6 +9,7 @@ import {DialogFooter,DialogHeader,DialogSection,+ DialogSectionSeparator,DialogTitle,DialogTrigger,} from '../ui/dialog'@@ -49,7 +50,8 @@ export const Default: Story = {Make changes to your profile here. Click save when you're done.</DialogDescription></DialogHeader>- <div className="grid gap-4 py-4">+ <DialogSectionSeparator />+ <DialogSection className="grid gap-4 py-4"><div className="grid grid-cols-4 items-center gap-4"><Label htmlFor="name" className="text-right">Name@@ -62,7 +64,7 @@ export const Default: Story = {</Label><Input id="username" value="@peduarte" className="col-span-3" /></div>- </div>+ </DialogSection><DialogFooter><Button type="submit">Save changes</Button></DialogFooter>@@ -92,20 +94,19 @@ export const withSize: Story = {Make changes to your profile here. Click save when you're done.</DialogDescription></DialogHeader>- <DialogSection>- <div className="grid gap-4 py-4">- <div className="grid grid-cols-4 items-center gap-4">- <Label htmlFor="name" className="text-right">- Name- </Label>- <Input id="name" value="Pedro Duarte" className="col-span-3" />- </div>- <div className="grid grid-cols-4 items-center gap-4">- <Label htmlFor="username" className="text-right">- Username- </Label>- <Input id="username" value="@peduarte" className="col-span-3" />- </div>+ <DialogSectionSeparator />+ <DialogSection className="grid gap-4 py-4">+ <div className="grid grid-cols-4 items-center gap-4">+ <Label htmlFor="name" className="text-right">+ Name+ </Label>+ <Input id="name" value="Pedro Duarte" className="col-span-3" />+ </div>+ <div className="grid grid-cols-4 items-center gap-4">+ <Label htmlFor="username" className="text-right">+ Username+ </Label>+ <Input id="username" value="@peduarte" className="col-span-3" /></div></DialogSection><DialogFooter>diff --git a/packages/ui/src/components/shadcn/ui/dialog.tsx b/packages/ui/src/components/shadcn/ui/dialog.tsxindex b17eb76021f..046d4652352 100644--- a/packages/ui/src/components/shadcn/ui/dialog.tsx+++ b/packages/ui/src/components/shadcn/ui/dialog.tsx@@ -55,7 +55,7 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayNameconst DialogContentVariants = cva(cn('my-8',- 'relative z-50 grid w-full gap-4 border shadow-md dark:shadow-sm duration-200',+ 'relative z-50 grid w-full border shadow-md dark:shadow-sm duration-200','data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0','data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95','data-[state=closed]:slide-out-to-left-[0%] data-[state=closed]:slide-out-to-top-[0%',