mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 12:25:05 +03:00
* feat: add basic api keys ui * init JWT secrets. rough * Update JWTSecretKeysTable.tsx * added some info hover cards. • found this this is probably the wrong direction • will create a new page for next iteration. * init new version * add illustrations * Update JWTSecretKeysTablev2.tsx * chore: delete API key now works * some style changes * added better tables * Update JWTSecretKeysTablev2.tsx * add public JWT dialog * moar * adding sub layout in * starts adding in a ButtonGroup * about to make into separate components * added quick copy to project loading screen * build state * basic loading * confirm dialog and loading states * switched for better loading experience * moved styles of Input to InputVariants * issue with ref type * loading,error and rest states * new loading states * alt l;ayout * add group * updated error states for permissions * copy button behaviour for secret keys * delete dialog * Update QuickKeyCopy.tsx * fix type errors * Update JWTSecretKeysTablev2.tsx * update menu to hide pages * Update SettingsMenu.utils.tsx * Update resource-query.ts * remove old file * moved JWT secrets to use valtio * Update api-keys-query.ts * fix typecheck * rename files * remove JWT stuff * revert file * remove more JWT stuff * Update package.json * Update pnpm-lock.yaml * Update ProjectLayout.tsx * Update PublishableAPIKeys.tsx * Update api-keys-query.ts * refactor api-keys-query * Update SettingsMenu.utils.tsx * Some clean up * more clean up and refactor * Update APIKeyRow.tsx * Update LayoutHeader.tsx * resolve comments * Update CreateSecretAPIKeyModal.tsx * Update APIKeyRow.tsx * Add perms check for delete API keys * Remove console log * Delete ConnectDialog.tsx * use project ref --------- Co-authored-by: Stojan Dimitrovski <sdimitrovski@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
141 lines
3.6 KiB
TypeScript
141 lines
3.6 KiB
TypeScript
'use client'
|
|
|
|
import { MouseEventHandler, forwardRef, useEffect, useState } from 'react'
|
|
import {
|
|
Alert_Shadcn_,
|
|
Button,
|
|
Dialog,
|
|
DialogContent,
|
|
DialogSection,
|
|
DialogSectionSeparator,
|
|
DialogTitle,
|
|
cn,
|
|
} from 'ui'
|
|
import { Admonition } from './../admonition'
|
|
import { DialogDescription, DialogHeader } from 'ui/src/components/shadcn/ui/dialog'
|
|
|
|
export interface ConfirmationModalProps {
|
|
loading?: boolean
|
|
visible: boolean
|
|
title: string | React.ReactNode
|
|
description?: string | React.ReactNode
|
|
size?: React.ComponentProps<typeof DialogContent>['size']
|
|
confirmLabel?: string
|
|
confirmLabelLoading?: string
|
|
cancelLabel?: string
|
|
onConfirm: () => void
|
|
onCancel: () => void
|
|
disabled?: boolean
|
|
variant?: React.ComponentProps<typeof Alert_Shadcn_>['variant']
|
|
alert?: {
|
|
base?: React.ComponentProps<typeof Alert_Shadcn_>
|
|
title?: string
|
|
description?: string | React.ReactNode
|
|
}
|
|
}
|
|
|
|
const ConfirmationModal = forwardRef<
|
|
React.ElementRef<typeof DialogContent>,
|
|
React.ComponentPropsWithoutRef<typeof Dialog> & ConfirmationModalProps
|
|
>(
|
|
(
|
|
{
|
|
title,
|
|
description,
|
|
size = 'small',
|
|
visible,
|
|
onCancel,
|
|
onConfirm,
|
|
loading: loading_ = false,
|
|
cancelLabel = 'Cancel',
|
|
confirmLabel = 'Submit',
|
|
confirmLabelLoading,
|
|
alert = undefined,
|
|
children,
|
|
variant = 'default',
|
|
disabled,
|
|
...props
|
|
},
|
|
ref
|
|
) => {
|
|
useEffect(() => {
|
|
if (visible) {
|
|
setLoading(false)
|
|
}
|
|
}, [visible])
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
const onSubmit: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
setLoading(true)
|
|
onConfirm()
|
|
}
|
|
|
|
return (
|
|
<Dialog
|
|
open={visible}
|
|
{...props}
|
|
onOpenChange={() => {
|
|
if (visible) {
|
|
onCancel()
|
|
}
|
|
}}
|
|
>
|
|
<DialogContent ref={ref} className="p-0 gap-0 pb-5 !block" size={size}>
|
|
<DialogHeader className={cn('border-b')} padding={'small'}>
|
|
<DialogTitle className="">{title}</DialogTitle>
|
|
{description && <DialogDescription>{description}</DialogDescription>}
|
|
</DialogHeader>
|
|
{alert && (
|
|
<Admonition
|
|
type={variant as 'default' | 'destructive' | 'warning'}
|
|
label={alert.title}
|
|
description={alert.description}
|
|
className="border-r-0 border-l-0 rounded-none -mt-px [&_svg]:ml-0.5 mb-0"
|
|
{...alert?.base}
|
|
/>
|
|
)}
|
|
{children && (
|
|
<>
|
|
<DialogSection padding={'small'}>{children}</DialogSection>
|
|
<DialogSectionSeparator />
|
|
</>
|
|
)}
|
|
<div className="flex gap-2 px-5 pt-5">
|
|
<Button
|
|
size="medium"
|
|
block
|
|
type="default"
|
|
disabled={loading}
|
|
onClick={() => onCancel()}
|
|
>
|
|
{cancelLabel}
|
|
</Button>
|
|
|
|
<Button
|
|
block
|
|
size="medium"
|
|
type={
|
|
variant === 'destructive' ? 'danger' : variant === 'warning' ? 'warning' : 'primary'
|
|
}
|
|
htmlType="submit"
|
|
loading={loading}
|
|
disabled={loading || disabled}
|
|
onClick={onSubmit}
|
|
className="truncate"
|
|
>
|
|
{confirmLabel}
|
|
</Button>
|
|
</div>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|
|
)
|
|
|
|
ConfirmationModal.displayName = 'ConfirmationModal'
|
|
|
|
export default ConfirmationModal
|