Skip to content

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

Ensure logs pages are accessible irregardless of project's status (#43010)

Joshen Lim42f134430339
diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx
index dc65c2d2a1e..2df6201e6bc 100644
--- a/apps/studio/components/interfaces/Sidebar.tsx
+++ b/apps/studio/components/interfaces/Sidebar.tsx
@@ -1,11 +1,3 @@
-import { AnimatePresence, motion, MotionProps } from 'framer-motion'
-import { isUndefined } from 'lodash'
-import { Blocks, Boxes, ChartArea, PanelLeftDashed, Receipt, Settings, Users } from 'lucide-react'
-import Link from 'next/link'
-import { useRouter } from 'next/router'
-import { ComponentProps, ComponentPropsWithoutRef, FC, ReactNode, useEffect } from 'react'
-
-import { PROJECT_STATUS } from '@/lib/constants'
import { LOCAL_STORAGE_KEYS, useFlag, useIsMFAEnabled, useParams } from 'common'
import {
generateOtherRoutes,
@@ -15,6 +7,7 @@ import {
} from 'components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils'
import { ProjectIndexPageLink } from 'data/prefetchers/project.$ref'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { AnimatePresence, motion, MotionProps } from 'framer-motion'
import { useHideSidebar } from 'hooks/misc/useHideSidebar'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useLints } from 'hooks/misc/useLints'
@@ -22,6 +15,11 @@ import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { Home } from 'icons'
+import { isUndefined } from 'lodash'
+import { Blocks, Boxes, ChartArea, PanelLeftDashed, Receipt, Settings, Users } from 'lucide-react'
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import { ComponentProps, ComponentPropsWithoutRef, FC, ReactNode, useEffect } from 'react'
import { useAppStateSnapshot } from 'state/app-state'
import {
Button,
@@ -43,6 +41,7 @@ import {
Sidebar as SidebarPrimitive,
useSidebar,
} from 'ui'
+
import { Route } from '../ui/ui.types'
import {
useIsAPIDocsSidePanelEnabled,
@@ -161,12 +160,10 @@ export function SideBarNavLink({
route,
active,
onClick,
- disabled,
...props
}: {
route: Route
active?: boolean
- disabled?: boolean
onClick?: () => void
} & ComponentPropsWithoutRef<typeof SidebarMenuButton>) {
const [sidebarBehaviour] = useLocalStorageQuery(
@@ -175,7 +172,7 @@ export function SideBarNavLink({
)
const buttonProps = {
- disabled,
+ disabled: route.disabled,
tooltip: sidebarBehaviour === 'closed' ? route.label : '',
isActive: active,
className: cn('text-sm', sidebarBehaviour === 'open' ? '!px-2' : ''),
@@ -194,7 +191,7 @@ export function SideBarNavLink({
return (
<SidebarMenuItem>
- {route.link && !disabled ? (
+ {route.link && !route.disabled ? (
<SidebarMenuButton {...buttonProps} asChild>
<Link href={route.link}>{content}</Link>
</SidebarMenuButton>
@@ -205,16 +202,12 @@ export function SideBarNavLink({
)
}
-const ActiveDot = (errorArray: any[], warningArray: any[]) => {
+const ActiveDot = ({ hasErrors, hasWarnings }: { hasErrors: boolean; hasWarnings: boolean }) => {
return (
<div
className={cn(
'absolute pointer-events-none flex h-2 w-2 left-[18px] group-data-[state=expanded]:left-[20px] top-2 z-10 rounded-full',
- errorArray.length > 0
- ? 'bg-destructive-600'
- : warningArray.length > 0
- ? 'bg-warning-600'
- : 'bg-transparent'
+ hasErrors ? 'bg-destructive-600' : hasWarnings ? 'bg-warning-600' : 'bg-transparent'
)}
/>
)
@@ -230,8 +223,6 @@ const ProjectLinks = () => {
const showReports = useIsFeatureEnabled('reports:all')
const { mutate: sendEvent } = useSendEventMutation()
- const isProjectActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
-
const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled()
const { isEnabled: isUnifiedLogsEnabled } = useUnifiedLogsPreview()
@@ -283,7 +274,6 @@ const ProjectLinks = () => {
{toolRoutes.map((route, i) => (
<SideBarNavLink
key={`tools-routes-${i}`}
- disabled={!isProjectActive}
route={route}
active={activeRoute === route.key}
/>
@@ -294,7 +284,6 @@ const ProjectLinks = () => {
{productRoutes.map((route, i) => (
<SideBarNavLink
key={`product-routes-${i}`}
- disabled={route.key !== 'functions' && !isProjectActive}
route={route}
active={activeRoute === route.key}
/>
@@ -322,41 +311,36 @@ const ProjectLinks = () => {
return (
<SideBarNavLink
- key={`other-routes-${i}`}
+ key={route.key}
route={
isNewAPIDocsEnabled
? {
label: route.label,
icon: route.icon,
key: route.key,
+ disabled: route.disabled,
}
: route
}
active={activeRoute === route.key}
- disabled={!isProjectActive}
onClick={handleApiClick}
/>
)
} else if (route.key === 'advisors') {
return (
<div className="relative" key={route.key}>
- {isProjectActive && ActiveDot(errorLints, securityLints)}
- <SideBarNavLink
- key={`other-routes-${i}`}
- route={route}
- disabled={!isProjectActive}
- active={activeRoute === route.key}
- />
+ {!route.disabled && (
+ <ActiveDot
+ hasErrors={errorLints.length > 0}
+ hasWarnings={securityLints.length > 0}
+ />
+ )}
+ <SideBarNavLink key={route.key} route={route} active={activeRoute === route.key} />
</div>
)
} else {
return (
- <SideBarNavLink
- key={`other-routes-${i}`}
- route={route}
- disabled={!isProjectActive}
- active={activeRoute === route.key}
- />
+ <SideBarNavLink key={route.key} route={route} active={activeRoute === route.key} />
)
}
})}
@@ -440,7 +424,6 @@ const OrganizationLinks = () => {
{navMenuItems.map((item, i) => (
<SideBarNavLink
key={item.key}
- disabled={disableAccessMfa}
active={
i === 0
? activeRoute === undefined
@@ -457,6 +440,7 @@ const OrganizationLinks = () => {
link: item.href,
key: item.label,
icon: item.icon,
+ disabled: disableAccessMfa,
}}
/>
))}
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
index 4a06b218dfe..995e6915d87 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
@@ -10,6 +10,7 @@ import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { Blocks, FileText, Lightbulb, List, Settings, Telescope } from 'lucide-react'
export const generateToolRoutes = (ref?: string, project?: Project, features?: {}): Route[] => {
+ const isProjectActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
const buildingUrl = `/project/${ref}`
@@ -17,6 +18,7 @@ export const generateToolRoutes = (ref?: string, project?: Project, features?: {
{
key: 'editor',
label: 'Table Editor',
+ disabled: !isProjectActive,
icon: <TableEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/editor`),
linkElement: <EditorIndexPageLink projectRef={ref} />,
@@ -24,6 +26,7 @@ export const generateToolRoutes = (ref?: string, project?: Project, features?: {
{
key: 'sql',
label: 'SQL Editor',
+ disabled: !isProjectActive,
icon: <SqlEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/sql`),
},
@@ -58,6 +61,7 @@ export const generateProductRoutes = (
{
key: 'database',
label: 'Database',
+ disabled: !isProjectActive,
icon: <Database size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link:
ref &&
@@ -73,6 +77,7 @@ export const generateProductRoutes = (
{
key: 'auth',
label: 'Authentication',
+ disabled: !isProjectActive,
icon: <Auth size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link:
ref &&
@@ -90,6 +95,7 @@ export const generateProductRoutes = (
{
key: 'storage',
label: 'Storage',
+ disabled: !isProjectActive,
icon: <Storage size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/storage/files`),
},
@@ -100,6 +106,7 @@ export const generateProductRoutes = (
{
key: 'functions',
label: 'Edge Functions',
+ disabled: false,
icon: <EdgeFunctions size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && `/project/${ref}/functions`,
},
@@ -110,6 +117,7 @@ export const generateProductRoutes = (
{
key: 'realtime',
label: 'Realtime',
+ disabled: !isProjectActive,
icon: <Realtime size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/realtime/inspector`),
},
@@ -123,6 +131,7 @@ export const generateOtherRoutes = (
project?: Project,
features?: { unifiedLogs?: boolean; showReports?: boolean; apiDocsSidePanel?: boolean }
): Route[] => {
+ const isProjectActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
const buildingUrl = `/project/${ref}`
@@ -135,6 +144,7 @@ export const generateOtherRoutes = (
{
key: 'advisors',
label: 'Advisors',
+ disabled: !isProjectActive,
icon: <Lightbulb size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/advisors/security`),
},
@@ -143,6 +153,7 @@ export const generateOtherRoutes = (
{
key: 'observability',
label: 'Observability',
+ disabled: !isProjectActive,
icon: <Telescope size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/observability`),
},
@@ -151,20 +162,16 @@ export const generateOtherRoutes = (
{
key: 'logs',
label: 'Logs',
+ disabled: false,
icon: <List size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
- link:
- ref &&
- (isProjectBuilding
- ? buildingUrl
- : unifiedLogsEnabled
- ? `/project/${ref}/logs`
- : `/project/${ref}/logs/explorer`),
+ link: ref && (unifiedLogsEnabled ? `/project/${ref}/logs` : `/project/${ref}/logs/explorer`),
},
...(apiDocsSidePanelEnabled
? [
{
key: 'api',
label: 'API Docs',
+ disabled: !isProjectActive,
icon: <FileText size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link:
ref &&
@@ -175,6 +182,7 @@ export const generateOtherRoutes = (
{
key: 'integrations',
label: 'Integrations',
+ disabled: !isProjectActive,
icon: <Blocks size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/integrations`),
},
@@ -192,6 +200,7 @@ export const generateSettingsRoutes = (ref?: string, project?: Project): Route[]
ref &&
(IS_PLATFORM ? `/project/${ref}/settings/general` : `/project/${ref}/settings/log-drains`),
items: settingsMenu,
+ disabled: false,
},
]
}
diff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsx
index 660c784aa41..5c63046e4dc 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx
@@ -1,7 +1,3 @@
-import Head from 'next/head'
-import { useRouter } from 'next/router'
-import { forwardRef, Fragment, PropsWithChildren, ReactNode, useEffect } from 'react'
-
import { mergeRefs, useParams } from 'common'
import { CreateBranchModal } from 'components/interfaces/BranchManagement/CreateBranchModal'
import { ProjectAPIDocs } from 'components/interfaces/ProjectAPIDocs/ProjectAPIDocs'
@@ -13,10 +9,14 @@ import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { withAuth } from 'hooks/misc/withAuth'
import { usePHFlag } from 'hooks/ui/useFlag'
import { PROJECT_STATUS } from 'lib/constants'
+import Head from 'next/head'
+import { useRouter } from 'next/router'
+import { forwardRef, Fragment, PropsWithChildren, ReactNode, useEffect } from 'react'
import { useAppStateSnapshot } from 'state/app-state'
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import { cn, LogoLoader, ResizableHandle, ResizablePanel, ResizablePanelGroup } from 'ui'
import MobileSheetNav from 'ui-patterns/MobileSheetNav/MobileSheetNav'
+
import { useEditorType } from '../editors/EditorsLayout.hooks'
import { useSetMainScrollContainer } from '../MainScrollContainerContext'
import BuildingState from './BuildingState'
@@ -35,27 +35,27 @@ import { UpgradingState } from './UpgradingState'
// [Joshen] This is temporary while we unblock users from managing their project
// if their project is not responding well for any reason. Eventually needs a bit of an overhaul
const routesToIgnoreProjectDetailsRequest = [
+ '/project/[ref]/settings/infrastructure',
+ '/project/[ref]/settings/addons',
'/project/[ref]/settings/general',
'/project/[ref]/database/settings',
'/project/[ref]/storage/settings',
- '/project/[ref]/settings/infrastructure',
- '/project/[ref]/settings/addons',
]
const routesToIgnoreDBConnection = [
'/project/[ref]/branches',
- '/project/[ref]/database/backups/scheduled',
- '/project/[ref]/database/backups/pitr',
- '/project/[ref]/settings/addons',
+ '/project/[ref]/database/backups',
+ '/project/[ref]/settings',
'/project/[ref]/functions',
+ '/project/[ref]/logs',
]
const routesToIgnorePostgrestConnection = [
- '/project/[ref]/reports',
'/project/[ref]/settings/general',
- '/project/[ref]/database/settings',
'/project/[ref]/settings/infrastructure',
'/project/[ref]/settings/addons',
+ '/project/[ref]/database/settings',
+ '/project/[ref]/reports',
]
export interface ProjectLayoutProps {
@@ -108,7 +108,8 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<Projec
const ignorePausedState =
router.pathname === '/project/[ref]' ||
router.pathname.includes('/project/[ref]/settings') ||
- router.pathname.includes('/project/[ref]/functions')
+ router.pathname.includes('/project/[ref]/functions') ||
+ router.pathname.includes('/project/[ref]/logs')
const showPausedState = isPaused && !ignorePausedState
const sidebarMinSizePercentage = 1
@@ -132,7 +133,6 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<Projec
<meta name="description" content="Supabase Studio" />
</Head>
<div className="flex flex-row h-full w-full">
- {/* autoSaveId="project-layout" */}
<ResizablePanelGroup direction="horizontal">
{productMenu && (
<ResizablePanel
@@ -275,18 +275,10 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrapp
const { data: selectedProject } = useSelectedProjectQuery()
const isHomeNew = usePHFlag('homeNew') === 'new-home'
- const isBranchesPage = router.pathname.includes('/project/[ref]/branches')
- const isSettingsPages = router.pathname.includes('/project/[ref]/settings')
- const isEdgeFunctionPages = router.pathname.includes('/project/[ref]/functions')
- const isVaultPage = router.pathname === '/project/[ref]/settings/vault'
const isBackupsPage = router.pathname.includes('/project/[ref]/database/backups')
const isHomePage = router.pathname === '/project/[ref]'
- const requiresDbConnection: boolean =
- (!isEdgeFunctionPages &&
- !isSettingsPages &&
- !routesToIgnoreDBConnection.includes(router.pathname)) ||
- isVaultPage
+ const requiresDbConnection = !routesToIgnoreDBConnection.some((x) => router.pathname.includes(x))
const requiresPostgrestConnection = !routesToIgnorePostgrestConnection.includes(router.pathname)
const requiresProjectDetails = !routesToIgnoreProjectDetailsRequest.includes(router.pathname)
@@ -304,11 +296,11 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrapp
// handle redirect to home for building state
const shouldRedirectToHomeForBuilding =
- isHomeNew && requiresDbConnection && isProjectBuilding && !isBranchesPage && !isHomePage
+ isProjectBuilding && requiresDbConnection && isHomeNew && !isHomePage
// We won't be showing the building state with the new home page
const shouldShowBuildingState =
- requiresDbConnection && isProjectBuilding && !isBranchesPage && !(isHomeNew && isHomePage)
+ isProjectBuilding && requiresDbConnection && !(isHomeNew && isHomePage)
useEffect(() => {
if (shouldRedirectToHomeForBuilding && ref) {
@@ -352,7 +344,7 @@ const ContentWrapper = ({ isLoading, isBlocking = true, children }: ContentWrapp
return <RestoringState />
}
- if (isProjectRestoreFailed && !isBackupsPage && !isEdgeFunctionPages) {
+ if (requiresDbConnection && isProjectRestoreFailed) {
return <RestoreFailedState />
}
diff --git a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
index cd82c7aa6a5..17320fc9d33 100644
--- a/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
+++ b/apps/studio/components/layouts/ProjectSettingsLayout/SettingsMenu.utils.tsx
@@ -1,8 +1,7 @@
-import { ArrowUpRight } from 'lucide-react'
-
import type { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
import type { Project } from 'data/projects/project-detail-query'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
+import { ArrowUpRight } from 'lucide-react'
import type { Organization } from 'types'
export const generateSettingsMenu = (
@@ -37,13 +36,7 @@ export const generateSettingsMenu = (
}
const isProjectActive = project?.status === PROJECT_STATUS.ACTIVE_HEALTHY
- const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
- const buildingUrl = `/project/${ref}`
- const authEnabled = features?.auth ?? true
- const authProvidersEnabled = features?.authProviders ?? true
- const edgeFunctionsEnabled = features?.edgeFunctions ?? true
- const storageEnabled = features?.storage ?? true
const legacyJwtKeysEnabled = features?.legacyJwtKeys ?? true
const billingEnabled = features?.billing ?? true
@@ -67,7 +60,7 @@ export const generateSettingsMenu = (
{
name: 'Infrastructure',
key: 'infrastructure',
- url: isProjectBuilding ? buildingUrl : `/project/${ref}/settings/infrastructure`,
+ url: `/project/${ref}/settings/infrastructure`,
items: [],
disabled: !isProjectActive,
},
@@ -118,14 +111,15 @@ export const generateSettingsMenu = (
{
name: 'Data API',
key: 'api',
- url: isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/data_api/overview`,
+ url: `/project/${ref}/integrations/data_api/overview`,
items: [],
rightIcon: <ArrowUpRight strokeWidth={1} className="h-4 w-4" />,
+ disabled: !isProjectActive,
},
{
name: 'Vault',
key: 'vault',
- url: isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/vault/overview`,
+ url: `/project/${ref}/integrations/vault/overview`,
items: [],
rightIcon: <ArrowUpRight strokeWidth={1} className="h-4 w-4" />,
label: 'Beta',