mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 00:19:08 +00:00
## Problem Studio relies on repeated classes to style inline code. Bare `<code>` elements can miss those styles. ## Solution Import the shared styles from #51980 and remove the repeated classes. Keep Markdown renderer behaviour and existing size overrides. Use `data-code-style="plain"` for webhook headers, CLI and upgrade commands, configuration comparisons and connected-resource labels that have their own layout. ## Review instructions Dashboard review: this PR changes Studio only. 1. Open [Database > Extensions](https://studio-staging-git-dnywh-depr-707-code-studio-supabase.vercel.app/dashboard/project/_/database/extensions). Search for `pg_trgm` or another disabled extension and turn on its toggle to open the Enable dialog. Check the Extension and Schema values and the help text under “Install in a different schema”. The SQL block should keep its highlighting and copy control. Close without installing. 2. Open [Edge Functions > Secrets](https://studio-staging-git-dnywh-depr-707-code-studio-supabase.vercel.app/dashboard/project/_/functions/secrets). Scroll to “Default secrets” and check `SUPABASE_URL` and `SUPABASE_DB_URL`: both should use the bordered inline-code style. Hover a name to see “Click to copy”, then click it and confirm the name is copied. No custom secret or deployed function is needed. 3. Compare light and dark themes at narrow and desktop widths. | Before | After | | --- | --- | | <img width="812" height="1066" alt="CleanShot 2026-10-19 at 15 35 10@2x" src="https://github.com/user-attachments/assets/e4a21310-1fac-4143-9ee6-d2452ab4f314" /> | <img width="812" height="1068" alt="CleanShot 2026-10-20 at 15 39 20@2x" src="https://github.com/user-attachments/assets/d2c91ef6-7836-4c71-8f15-d0c0df8e969d" /> |
195 lines
7.2 KiB
TypeScript
195 lines
7.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import { AlertCircleIcon, RefreshCwIcon } 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>{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>foo.app.example.com</code>,
|
|
you would need to create an entry for <code>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>{customDomain?.hostname}</code>. For example:{' '}
|
|
<code>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">
|
|
<AlertCircleIcon 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 onClick={onCancelCustomDomain} loading={isDeleting} className="self-end">
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
variant="primary"
|
|
icon={<RefreshCwIcon />}
|
|
onClick={onReverifyCustomDomain}
|
|
loading={!isValidating && isReverifyLoading}
|
|
disabled={isDeleting || isReverifyLoading || isValidating}
|
|
className="self-end"
|
|
>
|
|
Verify
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</Panel.Content>
|
|
</>
|
|
)
|
|
}
|