mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Context We've been seeing many `NotFoundError: Failed to execute 'removeChild' on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on 'Node'` events on Sentry which are historically known to be caused by Google Translate in the browser. There's technically no _right way_ to address this unfortunately, but one of the solutions which should address most of these issues is to wrap any dynamic text within a span - we've considered that quite a while back tbh but never took the time to do this until today with the help of Claude. Although just a heads up that it might not necessarily completely eradicate those issues. Also added an eslint rule which should prevent future occurences of this <img width="1264" height="192" alt="image" src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29" />
120 lines
3.4 KiB
TypeScript
120 lines
3.4 KiB
TypeScript
import { type SafeSqlFragment } from '@supabase/pg-meta'
|
|
import type { ReactNode } from 'react'
|
|
import { CodeBlock } from 'ui-patterns/CodeBlock'
|
|
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
|
|
|
|
type IntrospectionMode = 'enable' | 'disable'
|
|
|
|
interface ModeCopy {
|
|
title: string
|
|
confirmLabel: string
|
|
confirmLabelLoading: string
|
|
persistenceBullet: (schema: string) => ReactNode
|
|
securityBullet: ReactNode
|
|
}
|
|
|
|
const COPY: Record<IntrospectionMode, ModeCopy> = {
|
|
enable: {
|
|
title: 'Enable GraphQL introspection?',
|
|
confirmLabel: 'Enable introspection',
|
|
confirmLabelLoading: 'Enabling...',
|
|
persistenceBullet: (_schema) => <>This setting persists until explicitly disabled.</>,
|
|
securityBullet: (
|
|
<>
|
|
External actors will be able to introspect your schema using the <code>anon</code> key.
|
|
</>
|
|
),
|
|
},
|
|
disable: {
|
|
title: 'Disable GraphQL introspection?',
|
|
confirmLabel: 'Disable introspection',
|
|
confirmLabelLoading: 'Disabling...',
|
|
persistenceBullet: (_schema) => <>This setting persists until explicitly re-enabled.</>,
|
|
securityBullet: (
|
|
<>
|
|
External actors will no longer be able to introspect your schema via the <code>anon</code>{' '}
|
|
key. GraphiQL's docs explorer and autocomplete will stop working until introspection is
|
|
re-enabled.
|
|
</>
|
|
),
|
|
},
|
|
}
|
|
|
|
interface IntrospectionConfirmModalProps {
|
|
mode: IntrospectionMode
|
|
visible: boolean
|
|
schema: string
|
|
sql: SafeSqlFragment
|
|
otherExistingKeys: string[]
|
|
existingDirectiveIsMalformed: boolean
|
|
isPending: boolean
|
|
onCancel: () => void
|
|
onConfirm: () => void
|
|
}
|
|
|
|
export const IntrospectionConfirmModal = ({
|
|
mode,
|
|
visible,
|
|
schema,
|
|
sql,
|
|
otherExistingKeys,
|
|
existingDirectiveIsMalformed,
|
|
isPending,
|
|
onCancel,
|
|
onConfirm,
|
|
}: IntrospectionConfirmModalProps) => {
|
|
const copy = COPY[mode]
|
|
const hasPreservedOptions = otherExistingKeys.length > 0
|
|
|
|
return (
|
|
<ConfirmationModal
|
|
visible={visible}
|
|
size="large"
|
|
title={copy.title}
|
|
confirmLabel={copy.confirmLabel}
|
|
confirmLabelLoading={copy.confirmLabelLoading}
|
|
cancelLabel="Cancel"
|
|
loading={isPending}
|
|
onCancel={onCancel}
|
|
onConfirm={onConfirm}
|
|
>
|
|
<div className="space-y-4 text-sm">
|
|
<ul className="list-disc space-y-1 pl-5 text-foreground-light">
|
|
<li>{copy.persistenceBullet(schema)}</li>
|
|
<li>{copy.securityBullet}</li>
|
|
{hasPreservedOptions && (
|
|
<li>
|
|
Existing <code>@graphql(...)</code> options on this schema will be preserved:{' '}
|
|
<PreservedOptionKeys keys={otherExistingKeys} />.
|
|
</li>
|
|
)}
|
|
{existingDirectiveIsMalformed && (
|
|
<li className="text-warning">
|
|
The existing <code>@graphql(...)</code> directive on this schema could not be parsed
|
|
and will be replaced by the statement below.
|
|
</li>
|
|
)}
|
|
</ul>
|
|
|
|
<div>
|
|
<p className="text-foreground-light mb-2">The following statement will be executed:</p>
|
|
<CodeBlock language="sql" className="text-xs" hideLineNumbers>
|
|
{sql}
|
|
</CodeBlock>
|
|
</div>
|
|
</div>
|
|
</ConfirmationModal>
|
|
)
|
|
}
|
|
|
|
const PreservedOptionKeys = ({ keys }: { keys: string[] }) => (
|
|
<>
|
|
{keys.map((k, i) => (
|
|
<span key={k}>
|
|
{i > 0 && <span>{', '}</span>}
|
|
<code>{k}</code>
|
|
</span>
|
|
))}
|
|
</>
|
|
)
|