mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
## What kind of change does this PR introduce? Bug fix / design-system alignment for the legacy `Button` from `ui`. ## What is the current behavior? Omitting `variant` on the legacy `Button` falls back to brand-green `primary`. That makes accidental greens easy, and it is hard to spot the real main action on busy pages. ## What is the new behavior? - Legacy `Button` now defaults to neutral `default` - Intentional primary CTAs (create, save, submit, marketing CTAs, and matching `ButtonTooltip` usages) now set `variant="primary"` so their appearance is unchanged - Neutral actions that previously relied on the old fallback (cancel, close, back, dashboard nav, and similar) become grey/white - Design-system docs updated; regression tests cover the new default `Button_Shadcn_` is unchanged. It already uses its own CVA default. This is PR 1 of 2 in a stack. PR 2 drops now-redundant `variant="default"` props. ## To test Studio (http://localhost:8082): - `/sign-in`: Sign in stays green - Open a project → Database → Tables: New table stays green - Auth → Users → Invite: Invite user stays green; Cancel / dismiss controls stay neutral - Project Settings → General: edit a field so Cancel and Save appear. Cancel is neutral, Save is green Design system (http://localhost:3003): - Components → Button: default demo is neutral; primary demo is green; featured preview is the default variant Marketing (optional): - www header: Start your project stays green; logged-in Dashboard is neutral <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Style** - Buttons now default to a neutral style, while primary actions across Studio, documentation, marketing pages, forms, dialogs, and error states use prominent primary styling. - Updated button examples and previews clarify the distinction between default and primary variants. - Event registration now includes a directional arrow icon. - **Tests** - Added coverage confirming default button styling and explicit primary styling behave as expected. - Updated related test fixtures to use primary styling where appropriate. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
import { useParams } from 'common'
|
|
import { useState } from 'react'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogBody,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
Button,
|
|
} from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { useAPIKeyCreateMutation } from '@/data/api-keys/api-key-create-mutation'
|
|
|
|
export const CreateNewAPIKeysButton = () => {
|
|
const { ref: projectRef } = useParams()
|
|
|
|
const [createKeysDialogOpen, setCreateKeysDialogOpen] = useState(false)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
const { mutateAsync: createAPIKey } = useAPIKeyCreateMutation({ onError: () => {} })
|
|
|
|
const handleCreateNewApiKeys = async () => {
|
|
if (!projectRef) return
|
|
|
|
try {
|
|
setError(null)
|
|
|
|
// Create publishable key
|
|
try {
|
|
await createAPIKey({ projectRef, type: 'publishable', name: 'default' })
|
|
} catch (error: any) {
|
|
setError(`Failed to create the default publishable key: ${error.message}`)
|
|
throw error
|
|
}
|
|
|
|
// Create secret key
|
|
try {
|
|
await createAPIKey({ projectRef, type: 'secret', name: 'default' })
|
|
} catch (error: any) {
|
|
setError(
|
|
`The default publishable key was created, but the default secret key failed: ${error.message}`
|
|
)
|
|
throw error
|
|
}
|
|
|
|
setCreateKeysDialogOpen(false)
|
|
toast.success('Successfully created a new set of API keys!')
|
|
} catch (error) {
|
|
console.error('Failed to create API keys:', error)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
return (
|
|
<AlertDialog open={createKeysDialogOpen} onOpenChange={setCreateKeysDialogOpen}>
|
|
<Button variant="primary" onClick={() => setCreateKeysDialogOpen(true)}>
|
|
Create new API keys
|
|
</Button>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Create new API keys</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
This will create a default publishable key and a default secret key both named{' '}
|
|
<code className="break-keep! text-code-inline">default</code>. These keys are required
|
|
to connect your application to your Supabase project. Your existing legacy API keys (
|
|
<code className="break-keep! text-code-inline">anon</code> and{' '}
|
|
<code className="break-keep! text-code-inline">service_role</code>) are not affected and
|
|
remain valid until you disable them in a separate step.
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
{error && (
|
|
<AlertDialogBody>
|
|
<Admonition type="destructive" title="Unable to create API keys" description={error} />
|
|
</AlertDialogBody>
|
|
)}
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
<AlertDialogAction onClick={handleCreateNewApiKeys}>Create keys</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
)
|
|
}
|