mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +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
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useEffect } from 'react'
|
|
import {
|
|
Button,
|
|
cn,
|
|
Dialog,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogSection,
|
|
DialogSectionSeparator,
|
|
DialogTitle,
|
|
Form,
|
|
} from 'ui'
|
|
|
|
import { AIOptInLevelSelector } from '@/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector'
|
|
import { useAIOptInForm } from '@/hooks/forms/useAIOptInForm'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
|
|
interface AIOptInModalProps {
|
|
visible: boolean
|
|
onCancel: () => void
|
|
}
|
|
|
|
export const AIOptInModal = ({ visible, onCancel }: AIOptInModalProps) => {
|
|
const { form, onSubmit, isUpdating, currentOptInLevel } = useAIOptInForm(onCancel)
|
|
const { can: canUpdateOrganization } = useAsyncCheckPermissions(
|
|
PermissionAction.UPDATE,
|
|
'organizations'
|
|
)
|
|
|
|
const onOpenChange = (open: boolean) => {
|
|
if (!open) {
|
|
onCancel()
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (visible) {
|
|
form.reset({ aiOptInLevel: currentOptInLevel })
|
|
}
|
|
}, [visible, currentOptInLevel, form])
|
|
|
|
return (
|
|
<Dialog open={visible} onOpenChange={onOpenChange}>
|
|
<DialogContent size="large" aria-describedby={undefined}>
|
|
<Form {...form}>
|
|
<form id="ai-opt-in-form" onSubmit={form.handleSubmit(onSubmit)}>
|
|
<DialogHeader padding="small">
|
|
<DialogTitle>Update Supabase Assistant Opt-in Level</DialogTitle>
|
|
</DialogHeader>
|
|
|
|
<DialogSectionSeparator />
|
|
|
|
<DialogSection className="space-y-4 pb-0" padding="small">
|
|
<AIOptInLevelSelector
|
|
control={form.control}
|
|
disabled={!canUpdateOrganization || isUpdating}
|
|
/>
|
|
</DialogSection>
|
|
|
|
<DialogFooter
|
|
padding="small"
|
|
className={cn(!canUpdateOrganization && 'justify-between!')}
|
|
>
|
|
{!canUpdateOrganization && (
|
|
<p className="text-sm text-foreground-lighter">
|
|
You need additional permissions to update the opt-in level
|
|
</p>
|
|
)}
|
|
<div className="flex items-center gap-x-2">
|
|
<Button disabled={isUpdating} onClick={onCancel}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
variant="primary"
|
|
type="submit"
|
|
form="ai-opt-in-form"
|
|
loading={isUpdating}
|
|
disabled={isUpdating || !canUpdateOrganization || !form.formState.isDirty}
|
|
>
|
|
Confirm
|
|
</Button>
|
|
</div>
|
|
</DialogFooter>
|
|
</form>
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|