mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 02:45:07 +03:00
## What kind of change does this PR introduce? Refactor, cleanup, and docs update. ## What is the current behavior? After the page-title rollout, `ProjectLayout` is still in a transitional state: - it accepts a deprecated `title` prop - it still supports a separate `browserTitle.surface` - wrapper layouts are split between passing `title` directly and passing `browserTitle.section` That makes the API harder to reason about than it needs to be, even though the rendered titles are already correct. ## What is the new behavior? This cleanup finishes the API simplification that came out of the stacked PR review: - wrapper layouts stay `title`-first for DX - `ProjectLayout` no longer accepts `title` - `product` is now the single source of truth for the project-surface title segment - `browserTitle` is now only used for extra browser-title metadata (`entity`, `section`, `override`) - the remaining project-scoped callers now pass `browserTitle.section` when they need a section label - docs now reflect the final pattern instead of the transitional one Rendered page titles stay the same. ## Additional context Checks run: - `pnpm --filter studio exec vitest --run lib/page-title.test.ts components/layouts/ProjectLayout/index.test.tsx` - `pnpm --filter studio typecheck` - `pnpm exec prettier --check ...` on touched files This is intended as the post-rollout cleanup PR based on Joshen's review feedback across the stacked title changes. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { ProductMenu } from 'components/ui/ProductMenu'
|
|
import { withAuth } from 'hooks/misc/withAuth'
|
|
import { useRouter } from 'next/router'
|
|
import type { PropsWithChildren } from 'react'
|
|
|
|
import { ProjectLayout } from '../ProjectLayout'
|
|
import { useGenerateSettingsMenu } from './SettingsMenu.utils'
|
|
|
|
/**
|
|
* Menu-only component for the settings section. Used by the desktop sidebar and by the
|
|
* mobile sheet submenu. Must not wrap ProjectLayout so that opening the settings submenu
|
|
* in the mobile sheet does not overwrite registerOpenMenu and break the menu button.
|
|
*/
|
|
export const SettingsProductMenu = () => {
|
|
const router = useRouter()
|
|
|
|
const page = router.pathname.includes('billing')
|
|
? router.pathname.split('/')[5]
|
|
: router.pathname.split('/')[4]
|
|
|
|
const menu = useGenerateSettingsMenu()
|
|
|
|
return <ProductMenu page={page} menu={menu} />
|
|
}
|
|
|
|
interface SettingsLayoutProps {
|
|
title: string
|
|
}
|
|
|
|
export const SettingsLayout = ({ title, children }: PropsWithChildren<SettingsLayoutProps>) => {
|
|
return (
|
|
<ProjectLayout
|
|
isBlocking={false}
|
|
product="Settings"
|
|
browserTitle={{ section: title }}
|
|
productMenu={<SettingsProductMenu />}
|
|
>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(SettingsLayout)
|