mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
* chore: branching off breaking down scoped pat work This branches off the scoped PAT prototype and gives us a first base to go off. In this branch I will be migrating access tokens to their new visual style but they will be behaving as they currently do. * chore: separate sheet and dialog Separated the new scoped PAT sheet off. We can interchange. Anyway we will probably need to when opt in and out becomes available. * fix: remove unused part of test The test was still checking for permissions. Hidden that for now. * Fix prettier * Clean up * Hide new token banner if deleting the new token that was created * Clean up * Nit prettier import sorts * feat: remove future files for now This removes some of the upcoming components for Scopted PATs as its not really in scope of this. Also tidys up imports etc in files * Nit refactors * Update warning dialog in NewAccessTokenDialog * chore: regenerate types * chore: regenerate types again * fix: update mock response in new access token button test --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { ChevronDown } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
import { NewAccessTokenDialog } from './NewAccessTokenDialog'
|
|
|
|
export interface NewAccessTokenButtonProps {
|
|
onCreateToken: (token: any) => void
|
|
}
|
|
|
|
export const NewAccessTokenButton = ({ onCreateToken }: NewAccessTokenButtonProps) => {
|
|
const [visible, setVisible] = useState(false)
|
|
const [tokenScope, setTokenScope] = useState<'V0' | undefined>(undefined)
|
|
|
|
return (
|
|
<>
|
|
<div className="flex items-center">
|
|
<Button
|
|
className="rounded-r-none px-3"
|
|
onClick={() => {
|
|
setTokenScope(undefined)
|
|
setVisible(true)
|
|
}}
|
|
>
|
|
Generate new token
|
|
</Button>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
type="primary"
|
|
title="Choose token scope"
|
|
className="rounded-l-none px-[4px] py-[5px]"
|
|
icon={<ChevronDown />}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" side="bottom">
|
|
<DropdownMenuItem
|
|
key="experimental-token"
|
|
onClick={() => {
|
|
setTokenScope('V0')
|
|
setVisible(true)
|
|
}}
|
|
>
|
|
<div className="space-y-1">
|
|
<p className="block text-foreground">Generate token for experimental API</p>
|
|
</div>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
|
|
<NewAccessTokenDialog
|
|
open={visible}
|
|
onOpenChange={setVisible}
|
|
tokenScope={tokenScope}
|
|
onCreateToken={onCreateToken}
|
|
/>
|
|
</>
|
|
)
|
|
}
|