Files
4649bf911e feat: new api keys [hidden] (#33252)
* 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>
2025-02-05 15:21:10 +01:00

136 lines
4.1 KiB
TypeScript

import { Megaphone } from 'lucide-react'
import { forwardRef, PropsWithChildren, ReactNode } from 'react'
import { Badge, Button, Loading, cn } from 'ui'
interface PanelProps {
className?: string
footer?: JSX.Element | false
loading?: boolean
noMargin?: boolean
title?: ReactNode | false
wrapWithLoading?: boolean
noHideOverflow?: boolean
titleClasses?: string
}
function Panel(props: PropsWithChildren<PanelProps>) {
const content = (
<div
className={cn(
'bg-surface-100',
'rounded-md border shadow-sm',
props.noHideOverflow ? '' : 'overflow-hidden',
props.noMargin ? '' : 'mb-4 md:mb-8',
props.className
)}
>
{props.title && (
<div
className={cn(
'bg-surface-100 border-b border-default flex items-center px-4 md:px-6 py-4',
props.titleClasses
)}
>
{props.title}
</div>
)}
{props.children}
{props.footer && (
<div className="bg-surface-100 border-t border-default">
<div className="flex h-12 items-center px-4 md:px-6">{props.footer}</div>
</div>
)}
</div>
)
if (props.wrapWithLoading === false) {
return content
}
return <Loading active={Boolean(props.loading)}>{content}</Loading>
}
function Content({ children, className }: { children: ReactNode; className?: string | false }) {
return <div className={cn('px-4 md:px-6 py-4', className)}>{children}</div>
}
const PanelNotice = forwardRef<
HTMLDivElement,
{
className?: string | false
title?: string
description?: string
href?: string
buttonText?: string
badgeLabel?: string
}
>(({ className, title, description, href, buttonText, badgeLabel, ...props }, ref) => {
return (
<div
ref={ref}
{...props}
className={cn(
'relative px-4 md:px-6 py-5 bg-studio flex flex-col lg:flex-row lg:justify-between gap-6 overflow-hidden lg:items-center',
className
)}
>
<div
className="absolute inset-0 -mt-[5px]"
style={{
backgroundImage: `
linear-gradient(to right, hsl(var(--background-200)/1) 0%, hsl(var(--background-200)/1) 30%, hsl(var(--background-200)/0) 100%),
linear-gradient(to right, hsl(var(--border-default)/0.33) 1px, transparent 1px),
linear-gradient(to bottom, hsl(var(--border-default)/0.33) 1px, transparent 1px)
`,
backgroundSize: '100% 100%, 15px 15px, 15px 15px',
backgroundPosition: '0 0, 0 0, 0 0',
}}
></div>
<div className="relative flex flex-col gap-1">
<div className="flex flex-row items-center -space-x-px">
<Badge
variant={'default'}
className="
rounded-r-none
pr-2
flex-shrink-0 gap-1.5 border-dashed bg-opacity-0 bg-surface-400 text-foreground-lighter"
>
<Megaphone size={16} strokeWidth={1.2} />
<span className="text-foreground-lighter">{badgeLabel ?? 'Upcoming change'}</span>
</Badge>
<Badge
variant={'default'}
className="
rounded-l-none
flex-shrink-0 gap-1.5 bg-opacity-0 bg-surface-400 text-foreground-lighter border-l-0"
>
<span className="text-foreground text-xs">{title}</span>
</Badge>
{/* <span className="font-medium text-foreground text-sm">{title}</span> */}
</div>
{description && (
<div className="text-foreground-light text-sm flex flex-col gap-0">
<div className="prose text-xs max-w-none [&_p]:mt-2 [&_p]:mb-0">{description}</div>
</div>
)}
</div>
{href && (
<div>
<Button size="tiny" type="default" className="text-xs" asChild>
<a href={href} target="_blank" rel="noreferrer noopener">
{buttonText ?? 'Read the accouncement'}
</a>
</Button>
</div>
)}
</div>
)
})
PanelNotice.displayName = 'PanelNotice'
Panel.Content = Content
Panel.Notice = PanelNotice
export default Panel