mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { useParams } from 'common'
|
|
import { BookOpenText } from 'lucide-react'
|
|
|
|
import { ButtonTooltip } from './ButtonTooltip'
|
|
import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
|
|
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
|
|
interface APIDocsButtonProps {
|
|
section?: string[]
|
|
source: string
|
|
}
|
|
|
|
export const APIDocsButton = ({ section, source }: APIDocsButtonProps) => {
|
|
const snap = useAppStateSnapshot()
|
|
const { ref } = useParams()
|
|
const { data: org } = useSelectedOrganizationQuery()
|
|
const { mutate: sendEvent } = useSendEventMutation()
|
|
|
|
return (
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
type="default"
|
|
onClick={() => {
|
|
if (section) snap.setActiveDocsSection(section)
|
|
snap.setShowProjectApiDocs(true)
|
|
|
|
sendEvent({
|
|
action: 'api_docs_opened',
|
|
properties: {
|
|
source,
|
|
},
|
|
groups: {
|
|
project: ref ?? 'Unknown',
|
|
organization: org?.slug ?? 'Unknown',
|
|
},
|
|
})
|
|
}}
|
|
icon={<BookOpenText />}
|
|
className="w-7"
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: 'API Docs',
|
|
},
|
|
}}
|
|
/>
|
|
)
|
|
}
|