Files
supabase/apps/studio/components/interfaces/ConnectSheet/Connect.utils.ts
Saxon Fletcher 0d761b0434 Connect sheet final content (#42374)
<img width="2892" height="2342" alt="image"
src="https://github.com/user-attachments/assets/7e08929d-abc3-4397-b89d-99cc52d8190e"
/>

This is the third and final PR to complete the new connect sheet. 

First: https://github.com/supabase/supabase/pull/42367

Second: https://github.com/supabase/supabase/pull/42373

This re-adds the Direct, ORM, MCP tabs and their content, including via
connect.schema.

To test:
- Flag will be enabled on all staging projects
- Click connect and notice new Sheet
- Click all tabs and ensure content is correct

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

* **New Features**
* Multi-mode connection flow with mode selector and icons (framework,
direct DB, ORM, MCP)
* New framework/variant/library selector, richer connection guides and
install steps (Prisma, Drizzle, direct)
* MCP onboarding flows (Cursor, Codex, Claude Code) with server/auth
commands and configuration UIs

* **Refactor**
* Connect schema and state rebuilt to be mode-driven with improved step
resolution and cascading state updates

* **Tests**
* Expanded unit tests covering framework resolution, connect flows, and
mode behaviors

* **Chores**
  * ESLint ignores updated for content files
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-02-11 22:14:18 +08:00

38 lines
1.0 KiB
TypeScript

import { FRAMEWORKS, MOBILES } from './Connect.constants'
type FieldValue = string | boolean | string[] | undefined
interface FrameworkLibraryInput {
framework?: FieldValue
frameworkVariant?: FieldValue
library?: FieldValue
[key: string]: FieldValue
}
export function resolveFrameworkLibraryKey(state: FrameworkLibraryInput): string | null {
const { framework, frameworkVariant, library } = state
if (!framework) return null
if (library) return String(library)
const allFrameworks = [...FRAMEWORKS, ...MOBILES]
const selectedFramework = allFrameworks.find((f) => f.key === framework)
if (!selectedFramework?.children?.length) return null
if (frameworkVariant) {
const variant = selectedFramework.children.find((c) => c.key === frameworkVariant)
if (variant?.children?.length) {
return variant.children[0].key
}
}
const firstChild = selectedFramework.children[0]
if (firstChild?.children?.length) {
return firstChild.children[0].key
}
return firstChild?.key ?? null
}