mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
476d4a5851
## 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
114 lines
3.5 KiB
TypeScript
114 lines
3.5 KiB
TypeScript
import { useState } from 'react'
|
|
import {
|
|
Button,
|
|
Dialog,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogSection,
|
|
DialogSectionSeparator,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { INTERNAL_SCHEMAS, useIsProtectedSchema } from '@/hooks/useProtectedSchemas'
|
|
|
|
export const ProtectedSchemaDialog = ({ onClose }: { onClose: () => void }) => {
|
|
return (
|
|
<>
|
|
<DialogHeader>
|
|
<DialogTitle>Schemas managed by Supabase</DialogTitle>
|
|
</DialogHeader>
|
|
<DialogSectionSeparator />
|
|
<DialogSection className="space-y-2 prose">
|
|
<p className="text-sm">
|
|
The following schemas are managed by Supabase and are currently protected from write
|
|
access through the dashboard.
|
|
</p>
|
|
<div className="flex flex-wrap gap-1">
|
|
{INTERNAL_SCHEMAS.map((schema) => (
|
|
<code key={schema} className="text-xs">
|
|
{schema}
|
|
</code>
|
|
))}
|
|
</div>
|
|
<p className="text-sm mt-4!">
|
|
These schemas are critical to the functionality of your Supabase project and hence we
|
|
highly recommend not altering them.
|
|
</p>
|
|
<p className="text-sm">
|
|
You can, however, still interact with those schemas through the SQL Editor although we
|
|
advise you only do so if you know what you are doing.
|
|
</p>
|
|
</DialogSection>
|
|
<DialogFooter>
|
|
<div className="flex items-center justify-end space-x-2">
|
|
<Button onClick={onClose}>Understood</Button>
|
|
</div>
|
|
</DialogFooter>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const ProtectedSchemaWarning = ({
|
|
size = 'md',
|
|
schema,
|
|
entity,
|
|
}: {
|
|
size?: 'sm' | 'md'
|
|
schema: string
|
|
entity: string
|
|
}) => {
|
|
const [showModal, setShowModal] = useState(false)
|
|
const { isSchemaLocked, reason, fdwType } = useIsProtectedSchema({ schema })
|
|
|
|
if (!isSchemaLocked) return null
|
|
|
|
const showLearnMoreDialog =
|
|
reason !== 'fdw' || (fdwType !== 'iceberg' && fdwType !== 's3_vectors')
|
|
|
|
return (
|
|
<Admonition
|
|
showIcon={size === 'sm' ? false : true}
|
|
layout={size === 'sm' ? 'vertical' : 'horizontal'}
|
|
type="note"
|
|
title={
|
|
size === 'sm' ? `Viewing protected schema` : `Viewing ${entity} from a protected schema`
|
|
}
|
|
description={
|
|
reason === 'fdw' && fdwType === 'iceberg' ? (
|
|
<p>
|
|
The <code className="text-code-inline">{schema}</code> schema is used by Supabase to
|
|
connect to analytics buckets and is read-only through the dashboard.
|
|
</p>
|
|
) : reason === 'fdw' && fdwType === 's3_vectors' ? (
|
|
<p>
|
|
The <code className="text-code-inline">{schema}</code> schema is used by Supabase to
|
|
connect to vector buckets and is read-only through the dashboard.
|
|
</p>
|
|
) : (
|
|
<p>
|
|
The <code className="text-code-inline">{schema}</code> schema is managed by Supabase and
|
|
is read-only through the dashboard.
|
|
</p>
|
|
)
|
|
}
|
|
actions={
|
|
showLearnMoreDialog && (
|
|
<Dialog open={showModal} onOpenChange={setShowModal}>
|
|
<DialogTrigger asChild>
|
|
<Button size="tiny" onClick={() => setShowModal(true)}>
|
|
Learn more
|
|
</Button>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<ProtectedSchemaDialog onClose={() => setShowModal(false)} />
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|
|
/>
|
|
)
|
|
}
|