mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
- add new [OrgSelector](https://github.com/supabase/supabase/pull/43238/changes#diff-214b339101a9c06864ea2755ac7246eb4c971ce74c5d3169b1385a28ee1d4227) and [ProjectBranchSelector](https://github.com/supabase/supabase/pull/43238/changes#diff-82d25c128c306b61bea7481026f58f670a229874f23ca3a1a1d78ddeabde21e0) components to the mobile navigation, replacing the previous which took up a lot of horizontal space - org/project/branch dropdowns now open up in the bottom MobileSheetNav for a better mobile ux - desktop nav remains unchanged
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { Branch } from 'data/branches/branches-query'
|
|
import type { Organization } from 'types'
|
|
|
|
export interface ProjectBranchSelectorState {
|
|
selectedBranch: Branch | undefined
|
|
isMainBranch: boolean
|
|
branchDisplayName: string
|
|
selectedOrgInitial: string
|
|
organizationHref: string
|
|
}
|
|
|
|
export function getProjectBranchSelectorState(params: {
|
|
selectedBranch: Branch | undefined
|
|
isBranchingEnabled: boolean
|
|
selectedOrganization: Organization | undefined
|
|
}): ProjectBranchSelectorState {
|
|
const { selectedBranch, isBranchingEnabled, selectedOrganization } = params
|
|
|
|
const isMainBranch = !isBranchingEnabled || selectedBranch?.is_default === true
|
|
const branchDisplayName = isBranchingEnabled ? selectedBranch?.name ?? 'main' : 'main'
|
|
const selectedOrgInitial = selectedOrganization?.name?.trim().charAt(0).toUpperCase() ?? 'O'
|
|
const organizationHref = selectedOrganization?.slug
|
|
? `/org/${selectedOrganization.slug}`
|
|
: '/organizations'
|
|
|
|
return {
|
|
selectedBranch,
|
|
isMainBranch,
|
|
branchDisplayName,
|
|
selectedOrgInitial,
|
|
organizationHref,
|
|
}
|
|
}
|