mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Summary Follow-up to #54070. Removes the `data-attr` attributes added there, as raised in review: PostHog autocapture is off (`autocapture: false` in `packages/common/posthog-client.ts`), so they send nothing. Copy, reveal, create and remove are all tracked with explicit `track()` calls. Removes `data-attr` from the API key copy and reveal buttons, the delete menu item, both create dialogs, and the initial-setup "Create keys" action. The two docs links and the `DocsButton` `data-attr` prop are removed in #54119 instead, since that PR also edits `DocsButton`. The two PRs touch different files and can merge in either order. No behavior or tracking change. ## Testing - `tsc`, the lint ratchet and the Studio unit tests pass.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Trash2Icon } from 'lucide-react'
|
|
|
|
import { DropdownMenuItemTooltip } from '@/components/ui/DropdownMenuItemTooltip'
|
|
import type { APIKeysData } from '@/data/api-keys/api-keys-query'
|
|
import { getWriteGrantTooltip, useGrant } from '@/lib/grants'
|
|
|
|
interface APIKeyDeleteDialogProps {
|
|
apiKey: Extract<APIKeysData[number], { type: 'secret' | 'publishable' }>
|
|
setKeyToDelete: (id: string | null) => void
|
|
}
|
|
|
|
export const APIKeyDeleteDialog = ({ apiKey, setKeyToDelete }: APIKeyDeleteDialogProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const deleteGrant = useGrant('DELETE /v1/projects/{ref}/api-keys/{id}', { projectRef })
|
|
const canDeleteAPIKeys = deleteGrant.status === 'granted'
|
|
|
|
return (
|
|
<DropdownMenuItemTooltip
|
|
className="flex gap-2"
|
|
onClick={() => {
|
|
if (canDeleteAPIKeys) {
|
|
setKeyToDelete(apiKey.id)
|
|
}
|
|
}}
|
|
disabled={!canDeleteAPIKeys}
|
|
tooltip={{
|
|
content: {
|
|
side: 'left',
|
|
text: getWriteGrantTooltip(deleteGrant.status, 'delete', 'API keys'),
|
|
},
|
|
}}
|
|
>
|
|
<Trash2Icon size={14} /> Delete API key
|
|
</DropdownMenuItemTooltip>
|
|
)
|
|
}
|