import { useState } from 'react' import { Button, SidePanel } from 'ui' import { useParams } from 'common' import { getKeys, useAPIKeysQuery } from 'data/api-keys/api-keys-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query' import { useAppStateSnapshot } from 'state/app-state' import { Bucket, EdgeFunction, EdgeFunctions, Entities, Entity, Introduction, RPC, Realtime, Storage, StoredProcedures, UserManagement, } from './Content' import FirstLevelNav from './FirstLevelNav' import LanguageSelector from './LanguageSelector' import SecondLevelNav from './SecondLevelNav' /** * [Joshen] Reminder: when we choose to release this as a main feature * Ensure that UX is better than the existing, and make sure we do the * necessary communications around releasing this. * * Problems: * - Needs URL support * - Language selector is not clear, users are missing the bash language option * - GraphiQL needs a better home, cannot be placed under Database as its "API" */ const ProjectAPIDocs = () => { const { ref } = useParams() const snap = useAppStateSnapshot() const isIntroduction = snap.activeDocsSection.length === 1 && snap.activeDocsSection[0] === 'introduction' const isEntityDocs = snap.activeDocsSection.length === 2 && snap.activeDocsSection[0] === 'entities' const [showKeys, setShowKeys] = useState(false) const language = snap.docsLanguage const { data: apiKeys } = useAPIKeysQuery( { projectRef: ref }, { enabled: snap.showProjectApiDocs } ) const { data: settings } = useProjectSettingsV2Query( { projectRef: ref }, { enabled: snap.showProjectApiDocs } ) const { data: customDomainData } = useCustomDomainsQuery( { projectRef: ref }, { enabled: snap.showProjectApiDocs } ) const { anonKey } = getKeys(apiKeys) const apikey = showKeys ? anonKey?.api_key ?? 'SUPABASE_CLIENT_ANON_KEY' : 'SUPABASE_CLIENT_ANON_KEY' const protocol = settings?.app_config?.protocol ?? 'https' const hostEndpoint = settings?.app_config?.endpoint const endpoint = customDomainData?.customDomain?.status === 'active' ? `https://${customDomainData.customDomain?.hostname}` : `${protocol}://${hostEndpoint ?? ''}` return ( snap.setShowProjectApiDocs(false)} >

API Docs

{!isEntityDocs && } {isIntroduction && ( )}
{snap.activeDocsSection.length === 1 ? : }
{snap.activeDocsSection[0] === 'introduction' && ( )} {snap.activeDocsSection[0] === 'user-management' && ( )} {snap.activeDocsSection[0] === 'realtime' && } {snap.activeDocsSection[0] === 'storage' && ( <> {snap.activeDocsSection[1] !== undefined ? ( ) : ( )} )} {snap.activeDocsSection[0] === 'edge-functions' && ( <> {snap.activeDocsSection[1] !== undefined ? ( ) : ( )} )} {snap.activeDocsSection[0] === 'entities' && ( <> {snap.activeDocsSection[1] !== undefined ? ( ) : ( )} )} {snap.activeDocsSection[0] === 'stored-procedures' && ( <> {snap.activeDocsSection[1] !== undefined ? ( ) : ( )} )}
) } export default ProjectAPIDocs