Files
supabase/apps/studio/components/interfaces/Integrations/GraphQL/IntrospectionEnabledNotice.tsx
Gildas Garcia 96d43099bb chore: refactor Button API so that it can be used a standard button (#46880)
## Problem

Our `<Button>` component breaks the default `button` contract by
redefining the `type` prop to set its variant (`primary`, `default`,
etc) instead of the button type (`submit`, `button`, etc).
This is confusing and forces to write more code when using it with
shadcn components that expect/inject the standard button props.

## Solution

- rename the `type` prop to `variant`
- rename the `htmlType` prop to `type`
- propagate the changes where necessary
- format code

## How to test

As this is just prop renaming, if it builds it's ok

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-06-16 23:59:58 +02:00

55 lines
1.6 KiB
TypeScript

import { useState } from 'react'
import { Button } from 'ui'
import { IntrospectionConfirmModal } from './IntrospectionConfirmModal'
import { useSetIntrospection } from './useSetIntrospection'
interface IntrospectionEnabledNoticeProps {
schema: string
currentSchemaComment: string | null | undefined
onDisabled: () => void
}
export const IntrospectionEnabledNotice = ({
schema,
currentSchemaComment,
onDisabled,
}: IntrospectionEnabledNoticeProps) => {
const [showConfirm, setShowConfirm] = useState(false)
const { apply, isPending, sql, existingDirectiveIsMalformed, otherExistingKeys } =
useSetIntrospection({
schema,
currentSchemaComment,
enabled: false,
onMutationSuccess: () => setShowConfirm(false),
onInvalidated: onDisabled,
})
return (
<>
<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 enabled for this project, so schemas are discoverable through the
API.
</span>
<Button variant="default" size="tiny" onClick={() => setShowConfirm(true)}>
Disable introspection
</Button>
</div>
<IntrospectionConfirmModal
mode="disable"
visible={showConfirm}
schema={schema}
sql={sql}
otherExistingKeys={otherExistingKeys}
existingDirectiveIsMalformed={existingDirectiveIsMalformed}
isPending={isPending}
onCancel={() => setShowConfirm(false)}
onConfirm={apply}
/>
</>
)
}