Files
supabase/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainVerify.tsx
T
Danny White 1131e3e2ce fix(ui): default Button variant to default instead of primary (#50160)
## 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 -->
2026-09-10 11:23:17 +10:00

202 lines
7.5 KiB
TypeScript

import { useParams } from 'common'
import { AlertCircle, RefreshCw } from 'lucide-react'
import { useEffect } from 'react'
import { toast } from 'sonner'
import { Alert, AlertDescription, AlertTitle, Button, WarningIcon } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { DNSRecord } from './DNSRecord'
import { DNSTableHeaders } from './DNSTableHeaders'
import { DocsButton } from '@/components/ui/DocsButton'
import { InlineLink } from '@/components/ui/InlineLink'
import Panel from '@/components/ui/Panel'
import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
import { useCustomDomainDeleteMutation } from '@/data/custom-domains/custom-domains-delete-mutation'
import { useCustomDomainsQuery } from '@/data/custom-domains/custom-domains-query'
import { useCustomDomainReverifyQuery } from '@/data/custom-domains/custom-domains-reverify-query'
import { DOCS_URL } from '@/lib/constants'
export const CustomDomainVerify = () => {
const { ref: projectRef } = useParams()
const { data: settings } = useProjectSettingsV2Query({ projectRef })
const { data: customDomainData } = useCustomDomainsQuery({ projectRef })
const customDomain = customDomainData?.customDomain
const isSSLCertificateDeploying =
customDomain?.ssl.status !== undefined && customDomain.ssl.txt_name === undefined
const { mutate: deleteCustomDomain, isPending: isDeleting } = useCustomDomainDeleteMutation({
onSuccess: () => {
toast.success(
'Custom domain setup cancelled successfully. It may take a few seconds before your custom domain is fully removed, so you may need to refresh your browser.'
)
},
})
const {
data: reverifyData,
refetch: refetchReverify,
isFetching: isReverifyLoading,
isError: isReverifyError,
error: reverifyError,
} = useCustomDomainReverifyQuery(
{ projectRef },
{
// Poll every 10 seconds if the SSL certificate is being deployed
refetchInterval: isSSLCertificateDeploying && !isDeleting ? 10000 : false,
}
)
useEffect(() => {
if (isReverifyError) {
toast.error(reverifyError?.message)
}
}, [isReverifyError, reverifyError])
const isNotVerifiedYet = reverifyData?.status === '2_initiated'
const hasCAAErrors = customDomain?.ssl.validation_errors?.reduce(
(acc, error) => acc || error.message.includes('caa_error'),
false
)
const isValidating = (customDomain?.ssl.txt_name ?? '') === ''
const onReverifyCustomDomain = () => {
if (!projectRef) return console.error('Project ref is required')
refetchReverify()
}
const onCancelCustomDomain = async () => {
if (!projectRef) return console.error('Project ref is required')
deleteCustomDomain({ projectRef })
}
return (
<>
<Panel.Content className="space-y-6">
<div>
<h4 className="text-foreground mb-2">
Configure TXT verification for your custom domain{' '}
<code className="text-code-inline">{customDomain?.hostname}</code>
</h4>
<p className="text-sm text-foreground-light">
Set the following TXT record(s) in your DNS provider, then click verify to confirm your
control over the domain. Records which have been successfully verified will be removed
from this list below.
</p>
{!isValidating && (
<div className="mt-4 mb-2">
<Admonition
type="note"
title={
isNotVerifiedYet
? 'Unable to verify records from DNS provider yet.'
: 'Please note that it may take up to 24 hours for the DNS records to propagate.'
}
>
<p>
You may also visit{' '}
<InlineLink href={`https://whatsmydns.net/#TXT/${customDomain?.ssl.txt_name}`}>
here
</InlineLink>{' '}
to check if your DNS has been propagated successfully before clicking verify.
</p>
{isNotVerifiedYet && (
<p className="mt-1">
Some registrars will require you to remove the domain name when creating DNS
records. As an example, to create a record for{' '}
<code className="text-code-inline">foo.app.example.com</code>, you would need to
create an entry for <code className="text-code-inline">foo.app</code>.
</p>
)}
</Admonition>
</div>
)}
</div>
{hasCAAErrors && (
<Alert>
<WarningIcon />
<AlertTitle>Certificate Authority Authentication (CAA) error</AlertTitle>
<AlertDescription>
Please add a CAA record allowing "digicert.com" to issue certificates for{' '}
<code className="text-code-inline">{customDomain?.hostname}</code>. For example:{' '}
<code className="text-code-inline">0 issue "digicert.com"</code>
</AlertDescription>
</Alert>
)}
{customDomain?.ssl.status === 'validation_timed_out' ? (
<Alert>
<WarningIcon />
<AlertTitle>Validation timed out</AlertTitle>
<AlertDescription>
Please click "Verify" again to retry the validation of the records
</AlertDescription>
</Alert>
) : (
<div className="space-y-2">
<DNSTableHeaders display={customDomain?.ssl.txt_name ?? ''} />
{customDomain?.verification_errors?.includes(
'custom hostname does not CNAME to this zone.'
) && (
<DNSRecord
type="CNAME"
name={customDomain?.hostname}
value={settings?.app_config?.endpoint ?? 'Loading...'}
/>
)}
{!isValidating && customDomain?.ssl.status === 'pending_validation' && (
<DNSRecord
type="TXT"
name={customDomain?.ssl.txt_name ?? 'Loading...'}
value={customDomain?.ssl.txt_value ?? 'Loading...'}
/>
)}
{customDomain?.ssl.status === 'pending_deployment' && (
<div className="flex items-center justify-center space-x-2 py-8">
<AlertCircle size={16} strokeWidth={1.5} />
<p className="text-sm text-foreground-light">
SSL certificate is being deployed. Please wait a few minutes and try again.
</p>
</div>
)}
</div>
)}
</Panel.Content>
<div className="border-t border-muted" />
<Panel.Content>
<div className="flex items-center justify-between">
<DocsButton href={`${DOCS_URL}/guides/platform/custom-domains`} />
<div className="flex items-center space-x-2">
<Button
variant="default"
onClick={onCancelCustomDomain}
loading={isDeleting}
className="self-end"
>
Cancel
</Button>
<Button
variant="primary"
icon={<RefreshCw />}
onClick={onReverifyCustomDomain}
loading={!isValidating && isReverifyLoading}
disabled={isDeleting || isReverifyLoading || isValidating}
className="self-end"
>
Verify
</Button>
</div>
</div>
</Panel.Content>
</>
)
}