Skip to content

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

Optimize UI when redirecting from /projects

Joshen Lime46bb132f302
diff --git a/studio/components/layouts/AccountLayout/AccountLayout.tsx b/studio/components/layouts/AccountLayout/AccountLayout.tsx
index ae83fbece97..7efdbaa5e11 100644
--- a/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -127,7 +127,7 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
: []),
]
- if (navLayoutV2 && router.pathname !== '/projects') {
+ if (navLayoutV2) {
return <SettingsLayout>{children}</SettingsLayout>
}
@@ -142,7 +142,12 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
style={{ height: maxHeight, maxHeight }}
className="flex flex-col flex-1 w-full overflow-y-auto"
>
- <WithSidebar title={title} breadcrumbs={breadcrumbs} sections={sectionsWithHeaders}>
+ <WithSidebar
+ hideSidebar={navLayoutV2}
+ title={title}
+ breadcrumbs={breadcrumbs}
+ sections={sectionsWithHeaders}
+ >
{children}
</WithSidebar>
</main>
diff --git a/studio/components/layouts/AccountLayout/WithSidebar.tsx b/studio/components/layouts/AccountLayout/WithSidebar.tsx
index 4413ab6a3cb..cdf48e39a65 100644
--- a/studio/components/layouts/AccountLayout/WithSidebar.tsx
+++ b/studio/components/layouts/AccountLayout/WithSidebar.tsx
@@ -1,12 +1,12 @@
+import { useFlag } from 'hooks'
+import { isUndefined } from 'lodash'
import Link from 'next/link'
import { FC, ReactNode } from 'react'
-import { isUndefined } from 'lodash'
-import { Menu, IconArrowUpRight, Badge, IconLogOut } from 'ui'
-import { useFlag } from 'hooks'
+import { Badge, IconArrowUpRight, IconLogOut, Menu } from 'ui'
import LayoutHeader from '../ProjectLayout/LayoutHeader'
import { SidebarLink, SidebarSection } from './AccountLayout.types'
-interface Props {
+interface WithSidebarProps {
title: string
breadcrumbs: any[]
sections: SidebarSection[]
@@ -27,7 +27,7 @@ The information hierarchy for WithSidebar is:
SidebarItem
SidebarLink
*/
-const WithSidebar: FC<Props> = ({
+const WithSidebar = ({
title,
header,
breadcrumbs = [],
@@ -37,9 +37,10 @@ const WithSidebar: FC<Props> = ({
subitemsParentKey,
hideSidebar = false,
customSidebarContent,
-}) => {
+}: WithSidebarProps) => {
const noContent = !sections && !customSidebarContent
const ongoingIncident = useFlag('ongoingIncident')
+ const navLayoutV2 = useFlag('navigationLayoutV2')
const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh'
return (
@@ -89,7 +90,7 @@ const WithSidebar: FC<Props> = ({
</div>
)}
<div className="flex flex-1 flex-col">
- <LayoutHeader breadcrumbs={breadcrumbs} />
+ {!navLayoutV2 && <LayoutHeader breadcrumbs={breadcrumbs} />}
<div className="flex-1 flex-grow overflow-auto">{children}</div>
</div>
</div>
diff --git a/studio/components/layouts/AppLayout/AppLayout.tsx b/studio/components/layouts/AppLayout/AppLayout.tsx
index 7cefb9a6453..5abf9b3a826 100644
--- a/studio/components/layouts/AppLayout/AppLayout.tsx
+++ b/studio/components/layouts/AppLayout/AppLayout.tsx
@@ -6,7 +6,9 @@ import { useFlag } from 'hooks'
const AppLayout = ({ children }: PropsWithChildren<{}>) => {
const navLayoutV2 = useFlag('navigationLayoutV2')
const ongoingIncident = useFlag('ongoingIncident')
+
const appHeaderHeight = navLayoutV2 ? 49 : 0
+ const incidentBannerHeight = 44
return (
<div>
@@ -14,10 +16,10 @@ const AppLayout = ({ children }: PropsWithChildren<{}>) => {
<div
style={{
height: ongoingIncident
- ? `calc(100vh - 44px - ${appHeaderHeight}px)`
+ ? `calc(100vh - ${incidentBannerHeight}px - ${appHeaderHeight}px)`
: `calc(100vh - ${appHeaderHeight}px)`,
maxHeight: ongoingIncident
- ? `calc(100vh - 44px - ${appHeaderHeight}px)`
+ ? `calc(100vh - ${incidentBannerHeight}px - ${appHeaderHeight}px)`
: `calc(100vh - ${appHeaderHeight}px)`,
}}
>
diff --git a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
index 210df04dcb8..d8cfe64cc6d 100644
--- a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
+++ b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
@@ -1,3 +1,4 @@
+import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
import {
@@ -11,17 +12,15 @@ import {
Command_Shadcn_,
IconCode,
IconPlus,
- Popover,
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
} from 'ui'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
import { useFlag, useSelectedOrganization } from 'hooks'
-import ShimmeringLoader from 'components/ui/ShimmeringLoader'
-import Link from 'next/link'
const OrganizationDropdown = () => {
const router = useRouter()
diff --git a/studio/components/layouts/SettingsLayout/SettingsLayout.tsx b/studio/components/layouts/SettingsLayout/SettingsLayout.tsx
index 6bb553df5df..81ec13f6e89 100644
--- a/studio/components/layouts/SettingsLayout/SettingsLayout.tsx
+++ b/studio/components/layouts/SettingsLayout/SettingsLayout.tsx
@@ -3,22 +3,24 @@ import AppLayout from '../AppLayout/AppLayout'
import { useParams } from 'common'
import OrganizationSettingsMenu from './OrganizationSettingsMenu'
import AccountSettingsMenu from './AccountSettingsMenu'
+import { useRouter } from 'next/router'
const SettingsLayout = ({ children }: PropsWithChildren<{}>) => {
+ const router = useRouter()
const { ref, slug } = useParams()
- // [Joshen] Note to self - these could contribute to a Scaffold component
-
return (
<AppLayout>
<div className="flex h-full">
- <div className="h-full overflow-y-auto min-w-[280px] border-r px-8 py-8">
- {slug === undefined && ref === undefined ? (
- <AccountSettingsMenu />
- ) : (
- <OrganizationSettingsMenu />
- )}
- </div>
+ {router.pathname !== '/projects' && (
+ <div className="h-full overflow-y-auto min-w-[280px] border-r px-8 py-8">
+ {slug === undefined && ref === undefined ? (
+ <AccountSettingsMenu />
+ ) : (
+ <OrganizationSettingsMenu />
+ )}
+ </div>
+ )}
<div className="h-full overflow-y-auto flex-grow">{children}</div>
</div>
</AppLayout>
diff --git a/studio/pages/projects.tsx b/studio/pages/projects.tsx
index a004508fd74..ee0c4af7441 100644
--- a/studio/pages/projects.tsx
+++ b/studio/pages/projects.tsx
@@ -25,33 +25,35 @@ const ProjectsPage: NextPageWithLayout = () => {
const { isLoading: isProfileLoading } = useProfile()
const isLoading = isOrganizationLoading || isProfileLoading
const navLayoutV2 = useFlag('navigationLayoutV2')
+ const hasWindowLoaded = typeof window !== 'undefined'
useEffect(() => {
- if (navLayoutV2 && isSuccess && typeof window !== 'undefined') {
- const localStorageSlug =
- typeof window !== 'undefined'
- ? localStorage.getItem(LOCAL_STORAGE_KEYS.RECENTLY_VISITED_ORGANIZATION)
- : undefined
+ if (navLayoutV2 && isSuccess && hasWindowLoaded) {
+ const localStorageSlug = localStorage.getItem(
+ LOCAL_STORAGE_KEYS.RECENTLY_VISITED_ORGANIZATION
+ )
if (localStorageSlug) router.push(`/org/${localStorageSlug}`)
else router.push(`/org/${organizations[0].slug}`)
}
- }, [navLayoutV2, isSuccess, typeof window])
+ }, [navLayoutV2, isSuccess, hasWindowLoaded])
return (
<>
- {isLoading && (
- <div className="flex h-full items-center justify-center space-x-2">
+ {navLayoutV2 && isLoading && (
+ <div className={`flex items-center justify-center h-full`}>
<Connecting />
</div>
)}
{isError && (
- <div className="py-4 px-5">
+ <div
+ className={`py-4 px-5 ${navLayoutV2 ? 'h-full flex items-center justify-center' : ''}`}
+ >
<AlertError subject="Failed to retrieve organizations" />
</div>
)}
- {isSuccess && (
+ {!navLayoutV2 && isSuccess && (
<div className="py-4 px-5">
{IS_PLATFORM && (
<div className="my-2">