mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Download } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import { toast } from 'sonner'
|
|
import { Button } from 'ui'
|
|
|
|
import ContentSnippet from '../ContentSnippet'
|
|
import { DOCS_CONTENT } from '../ProjectAPIDocs.constants'
|
|
import type { ContentProps } from './Content.types'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query'
|
|
import { generateTypes } from '@/data/projects/project-type-generation-query'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
export const Entities = ({ language }: ContentProps) => {
|
|
const { ref } = useParams()
|
|
const [isGeneratingTypes, setIsGeneratingTypes] = useState(false)
|
|
|
|
const { data: config } = useProjectPostgrestConfigQuery({ projectRef: ref })
|
|
|
|
const onClickGenerateTypes = async () => {
|
|
try {
|
|
setIsGeneratingTypes(true)
|
|
const res = await generateTypes({ ref, included_schemas: config?.db_schema })
|
|
let element = document.createElement('a')
|
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(res.types))
|
|
element.setAttribute('download', 'supabase.ts')
|
|
element.style.display = 'none'
|
|
document.body.appendChild(element)
|
|
element.click()
|
|
document.body.removeChild(element)
|
|
toast.success(`Successfully generated types! File is being downloaded`)
|
|
} catch (error: any) {
|
|
toast.error(`Failed to generate types: ${error.message}`)
|
|
} finally {
|
|
setIsGeneratingTypes(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<ContentSnippet selectedLanguage={language} snippet={DOCS_CONTENT.entitiesIntroduction} />
|
|
<div>
|
|
<ContentSnippet selectedLanguage={language} snippet={DOCS_CONTENT.generatingTypes} />
|
|
<div className="flex items-center gap-x-2 px-4 mt-3">
|
|
<DocsButton href={`${DOCS_URL}/guides/database/api/generating-types`} />
|
|
<Button
|
|
disabled={isGeneratingTypes}
|
|
loading={isGeneratingTypes}
|
|
icon={<Download strokeWidth={1.5} />}
|
|
onClick={onClickGenerateTypes}
|
|
>
|
|
Generate and download types
|
|
</Button>
|
|
</div>
|
|
<p className="text-xs text-foreground-light px-4 mt-2">
|
|
Remember to re-generate and download this file as you make changes to your tables.
|
|
</p>
|
|
</div>
|
|
<ContentSnippet selectedLanguage={language} snippet={DOCS_CONTENT.graphql} />
|
|
</>
|
|
)
|
|
}
|