mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
Follow-up to #48344: collapses the two resolution paths for the Admonition module into one. `src/admonition.tsx` was a back-compat shim re-exporting `src/Admonition/`. Two ways to resolve one module is exactly what produced the macOS self-import bug fixed in #48344, and the local typecheck errors that #48374 worked around. This removes the shim and standardizes on the PascalCase subpath, matching every other export in the package. **Changed:** - Codemodded all 246 `ui-patterns/admonition` imports to `ui-patterns/Admonition` (240 `.tsx`, 5 `.mdx`, 1 `.ts` across studio, docs, www, design-system, and lite-studio) - Pointed the 5 internal `'../admonition'` imports back at the `'../Admonition'` directory **Removed:** - `packages/ui-patterns/src/admonition.tsx`, and its `./admonition` entry in the exports map (regenerated with `pnpm gen:exports`) ## To test - `grep -r "ui-patterns/admonition" --include='*.ts*'` → no hits - `pnpm test:case-hazards` → passes - `pnpm typecheck` → all 15 tasks green - `pnpm --filter studio run lint:ratchet` → passes - `pnpm --filter ui-patterns vitest run src/Admonition` → 11 tests pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Standardized Admonition component imports across the application and documentation. * Improved compatibility with case-sensitive environments by using the canonical component path. * Removed the legacy Admonition import entry point. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
108 lines
3.7 KiB
TypeScript
108 lines
3.7 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 variant="default" 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 variant="default" 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}
|
|
/>
|
|
</>
|
|
)
|
|
}
|