Files
supabase/apps/studio/components/interfaces/ProjectCreation/InternalOnlyConfiguration.tsx
T
55ee3e0f2c feat(ui-patterns): add CollapsibleCardSection component (#46250)
## What kind of change does this PR introduce?

New shared component + docs.

## What is the current behavior?

`AdvancedConfiguration` and `InternalOnlyConfiguration` in the New
Project form each contain bespoke `<Collapsible>` markup. There's no
reusable collapsible section component available to other card/panel
forms.

## What is the new behavior?

- Extracts a shared `CollapsibleCardSection` into
`packages/ui-patterns`, exported via
`ui-patterns/CollapsibleCardSection`
- Refactors `AdvancedConfiguration` and `InternalOnlyConfiguration` to
use it
- Adds design system docs with a live demo at
`/docs/fragments/collapsible-card-section`

This is a prereq for #45707 and #46187, which both consume this
component.

| Example Usage |
| --- |
| <img width="1464" height="500" alt="CleanShot 2026-05-22 at 15 20
38@2x"
src="https://github.com/user-attachments/assets/5b88ef8d-3f9a-4454-b246-5bbaf53e027a"
/> |

## To test

- [ ] Check that [the Design System
page](https://design-system-git-dnywh-collapsible-card-section-supabase.vercel.app/design-system/docs/fragments/collapsible-card-section)
makes sense
- [ ] Check that the [new project
form](https://studio-staging-git-dnywh-collapsible-card-section-supabase.vercel.app/dashboard/new/)
collapsible sections work as expected

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Introduced CollapsibleCardSection component as a reusable UI pattern
for collapsible card-based content with customizable title, description,
and open state.
* Refactored project configuration interfaces to use the new component
for improved visual consistency.

* **Documentation**
* Added comprehensive documentation with interactive examples and
multiple usage patterns for CollapsibleCardSection.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46250?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-05-22 18:24:17 +10:00

95 lines
3.6 KiB
TypeScript

import { useParams } from 'common'
import { UseFormReturn } from 'react-hook-form'
import { type CloudProvider } from 'shared-data'
import { Card, CardContent, FormControl, FormField, Input } from 'ui'
import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { CloudProviderSelector } from './CloudProviderSelector'
import { HighAvailabilityInput } from './HighAvailabilityInput'
import { PostgresVersionSelector } from './PostgresVersionSelector'
import { CreateProjectForm } from './ProjectCreation.schema'
interface InternalOnlyConfigurationProps {
form: UseFormReturn<CreateProjectForm>
}
export const InternalOnlyConfiguration = ({ form }: InternalOnlyConfigurationProps) => {
const { slug } = useParams()
const showNonProdFields = process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'
return (
<Card className="border-0 border-b rounded-none">
<CardContent>
<CollapsibleCardSection
title="Internal-only Configuration"
description="These settings are only visible to internal staff"
>
<div className="flex flex-col gap-y-6">
<div className="flex flex-col gap-y-4">
<FormField
control={form.control}
name="postgresVersionSelection"
render={({ field }) => (
<PostgresVersionSelector
field={field}
form={form}
cloudProvider={form.getValues('cloudProvider') as CloudProvider}
organizationSlug={slug}
dbRegion={form.getValues('dbRegion')}
/>
)}
/>
<HighAvailabilityInput form={form} />
</div>
{showNonProdFields && (
<div>
<p className="text-xs text-foreground-lighter mb-6">
The settings below are only applicable for local/staging projects
</p>
<div className="flex flex-col gap-y-4">
<CloudProviderSelector form={form} />
<FormField
control={form.control}
name="postgresVersion"
render={({ field }) => (
<FormItemLayout
label="Custom Postgres version"
layout="horizontal"
description="Specify a custom version of Postgres (defaults to the latest)."
>
<FormControl>
<Input placeholder="e.g 17.6.1.104" {...field} autoComplete="off" />
</FormControl>
</FormItemLayout>
)}
/>
<FormField
control={form.control}
name="instanceType"
render={({ field }) => (
<FormItemLayout
label="Custom instance type"
layout="horizontal"
description="Specify a custom instance type."
>
<FormControl>
<Input placeholder="e.g t3.nano" {...field} autoComplete="off" />
</FormControl>
</FormItemLayout>
)}
/>
</div>
</div>
)}
</div>
</CollapsibleCardSection>
</CardContent>
</Card>
)
}