mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
## Context There's 2 areas of the dashboard that has the project creation flow - and this PR consolidates both to use the same UI components to minimise duplication + keep things consistent ### Before <img width="1920" height="957" alt="image" src="https://github.com/user-attachments/assets/2a7ab79d-71c7-43f2-925b-1e1666cc3a69" /> ### After <img width="1389" height="957" alt="image" src="https://github.com/user-attachments/assets/f8465568-af99-46eb-80ee-7ac345383231" /> ## Changes involved - What this means for the project creation flow for Vercel Integration: - Smart region can be selected - Compute size can be selected - Enable Data API can be checked - Automatic RLS enable can be checked - How it differs from the main project creation flow on `new/slug` - Organization selection is disabled (cannot be changed) - The following UI is hidden: - "Internal configuration" section - "GitHub repository" field - "Free project info" at the bottom - "Cancel" button Eventually we could looking into reducing the differences more, e.g having data seeding for both ways, and showing GitHub repository field for Vercel integration Resolves DEPR-616 Resolves FE-3905 ## To test Tbh, I'm not really sure how you'd be able to test the vercel integration locally or on staging, this seemingly can only be done when changes land on prod. - What I'd do however is to just test the project creation flow minimally by landing on `/integrations/vercel/_/deploy-button/new-project` - Project creation can work, but just not the connection creation part - And also test project creation on `/new/slug` as well <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit * **New Features** * Added “Create sample tables with seed data” during project creation. * Enhanced Vercel integration setup with a guided creation flow and post-creation connection step. * Added an option to disable organization selection in specialized flows. * Added support for triggering a callback after successful project creation. * Added support for hiding the Cancel button in specialized flows. * **UI Improvements** * Refined the connected GitHub repository selector button/dropdown visuals. * Improved security options behavior for different project creation contexts. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
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>
|
|
)
|
|
}
|