import { createBrowserRouter, Navigate } from 'react-router'; import { ProtectedRoute } from './auth/ProtectedRoute'; import { RequireAdmin } from './auth/RequireAdmin'; import { LoginPage } from './auth/LoginPage'; import { OidcCallback } from './auth/OidcCallback'; import { LayoutShell } from './components/LayoutShell'; import { config } from './config'; import { lazy, Suspense } from 'react'; import { PageLoader } from './components/PageLoader'; const ExchangesPage = lazy(() => import('./pages/Exchanges/ExchangesPage')); const DashboardPage = lazy(() => import('./pages/DashboardTab/DashboardPage')); const RuntimePage = lazy(() => import('./pages/RuntimeTab/RuntimePage')); const AdminLayout = lazy(() => import('./pages/Admin/AdminLayout')); const RbacPage = lazy(() => import('./pages/Admin/RbacPage')); const AuditLogPage = lazy(() => import('./pages/Admin/AuditLogPage')); const OidcConfigPage = lazy(() => import('./pages/Admin/OidcConfigPage')); const DatabaseAdminPage = lazy(() => import('./pages/Admin/DatabaseAdminPage')); const ClickHouseAdminPage = lazy(() => import('./pages/Admin/ClickHouseAdminPage')); const EnvironmentsPage = lazy(() => import('./pages/Admin/EnvironmentsPage')); const OutboundConnectionsPage = lazy(() => import('./pages/Admin/OutboundConnectionsPage')); const SensitiveKeysPage = lazy(() => import('./pages/Admin/SensitiveKeysPage')); const AppsTab = lazy(() => import('./pages/AppsTab/AppsTab')); const SwaggerPage = lazy(() => import('./pages/Swagger/SwaggerPage')); function SuspenseWrapper({ children }: { children: React.ReactNode }) { return ( }> {children} ); } const basename = config.basePath.replace(/\/$/, '') || undefined; export const router = createBrowserRouter([ { path: '/login', element: }, { path: '/oidc/callback', element: }, { element: , children: [ { element: , children: [ // Default redirect { index: true, element: }, // Exchanges tab { path: 'exchanges', element: }, { path: 'exchanges/:appId', element: }, { path: 'exchanges/:appId/:routeId', element: }, { path: 'exchanges/:appId/:routeId/:exchangeId', element: }, // Dashboard tab { path: 'dashboard', element: }, { path: 'dashboard/:appId', element: }, { path: 'dashboard/:appId/:routeId', element: }, // Runtime tab { path: 'runtime', element: }, { path: 'runtime/:appId', element: }, { path: 'runtime/:appId/:instanceId', element: }, // Redirects for removed tabs { path: 'logs', element: }, { path: 'logs/:appId', element: }, { path: 'logs/:appId/:routeId', element: }, { path: 'config', element: }, { path: 'config/:appId', element: }, { path: 'deployments', element: }, // Apps tab (OPERATOR+ via UI guard, shows all or single app) { path: 'apps', element: }, { path: 'apps/new', element: }, { path: 'apps/:appId', element: }, // Admin (ADMIN role required) { element: , children: [{ path: 'admin', element: , children: [ { index: true, element: }, { path: 'rbac', element: }, { path: 'audit', element: }, { path: 'oidc', element: }, { path: 'outbound-connections', element: }, { path: 'sensitive-keys', element: }, { path: 'database', element: }, { path: 'clickhouse', element: }, { path: 'environments', element: }, ], }], }, { path: 'api-docs', element: }, ], }, ], }, ], { basename });