mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
Stacked PR 2/5 for page title improvements. Includes Auth, Database, editors, and Edge Functions layout title adoption. _Base: [dnywh/feat/page-titles](https://github.com/supabase/supabase/pull/43538)_ --- ## What kind of change does this PR introduce? - Resolves FE-1960 - Resolves FE-1983 - Resolves DEPR-207 ## What is the current behavior? Page titles between surfaces are inconsistent and vague. Sometimes they say the product name: ``` My Project | My Org | Supabase ``` ...even when on a specific surface like Database > Tables. Other times they show the entity name but skip over the project or org name : ``` Edge Functions | Supabase ``` ## What is the new behavior? Auth, Database, editors, and Edge Functions adopt the layout title format introduced in https://github.com/supabase/supabase/pull/43538: ``` users | Table Editor | My Project | My Org | Supabase hello-world | Logs | Edge Functions | My Project | My Org | Supabase Backups | Database | My Project | My Org | Supabase Authentication | My Project | My Org | Supabase ``` That format is: entity, section, surface, project, org, brand ## Additional context Related stacked PRs also based on the the original [dnywh/feat/page-titles](https://github.com/supabase/supabase/pull/43538) branch: - https://github.com/supabase/supabase/pull/43535 - https://github.com/supabase/supabase/pull/43536 - https://github.com/supabase/supabase/pull/43537 --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import { useParams } from 'common'
|
|
import { usePathname } from 'next/navigation'
|
|
import { ComponentProps, ReactNode } from 'react'
|
|
import { useTabsStateSnapshot } from 'state/tabs'
|
|
import { cn } from 'ui'
|
|
|
|
import { ProjectLayoutWithAuth } from '../ProjectLayout'
|
|
import { CollapseButton } from '../Tabs/CollapseButton'
|
|
import { EditorTabs } from '../Tabs/Tabs'
|
|
import { useEditorType } from './EditorsLayout.hooks'
|
|
|
|
export interface ExplorerLayoutProps extends ComponentProps<typeof ProjectLayoutWithAuth> {
|
|
children: ReactNode
|
|
title?: string
|
|
product?: string
|
|
productMenuClassName?: string
|
|
}
|
|
|
|
export const EditorBaseLayout = ({
|
|
children,
|
|
title,
|
|
product,
|
|
productMenuClassName,
|
|
productMenu,
|
|
browserTitle,
|
|
}: ExplorerLayoutProps) => {
|
|
const { ref } = useParams()
|
|
const pathname = usePathname()
|
|
const editor = useEditorType()
|
|
const tabs = useTabsStateSnapshot()
|
|
|
|
const hasNoOpenTabs =
|
|
editor === 'table' ? tabs.openTabs.filter((x) => !x.startsWith('sql')).length === 0 : false
|
|
const hideTabs =
|
|
pathname === `/project/${ref}/editor` || pathname === `/project/${ref}/sql` || hasNoOpenTabs
|
|
|
|
const activeEditorTab = tabs.activeTab ? tabs.tabsMap[tabs.activeTab] : undefined
|
|
const activeEditorTabEntity =
|
|
activeEditorTab === undefined
|
|
? undefined
|
|
: editor === 'sql'
|
|
? activeEditorTab.type === 'sql'
|
|
? activeEditorTab.metadata?.name || activeEditorTab.label
|
|
: undefined
|
|
: editor === 'table'
|
|
? activeEditorTab.type !== 'sql'
|
|
? activeEditorTab.metadata?.name || activeEditorTab.label
|
|
: undefined
|
|
: undefined
|
|
|
|
const mergedBrowserTitle = {
|
|
...browserTitle,
|
|
entity: browserTitle?.entity ?? activeEditorTabEntity,
|
|
}
|
|
|
|
return (
|
|
<ProjectLayoutWithAuth
|
|
resizableSidebar
|
|
title={title}
|
|
product={product}
|
|
browserTitle={mergedBrowserTitle}
|
|
productMenuClassName={productMenuClassName}
|
|
productMenu={productMenu}
|
|
>
|
|
<div className="flex flex-col h-full">
|
|
<div
|
|
className={cn(
|
|
'h-10 md:min-h-[var(--header-height)] flex items-center',
|
|
!hideTabs ? 'bg-surface-200 dark:bg-alternative' : 'bg-surface-100'
|
|
)}
|
|
>
|
|
{hideTabs ? <CollapseButton hideTabs={hideTabs} /> : <EditorTabs />}
|
|
</div>
|
|
<div className="h-full">{children}</div>
|
|
</div>
|
|
</ProjectLayoutWithAuth>
|
|
)
|
|
}
|