mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
Ensure the observability link in the sidebar and command menu are properly guarded by IS_PLATFORM to prevent them from showing in self-hosted or CLI environments. The logic is functionally the same (IS_PLATFORM && reportsEnabled), but restructured with IS_PLATFORM as the outer check for clarity, and added comments explaining the platform-only restriction. https://claude.ai/code/session_01PG2TEGaSxaXZfXkbSBU3kQ ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES/NO ## What kind of change does this PR introduce? Bug fix, feature, docs update, ... ## What is the current behavior? Please link any relevant issues here. ## What is the new behavior? Feel free to include screenshots if it includes visual changes. ## Additional context Add any other context or screenshots. Co-authored-by: Claude <noreply@anthropic.com>
201 lines
6.6 KiB
TypeScript
201 lines
6.6 KiB
TypeScript
import { ICON_SIZE, ICON_STROKE_WIDTH } from 'components/interfaces/Sidebar'
|
|
import { useGenerateSettingsMenu } from 'components/layouts/ProjectSettingsLayout/SettingsMenu.utils'
|
|
import type { Route } from 'components/ui/ui.types'
|
|
import { EditorIndexPageLink } from 'data/prefetchers/project.$ref.editor'
|
|
import type { Project } from 'data/projects/project-detail-query'
|
|
import { Auth, Database, EdgeFunctions, Realtime, SqlEditor, Storage, TableEditor } from 'icons'
|
|
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}`
|
|
|
|
return [
|
|
{
|
|
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} />,
|
|
},
|
|
{
|
|
key: 'sql',
|
|
label: 'SQL Editor',
|
|
disabled: !isProjectActive,
|
|
icon: <SqlEditor size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/sql`),
|
|
},
|
|
]
|
|
}
|
|
|
|
export const generateProductRoutes = (
|
|
ref?: string,
|
|
project?: Project,
|
|
features?: {
|
|
auth?: boolean
|
|
edgeFunctions?: boolean
|
|
storage?: boolean
|
|
realtime?: boolean
|
|
authOverviewPage?: boolean
|
|
}
|
|
): Route[] => {
|
|
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 edgeFunctionsEnabled = features?.edgeFunctions ?? true
|
|
const storageEnabled = features?.storage ?? true
|
|
const realtimeEnabled = features?.realtime ?? true
|
|
const authOverviewPageEnabled = features?.authOverviewPage ?? false
|
|
|
|
return [
|
|
{
|
|
key: 'database',
|
|
label: 'Database',
|
|
disabled: !isProjectActive,
|
|
icon: <Database size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link:
|
|
ref &&
|
|
(isProjectBuilding
|
|
? buildingUrl
|
|
: isProjectActive
|
|
? `/project/${ref}/database/schemas`
|
|
: `/project/${ref}/database/backups/scheduled`),
|
|
},
|
|
...(authEnabled
|
|
? [
|
|
{
|
|
key: 'auth',
|
|
label: 'Authentication',
|
|
disabled: !isProjectActive,
|
|
icon: <Auth size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link:
|
|
ref &&
|
|
(isProjectBuilding
|
|
? buildingUrl
|
|
: authOverviewPageEnabled
|
|
? `/project/${ref}/auth/overview`
|
|
: `/project/${ref}/auth/users`),
|
|
},
|
|
]
|
|
: []),
|
|
...(storageEnabled
|
|
? [
|
|
{
|
|
key: 'storage',
|
|
label: 'Storage',
|
|
disabled: !isProjectActive,
|
|
icon: <Storage size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/storage/files`),
|
|
},
|
|
]
|
|
: []),
|
|
...(edgeFunctionsEnabled
|
|
? [
|
|
{
|
|
key: 'functions',
|
|
label: 'Edge Functions',
|
|
disabled: false,
|
|
icon: <EdgeFunctions size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && `/project/${ref}/functions`,
|
|
},
|
|
]
|
|
: []),
|
|
...(realtimeEnabled
|
|
? [
|
|
{
|
|
key: 'realtime',
|
|
label: 'Realtime',
|
|
disabled: !isProjectActive,
|
|
icon: <Realtime size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/realtime/inspector`),
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
}
|
|
|
|
export const generateOtherRoutes = (
|
|
ref?: string,
|
|
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}`
|
|
|
|
const { unifiedLogs, showReports, apiDocsSidePanel } = features ?? {}
|
|
const unifiedLogsEnabled = unifiedLogs ?? false
|
|
const reportsEnabled = showReports ?? true
|
|
const apiDocsSidePanelEnabled = apiDocsSidePanel ?? false
|
|
|
|
return [
|
|
{
|
|
key: 'advisors',
|
|
label: 'Advisors',
|
|
disabled: !isProjectActive,
|
|
icon: <Lightbulb size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/advisors/security`),
|
|
},
|
|
// Observability is only available on the platform, not for self-hosted/CLI
|
|
...(IS_PLATFORM
|
|
? reportsEnabled
|
|
? [
|
|
{
|
|
key: 'observability',
|
|
label: 'Observability',
|
|
disabled: !isProjectActive,
|
|
icon: <Telescope size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/observability`),
|
|
},
|
|
]
|
|
: []
|
|
: []),
|
|
{
|
|
key: 'logs',
|
|
label: 'Logs',
|
|
disabled: false,
|
|
icon: <List size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
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 &&
|
|
(isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/data_api/docs`),
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
key: 'integrations',
|
|
label: 'Integrations',
|
|
disabled: !isProjectActive,
|
|
icon: <Blocks size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/integrations`),
|
|
},
|
|
]
|
|
}
|
|
|
|
export const generateSettingsRoutes = (ref?: string): Route[] => {
|
|
return [
|
|
{
|
|
key: 'settings',
|
|
label: 'Project Settings',
|
|
icon: <Settings size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
|
|
link:
|
|
ref &&
|
|
(IS_PLATFORM ? `/project/${ref}/settings/general` : `/project/${ref}/settings/log-drains`),
|
|
disabled: false,
|
|
},
|
|
]
|
|
}
|