Skip to content

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

fix: project sidebar menu urls while project is building up

phamhieu34d4a2feee07
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index 20943f281c2..335b31fd207 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -16,10 +16,11 @@ const NavigationBar: FC<Props> = ({}) => {
const router = useRouter()
const { ui } = useStore()
const projectRef = ui.selectedProjectRef as string
+ const projectBaseInfo = ui.selectedProjectBaseInfo
const activeRoute = router.pathname.split('/')[3]
- const productRoutes = generateProductRoutes(projectRef)
- const otherRoutes = generateOtherRoutes(projectRef)
+ const productRoutes = generateProductRoutes(projectRef, projectBaseInfo)
+ const otherRoutes = generateOtherRoutes(projectRef, projectBaseInfo)
return (
<div
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
index 83c21273b9f..16ceb4efdc9 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
@@ -10,13 +10,16 @@ import {
} from '@supabase/ui'
import SVG from 'react-inlinesvg'
-import { IS_PLATFORM } from 'lib/constants'
+import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { Route } from 'components/ui/ui.types'
import { useFlag } from 'hooks'
+import { ProjectBase } from 'types'
-export const generateProductRoutes = (ref: string): Route[] => {
+export const generateProductRoutes = (ref: string, project?: ProjectBase): Route[] => {
const functionsUi = useFlag('functionsUi')
+ const isProjectBuilding = project?.status !== PROJECT_STATUS.ACTIVE_HEALTHY
+ const buildingUrl = `/project/${ref}/building`
return [
{
@@ -29,13 +32,13 @@ export const generateProductRoutes = (ref: string): Route[] => {
preProcessor={(code) => code.replace(/svg/, 'svg class="m-auto text-color-inherit"')}
/>
),
- link: `/project/${ref}/editor`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/editor`,
},
{
key: 'auth',
label: 'Authentication',
icon: <IconUsers size={18} strokeWidth={2} />,
- link: `/project/${ref}/auth/users`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/auth/users`,
},
...(IS_PLATFORM
? [
@@ -43,7 +46,7 @@ export const generateProductRoutes = (ref: string): Route[] => {
key: 'storage',
label: 'Storage',
icon: <IconArchive size={18} strokeWidth={2} />,
- link: `/project/${ref}/storage/buckets`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/storage/buckets`,
},
]
: []),
@@ -57,13 +60,13 @@ export const generateProductRoutes = (ref: string): Route[] => {
preProcessor={(code) => code.replace(/svg/, 'svg class="m-auto text-color-inherit"')}
/>
),
- link: `/project/${ref}/sql`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/sql`,
},
{
key: 'database',
label: 'Database',
icon: <IconDatabase size={18} strokeWidth={2} />,
- link: `/project/${ref}/database/tables`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/database/tables`,
},
...(IS_PLATFORM && functionsUi
? [
@@ -71,15 +74,18 @@ export const generateProductRoutes = (ref: string): Route[] => {
key: 'functions',
label: 'Functions',
icon: <IconCode size={18} strokeWidth={2} />,
- link: `/project/${ref}/functions`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/functions`,
},
]
: []),
]
}
-export const generateOtherRoutes = (ref: string) => {
+export const generateOtherRoutes = (ref: string, project?: ProjectBase) => {
const logsExplorer = useFlag('logsExplorer')
+ const isProjectBuilding = project?.status !== PROJECT_STATUS.ACTIVE_HEALTHY
+ const buildingUrl = `/project/${ref}/building`
+
return [
...(IS_PLATFORM && logsExplorer
? [
@@ -87,7 +93,7 @@ export const generateOtherRoutes = (ref: string) => {
key: 'logsExplorer',
label: 'Logs Explorer',
icon: <IconList size={18} strokeWidth={2} />,
- link: `/project/${ref}/logs-explorer`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/logs-explorer`,
},
]
: []),
@@ -97,7 +103,7 @@ export const generateOtherRoutes = (ref: string) => {
key: 'reports',
label: 'Reports',
icon: <IconBarChart size={18} strokeWidth={2} />,
- link: `/project/${ref}/reports`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/reports`,
},
]
: []),
@@ -105,7 +111,7 @@ export const generateOtherRoutes = (ref: string) => {
key: 'api',
label: 'API',
icon: <IconFileText size={18} strokeWidth={2} />,
- link: `/project/${ref}/api`,
+ link: isProjectBuilding ? buildingUrl : `/project/${ref}/api`,
},
...(IS_PLATFORM
? [
diff --git a/studio/stores/UiStore.ts b/studio/stores/UiStore.ts
index 354eb335714..630acc952c9 100644
--- a/studio/stores/UiStore.ts
+++ b/studio/stores/UiStore.ts
@@ -1,6 +1,6 @@
import { uuidv4 } from 'lib/helpers'
import { action, makeAutoObservable } from 'mobx'
-import { Project, Notification, User, Organization } from 'types'
+import { Project, Notification, User, Organization, ProjectBase } from 'types'
import { IRootStore } from './RootStore'
import Telemetry from 'lib/telemetry'
@@ -12,6 +12,7 @@ export interface IUiStore {
selectedProjectRef?: string
isDarkTheme: boolean
selectedProject?: Project
+ selectedProjectBaseInfo?: ProjectBase
selectedOrganization?: Organization
notification?: Notification
profile?: User
@@ -60,6 +61,18 @@ export default class UiStore implements IUiStore {
return undefined
}
+ /**
+ * Get selected project base info.
+ *
+ * @return ProjectBase or undefined
+ */
+ get selectedProjectBaseInfo(): ProjectBase | undefined {
+ if (this.selectedProjectRef) {
+ return this.rootStore.app.projects.find((x: Project) => x.ref == this.selectedProjectRef)
+ }
+ return undefined
+ }
+
get selectedOrganization() {
if (this.selectedOrganizationSlug) {
const found = this.rootStore.app.organizations.find(
diff --git a/studio/types/base.ts b/studio/types/base.ts
index 552c545d1fe..138490aecb1 100644
--- a/studio/types/base.ts
+++ b/studio/types/base.ts
@@ -12,7 +12,7 @@ export interface Organization {
total_paid_projects?: number
}
-export interface Project {
+export interface ProjectBase {
id: number
ref: string
name: string
@@ -22,7 +22,9 @@ export interface Project {
region: string
inserted_at: string
subscription_id: string
+}
+export interface Project extends ProjectBase {
// only available after projects.fetchDetail
kpsVersion?: string
connectionString?: string