mirror of
https://github.com/supabase/supabase.git
synced 2026-06-28 19:39:19 -04:00
96d43099bb
## 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>
55 lines
1.6 KiB
TypeScript
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}
|
|
/>
|
|
</>
|
|
)
|
|
}
|