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: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/editor`), linkElement: , }, { key: 'sql', label: 'SQL Editor', disabled: !isProjectActive, icon: , 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: , link: ref && (isProjectBuilding ? buildingUrl : isProjectActive ? `/project/${ref}/database/schemas` : `/project/${ref}/database/backups/scheduled`), }, ...(authEnabled ? [ { key: 'auth', label: 'Authentication', disabled: !isProjectActive, icon: , link: ref && (isProjectBuilding ? buildingUrl : authOverviewPageEnabled ? `/project/${ref}/auth/overview` : `/project/${ref}/auth/users`), }, ] : []), ...(storageEnabled ? [ { key: 'storage', label: 'Storage', disabled: !isProjectActive, icon: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/storage/files`), }, ] : []), ...(edgeFunctionsEnabled ? [ { key: 'functions', label: 'Edge Functions', disabled: false, icon: , link: ref && `/project/${ref}/functions`, }, ] : []), ...(realtimeEnabled ? [ { key: 'realtime', label: 'Realtime', disabled: !isProjectActive, icon: , 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: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/advisors/security`), }, ...(IS_PLATFORM && reportsEnabled ? [ { key: 'observability', label: 'Observability', disabled: !isProjectActive, icon: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/observability`), }, ] : []), { key: 'logs', label: 'Logs', disabled: false, icon: , link: ref && (unifiedLogsEnabled ? `/project/${ref}/logs` : `/project/${ref}/logs/explorer`), }, ...(apiDocsSidePanelEnabled ? [ { key: 'api', label: 'API Docs', disabled: !isProjectActive, icon: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/integrations/data_api/docs`), }, ] : []), { key: 'integrations', label: 'Integrations', disabled: !isProjectActive, icon: , link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/integrations`), }, ] } export const generateSettingsRoutes = (ref?: string): Route[] => { return [ { key: 'settings', label: 'Project Settings', icon: , link: ref && (IS_PLATFORM ? `/project/${ref}/settings/general` : `/project/${ref}/settings/log-drains`), disabled: false, }, ] }