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
106 lines
3.6 KiB
TypeScript
106 lines
3.6 KiB
TypeScript
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
|
|
import { ChevronDown, ChevronUp } from 'lucide-react'
|
|
import { useState } from 'react'
|
|
import { Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { PG_GRAPHQL_CONFIG_DOCS_URL } from './constants'
|
|
import { IntrospectionConfirmModal } from './IntrospectionConfirmModal'
|
|
import { useSetIntrospection } from './useSetIntrospection'
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
|
|
|
interface IntrospectionDisabledNoticeProps {
|
|
schema: string
|
|
currentSchemaComment: string | null | undefined
|
|
onEnabled: () => void
|
|
}
|
|
|
|
export const IntrospectionDisabledNotice = ({
|
|
schema,
|
|
currentSchemaComment,
|
|
onEnabled,
|
|
}: IntrospectionDisabledNoticeProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const [showConfirm, setShowConfirm] = useState(false)
|
|
const [isCollapsed, setIsCollapsed] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.GRAPHQL_INTROSPECTION_NOTICE_COLLAPSED(projectRef ?? ''),
|
|
false
|
|
)
|
|
|
|
const { apply, isPending, sql, existingDirectiveIsMalformed, otherExistingKeys } =
|
|
useSetIntrospection({
|
|
schema,
|
|
currentSchemaComment,
|
|
enabled: true,
|
|
onMutationSuccess: () => setShowConfirm(false),
|
|
onInvalidated: onEnabled,
|
|
})
|
|
|
|
return (
|
|
<>
|
|
{isCollapsed ? (
|
|
<div className="flex items-center justify-between gap-3 border-b bg-surface-100 px-4 py-2 text-xs text-foreground-light">
|
|
<span>
|
|
GraphQL introspection is disabled — docs explorer and autocomplete are unavailable.
|
|
</span>
|
|
<div className="flex items-center gap-1">
|
|
<Button size="tiny" onClick={() => setShowConfirm(true)}>
|
|
Enable introspection
|
|
</Button>
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
icon={<ChevronDown />}
|
|
onClick={() => setIsCollapsed(false)}
|
|
aria-label="Show introspection notice details"
|
|
/>
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<div className="relative">
|
|
<Admonition
|
|
type="default"
|
|
title="GraphQL introspection is disabled for this project"
|
|
className="m-0 rounded-none border-x-0 border-t-0"
|
|
>
|
|
<p>
|
|
GraphiQL relies on introspection to populate the docs explorer and field autocomplete.
|
|
With <code>pg_graphql</code> 1.6+, introspection is disabled by default so that
|
|
schemas aren't enumerable via the API. You can still run queries — only schema
|
|
discovery is affected.{' '}
|
|
<InlineLink href={PG_GRAPHQL_CONFIG_DOCS_URL} target="_blank" rel="noreferrer">
|
|
Learn more
|
|
</InlineLink>
|
|
.
|
|
</p>
|
|
<div className="mt-3">
|
|
<Button onClick={() => setShowConfirm(true)}>Enable introspection</Button>
|
|
</div>
|
|
</Admonition>
|
|
<Button
|
|
className="absolute right-2 top-2"
|
|
variant="text"
|
|
size="tiny"
|
|
icon={<ChevronUp />}
|
|
onClick={() => setIsCollapsed(true)}
|
|
aria-label="Collapse introspection notice"
|
|
/>
|
|
</div>
|
|
)}
|
|
|
|
<IntrospectionConfirmModal
|
|
mode="enable"
|
|
visible={showConfirm}
|
|
schema={schema}
|
|
sql={sql}
|
|
otherExistingKeys={otherExistingKeys}
|
|
existingDirectiveIsMalformed={existingDirectiveIsMalformed}
|
|
isPending={isPending}
|
|
onCancel={() => setShowConfirm(false)}
|
|
onConfirm={apply}
|
|
/>
|
|
</>
|
|
)
|
|
}
|