mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Context
Just some housekeeping here while going through the repo, realised that
there's dead code in `ProjectBranchSwitcher`
## Changes involved:
- `ProjectBranchSelector` is only rendered by `MobileNavigationBar`,
which `DefaultLayout` only mounts when `useBreakpoint('md')` is true.
The selector's own `isMobile` check used the same breakpoint, so its
desktop `Popover` branch could never run.
- The name `ProjectBranchSelector` is also misleading since the sheet
switches more than just the project's branch + it's mobile-only, so
opting to rename it to `MobileProjectSwitcher` instead
- Also fix org rows in the sheet being tighter than project rows.
`compactPadding` was inverted, so the embedded list got `p-0.5` on the
item and lost the default `px-2 py-1.5`
- Align buttons in `ProjectBranchSelector` across all tabs + use outline
variant for secondary action
| Previous | Updated |
|---|---|
| <img width="352" height="174" alt="image"
src="https://github.com/user-attachments/assets/24cb2985-b568-4bc1-8f53-ab3914ef0804"
/> | <img width="351" height="161" alt="image"
src="https://github.com/user-attachments/assets/e6e9b0e9-c075-4235-93ca-80c5d070c287"
/> |
| <img width="336" height="248" alt="image"
src="https://github.com/user-attachments/assets/4071b73f-f741-4598-ba01-8dc7bb6ba57a"
/> | <img width="335" height="313" alt="image"
src="https://github.com/user-attachments/assets/2bea398d-ebe9-4641-9bfe-c4a7b6b10c51"
/> |
If you meant a different table, tell me what the two columns should be.
For example, file and change, or before and after behaviour.
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 MobileProjectSwitcherState {
|
|
selectedBranch: Branch | undefined
|
|
isMainBranch: boolean
|
|
branchDisplayName: string
|
|
selectedOrgInitial: string
|
|
organizationHref: string
|
|
}
|
|
|
|
export function getMobileProjectSwitcherState(params: {
|
|
selectedBranch: Branch | undefined
|
|
isBranchingEnabled: boolean
|
|
selectedOrganization: Organization | undefined
|
|
}): MobileProjectSwitcherState {
|
|
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,
|
|
}
|
|
}
|