mirror of
https://github.com/supabase/supabase.git
synced 2026-06-21 09:47:20 +08:00
* chore(studio): add param routing to policies crud panels * chore(studio): policy not found if opening edit or delete panel with wrong id * integrate useQueryStateWithSelect to Policies * add useQueryStateWithSelect to db triggers * add useQueryStateWithSelect to AddUserDropdown * add useQueryStateWithSelect to OAuthApps * add useQueryStateWithSelect to API Keyys * revert policies and users param routing
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { Trash2 } from 'lucide-react'
|
|
|
|
import { DropdownMenuItemTooltip } from 'components/ui/DropdownMenuItemTooltip'
|
|
import { useAsyncCheckPermissions } from 'hooks/misc/useCheckPermissions'
|
|
import type { APIKeysData } from 'data/api-keys/api-keys-query'
|
|
|
|
interface APIKeyDeleteDialogProps {
|
|
apiKey: Extract<APIKeysData[number], { type: 'secret' | 'publishable' }>
|
|
setKeyToDelete: (id: string | null) => void
|
|
}
|
|
|
|
export const APIKeyDeleteDialog = ({ apiKey, setKeyToDelete }: APIKeyDeleteDialogProps) => {
|
|
const { can: canDeleteAPIKeys } = useAsyncCheckPermissions(
|
|
PermissionAction.TENANT_SQL_ADMIN_WRITE,
|
|
'*'
|
|
)
|
|
|
|
return (
|
|
<DropdownMenuItemTooltip
|
|
className="flex gap-2"
|
|
onClick={() => {
|
|
if (canDeleteAPIKeys) {
|
|
setKeyToDelete(apiKey.id)
|
|
}
|
|
}}
|
|
disabled={!canDeleteAPIKeys}
|
|
tooltip={{
|
|
content: {
|
|
side: 'left',
|
|
text: !canDeleteAPIKeys
|
|
? 'You need additional permissions to delete API keys'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
<Trash2 size={14} strokeWidth={1.5} /> Delete API key
|
|
</DropdownMenuItemTooltip>
|
|
)
|
|
}
|