mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context Some minor UI issues that I found while reviewing another PR - Fix `NoProjectsOnPaidOrgInfo` prematurely showing while project details is still loading <img width="1249" height="376" alt="image" src="https://github.com/user-attachments/assets/3f41f4a3-849f-4685-bcc4-6fed3b433042" /> - Fix padding alignment for Organization details form group <img width="1115" height="282" alt="image" src="https://github.com/user-attachments/assets/c0865614-208c-4335-87d3-176c4411b6a4" /> - Fix projects list on `/org/[slug]` showing stale projects while switching orgs - just removed `keepPreviousData` so that the card loaders shows up - Fix organization settings in sidebar menu not showing active state while on certain settings pages like audit-log-drains, webhooks, etc
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import type { ReactNode } from 'react'
|
|
|
|
import { ORG_SETTINGS_ROUTES } from '@/components/layouts/OrganizationLayout/OrganizationLayout.utils'
|
|
|
|
export interface OrgNavItem {
|
|
label: string
|
|
href: string
|
|
key: string
|
|
icon: ReactNode
|
|
}
|
|
|
|
export function getOrgActiveRoute(pathname: string): string | undefined {
|
|
const segments = pathname.split('/').filter(Boolean)
|
|
const orgIndex = segments.indexOf('org')
|
|
if (orgIndex === -1 || segments.length <= orgIndex + 1) return undefined
|
|
return segments[orgIndex + 2]
|
|
}
|
|
|
|
export function getOrgSectionKeyFromPathname(activeRoute: string | undefined): string | null {
|
|
if (activeRoute && ORG_SETTINGS_ROUTES.includes(activeRoute)) {
|
|
return 'settings'
|
|
}
|
|
return null
|
|
}
|
|
|
|
export function isOrgMenuActive(
|
|
item: OrgNavItem,
|
|
index: number,
|
|
pathname: string,
|
|
activeRoute: string | undefined
|
|
): boolean {
|
|
if (index === 0) {
|
|
return activeRoute === undefined
|
|
}
|
|
if (item.key === 'settings') {
|
|
const route = activeRoute ?? getOrgActiveRoute(pathname)
|
|
if (route === undefined) return false
|
|
return route === 'settings' || ORG_SETTINGS_ROUTES.includes(route)
|
|
}
|
|
return activeRoute === item.key
|
|
}
|