mirror of
https://github.com/supabase/supabase.git
synced 2026-09-09 11:30:17 +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>
170 lines
6.0 KiB
TypeScript
170 lines
6.0 KiB
TypeScript
import { useParams } from 'common'
|
|
import { UseFormReturn } from 'react-hook-form'
|
|
import {
|
|
Checkbox,
|
|
cn,
|
|
FormControl,
|
|
FormDescription,
|
|
FormField,
|
|
FormItem,
|
|
FormLabel,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
useWatch,
|
|
} from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
|
|
|
|
import { CreateProjectForm } from './ProjectCreation.schema'
|
|
import { InlineLink } from '@/components/ui/InlineLink'
|
|
import Panel from '@/components/ui/Panel'
|
|
import { useTrackDefaultPrivilegesExposure } from '@/hooks/misc/useDataApiRevokeOnCreateDefault'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
interface SecurityOptionsProps {
|
|
form: UseFormReturn<CreateProjectForm>
|
|
layout?: 'vertical' | 'horizontal'
|
|
surface: 'main' | 'vercel'
|
|
}
|
|
|
|
export const SecurityOptions = ({ form, layout = 'horizontal', surface }: SecurityOptionsProps) => {
|
|
const { slug } = useParams()
|
|
const dataApi = useWatch({ control: form.control, name: 'dataApi' })
|
|
const dataApiDefaultPrivileges = useWatch({
|
|
control: form.control,
|
|
name: 'dataApiDefaultPrivileges',
|
|
})
|
|
const hasUserModified = form.getFieldState('dataApiDefaultPrivileges', form.formState).isDirty
|
|
|
|
useTrackDefaultPrivilegesExposure(
|
|
surface === 'main'
|
|
? {
|
|
surface: 'main',
|
|
dataApiDefaultPrivileges: dataApiDefaultPrivileges ?? true,
|
|
hasUserModified,
|
|
}
|
|
: {
|
|
surface: 'vercel',
|
|
orgSlug: slug,
|
|
dataApiDefaultPrivileges: dataApiDefaultPrivileges ?? true,
|
|
hasUserModified,
|
|
}
|
|
)
|
|
|
|
return (
|
|
<Panel.Content className="pb-8">
|
|
<FormItemLayout layout={layout} label="Security" isReactForm={false}>
|
|
<div className="flex flex-col gap-4">
|
|
<FormField
|
|
name="dataApi"
|
|
control={form.control}
|
|
render={({ field }) => (
|
|
<FormItem className="flex items-start gap-3">
|
|
<FormControl>
|
|
<Checkbox
|
|
checked={field.value}
|
|
disabled={field.disabled}
|
|
onCheckedChange={(value) => field.onChange(value === true)}
|
|
/>
|
|
</FormControl>
|
|
<div className="space-y-1">
|
|
<FormLabel className="text-sm text-foreground">Enable Data API</FormLabel>
|
|
<FormDescription className="text-foreground-lighter">
|
|
Autogenerate a RESTful API for your public schema. Recommended if using a client
|
|
library like{' '}
|
|
<InlineLink href={`${DOCS_URL}/reference/javascript/introduction`}>
|
|
supabase-js
|
|
</InlineLink>
|
|
.
|
|
</FormDescription>
|
|
</div>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
name="dataApiDefaultPrivileges"
|
|
control={form.control}
|
|
render={({ field }) => (
|
|
<FormItem
|
|
className={cn(
|
|
'flex items-start gap-3',
|
|
!dataApi && 'opacity-50 cursor-not-allowed'
|
|
)}
|
|
>
|
|
<FormControl>
|
|
{dataApi ? (
|
|
<Checkbox
|
|
checked={field.value}
|
|
disabled={field.disabled}
|
|
onCheckedChange={(value) => field.onChange(value === true)}
|
|
/>
|
|
) : (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="cursor-not-allowed">
|
|
<Checkbox checked={field.value} disabled />
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top">
|
|
Enable the Data API to configure default privileges.
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
</FormControl>
|
|
<div className="space-y-1">
|
|
<FormLabel
|
|
className={cn('text-sm text-foreground', !dataApi && 'text-foreground-muted')}
|
|
>
|
|
Automatically expose new tables
|
|
</FormLabel>
|
|
<FormDescription className="text-foreground-lighter">
|
|
Grants privileges to Data API roles by default, exposing new tables.
|
|
<br />
|
|
<strong className="font-medium text-foreground-light">
|
|
We recommend disabling this to control access manually.
|
|
</strong>
|
|
</FormDescription>
|
|
</div>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
name="enableRlsEventTrigger"
|
|
control={form.control}
|
|
render={({ field }) => (
|
|
<FormItem className="flex items-start gap-3">
|
|
<FormControl>
|
|
<Checkbox
|
|
checked={field.value}
|
|
disabled={field.disabled}
|
|
onCheckedChange={(value) => field.onChange(value === true)}
|
|
/>
|
|
</FormControl>
|
|
<div className="space-y-1">
|
|
<FormLabel className="text-sm text-foreground">Enable automatic RLS</FormLabel>
|
|
<FormDescription className="text-foreground-lighter">
|
|
Create an event trigger that automatically enables Row Level Security on all new
|
|
tables in the public schema.
|
|
</FormDescription>
|
|
</div>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
|
|
{!dataApi && (
|
|
<Admonition
|
|
type="warning"
|
|
title="Client libraries need Data API to query your database"
|
|
>
|
|
Disabling it means supabase-js and similar libraries can't query or mutate data.
|
|
</Admonition>
|
|
)}
|
|
</div>
|
|
</FormItemLayout>
|
|
</Panel.Content>
|
|
)
|
|
}
|