Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix mobile nav menu for org nav layout (#34990)

Joshen Limf7fbd6a4ca4a
diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx
index 4e9e176a5d7..522ad536a2d 100644
--- a/apps/studio/components/interfaces/Sidebar.tsx
+++ b/apps/studio/components/interfaces/Sidebar.tsx
@@ -1,9 +1,17 @@
import { AnimatePresence, motion, MotionProps } from 'framer-motion'
import { isUndefined } from 'lodash'
-import { Blocks, Boxes, ChartArea, PanelLeftDashed, Settings, Users } from 'lucide-react'
+import {
+ ArrowUpRight,
+ Blocks,
+ Boxes,
+ ChartArea,
+ PanelLeftDashed,
+ Settings,
+ Users,
+} from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import { ComponentProps, ComponentPropsWithoutRef, FC, useEffect } from 'react'
+import { ComponentProps, ComponentPropsWithoutRef, FC, ReactNode, useEffect } from 'react'
import { useParams } from 'common'
import {
@@ -13,6 +21,7 @@ import {
generateToolRoutes,
} from 'components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { ProjectIndexPageLink } from 'data/prefetchers/project.$ref'
import { useHideSidebar } from 'hooks/misc/useHideSidebar'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
@@ -36,13 +45,14 @@ import {
SidebarContent as SidebarContentPrimitive,
SidebarFooter,
SidebarGroup,
+ SidebarGroupLabel,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
Sidebar as SidebarPrimitive,
+ SidebarSeparator,
useSidebar,
} from 'ui'
-import { useSetCommandMenuOpen } from 'ui-patterns'
import {
useIsAPIDocsSidePanelEnabled,
useIsSQLEditorTabsEnabled,
@@ -139,8 +149,8 @@ export const Sidebar = ({ className, ...props }: SidebarProps) => {
)
}
-export function SidebarContent({ footer }: { footer?: React.ReactNode }) {
- const setCommandMenuOpen = useSetCommandMenuOpen()
+export const SidebarContent = ({ footer }: { footer?: ReactNode }) => {
+ const newLayoutPreview = useNewLayout()
const { ref: projectRef } = useParams()
// temporary logic to show settings route in sidebar footer
@@ -167,7 +177,7 @@ export function SidebarContent({ footer }: { footer?: React.ReactNode }) {
exit={{ opacity: 0, y: -20 }}
transition={{ duration: 0.2, ease: 'easeOut' }}
>
- <OrganizationLinks />
+ {newLayoutPreview ? <OrganizationLinks /> : <HomePageLinks />}
</motion.div>
)}
</SidebarContentPrimitive>
@@ -239,7 +249,7 @@ const ActiveDot = (errorArray: any[], warningArray: any[]) => {
)
}
-function ProjectLinks() {
+const ProjectLinks = () => {
const router = useRouter()
const { ref } = useParams()
const { project } = useProjectContext()
@@ -372,6 +382,78 @@ function ProjectLinks() {
)
}
+const HomePageLinks = () => {
+ const { data: organizations = [] } = useOrganizationsQuery()
+ const organizationLinks = organizations.map((org) => {
+ return { label: org.name, href: `/org/${org.slug}/general`, key: org.slug }
+ })
+ const accountLinks = [
+ { label: 'Preferences', href: `/account/me`, key: 'preferences' },
+ { label: 'Access Tokens', href: `/account/tokens`, key: 'account-tokens' },
+ { label: 'Security', href: `/account/security`, key: 'security' },
+ { label: 'Audit Logs', href: `/account/audit`, key: 'audit-logs' },
+ ]
+ const docsLinks = [
+ { label: 'Guides', href: `https://supabase.com/docs`, key: 'guides', icon: <ArrowUpRight /> },
+ {
+ label: 'API Reference',
+ href: `https://supabase.com/docs/guides/api`,
+ key: 'api-reference',
+ icon: <ArrowUpRight />,
+ },
+ ]
+
+ return (
+ <SidebarMenu className="flex flex-col gap-y-1 items-start">
+ <SidebarGroupLabel className="px-4 h-auto pt-4">Organizations</SidebarGroupLabel>
+ <SidebarGroup className="gap-0.5">
+ {organizationLinks.map((x) => (
+ <SideBarNavLink
+ key={x.key}
+ active={false}
+ route={{
+ label: x.label,
+ link: x.href,
+ key: x.label,
+ }}
+ />
+ ))}
+ </SidebarGroup>
+ <SidebarSeparator className="!bg-border-overlay w-full mx-0" />
+ <SidebarGroupLabel className="px-4 h-auto pt-4">Account</SidebarGroupLabel>
+ <SidebarGroup className="gap-0.5">
+ {accountLinks.map((x) => (
+ <SideBarNavLink
+ key={x.key}
+ active={false}
+ route={{
+ label: x.label,
+ link: x.href,
+ key: x.label,
+ }}
+ />
+ ))}
+ </SidebarGroup>
+ <SidebarSeparator className="!bg-border-overlay w-full mx-0" />
+ <SidebarGroupLabel className="px-4 h-auto pt-4">Documentation</SidebarGroupLabel>
+ <SidebarGroup className="gap-0.5">
+ {docsLinks.map((x) => (
+ <SideBarNavLink
+ key={x.key}
+ active={false}
+ route={{
+ label: x.label,
+ link: x.href,
+ key: x.label,
+ icon: x.icon,
+ }}
+ />
+ ))}
+ </SidebarGroup>
+ </SidebarMenu>
+ )
+}
+
const OrganizationLinks = () => {
const router = useRouter()
const { slug } = useParams()
@@ -382,7 +464,7 @@ const OrganizationLinks = () => {
{
label: 'Projects',
href: `/org/${slug}`,
- key: '',
+ key: 'projects',
icon: <Boxes size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
},
{
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
index a9cfcceffff..5baee3d8823 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
@@ -101,25 +101,9 @@ const LayoutHeader = ({
<header className={cn('flex h-12 items-center flex-shrink-0 border-b')}>
<div
className={cn(
- 'flex items-center justify-between h-full pr-3 flex-1 overflow-x-auto gap-x-4 md:pl-4'
+ 'flex items-center justify-between h-full pr-3 flex-1 overflow-x-auto gap-x-8 pl-4'
)}
>
- {showProductMenu && (
- <div className="flex items-center justify-center border-r flex-0 md:hidden h-full aspect-square">
- <button
- title="Menu dropdown button"
- className={cn(
- 'group/view-toggle flex justify-center items-center border-none gap-1 !bg-transparent rounded-md min-w-[30px] w-[30px] h-[30px]'
- )}
- onClick={() => setMobileMenuOpen(true)}
- >
- <div className="flex flex-col gap-y-1">
- <div className="h-px inline-block left-0 w-4 transition-all ease-out bg-foreground-lighter group-hover/view-toggle:bg-foreground p-0 m-0" />
- <div className="h-px inline-block left-0 w-3 transition-all ease-out bg-foreground-lighter group-hover/view-toggle:bg-foreground p-0 m-0" />
- </div>
- </button>
- </div>
- )}
<div className="flex items-center text-sm">
<HomeIcon />
<>
@@ -232,10 +216,10 @@ const LayoutHeader = ({
exit={{ opacity: 0, x: 0, width: 0 }}
transition={{ duration: 0.15, ease: 'easeOut' }}
>
- <div className="border-r h-full flex items-center justify-center md:px-2">
+ <div className="border-r h-full flex items-center justify-center px-2">
<InlineEditorButton />
</div>
- <div className="md:px-2">
+ <div className="px-2">
<AssistantButton />
</div>
</motion.div>