Commit 4a1f333d authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat: add Federation tab with routing and sidebar integration

parent 158b9ef6
Loading
Loading
Loading
Loading
+13 −0
Changes for portal-gui/src/app/config/navigation.ts: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import {
  Server,
  Rocket,
  UserIcon,
  Handshake,
} from 'lucide-react';

import { ROUTES } from './route';
@@ -56,6 +57,14 @@ export const mainNavItems: NavItem[] = [
      },
    ],
  },
  {
    title: 'Federation',
    to: ROUTES.FEDERATION,
    description: 'Federate with partner operator platforms.',
    icon: Handshake,
    showInSidebar: true,
    roles: ['operator'],
  },
  {
    title: 'Profile',
    to: ROUTES.PROFILE,
@@ -64,6 +73,10 @@ export const mainNavItems: NavItem[] = [
  },
];

export function canSeeNavItem(item: NavItem, userRoles: readonly string[]) {
  return !item.roles || item.roles.some((role) => userRoles.includes(role));
}

export function isActivePath(pathname: string, to: string) {
  if (to === '/') {
    return pathname === '/';
+1 −0
Changes for portal-gui/src/app/config/route.ts: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ export const ROUTES = {
  APPLICATION_INSTANCES: '/applications/instances',
  APPLICATION_DEPLOYMENTS: '/applications/deployments',
  APPLICATION: '/applications/profiles/:appId',
  FEDERATION: '/federation',
  FORBIDDEN: '/403',
  NOT_FOUND: '/404',
} as const;
+10 −0
Changes for portal-gui/src/app/router.tsx: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import { AuthLayout } from '@/layouts/auth-layout';

import { ProtectedRoute } from './guards/protected-route';
import { PublicRoute } from './guards/public-route';
import { RoleGuard } from './guards/role-guard';

// Pages
import HomePage from '@/pages/home/index';
@@ -17,6 +18,7 @@ import ApplicationsPage from '@/pages/applications/index';
import ApplicationProfilesPage from '@/pages/applications/app-profiles';
import ApplicationInstancesPage from '@/pages/applications/app-instances';
import DeploymentsPage from '@/pages/applications/app-deployments';
import FederationPage from '@/pages/federation/index';

import ForbiddenPage from '@/pages/errors/forbidden';
import NotFoundPage from '@/pages/errors/not-found';
@@ -81,6 +83,14 @@ export const router = createBrowserRouter([
            path: ROUTES.APPLICATION_DEPLOYMENTS,
            element: <DeploymentsPage />,
          },
          {
            path: ROUTES.FEDERATION,
            element: (
              <RoleGuard allowedRoles={['operator']}>
                <FederationPage />
              </RoleGuard>
            ),
          },
        ],
      },
    ],
+17 −0
Changes for portal-gui/src/features/federation/federation.tsx: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
import { PageHeader } from '@/components/common/page-header';
import { PageContent } from '@/components/common/page-content';
import { EmptyState } from '@/components/common/empty-state';

export function FederationPage() {
  return (
    <>
      <PageHeader />
      <PageContent>
        <EmptyState
          title="No partners yet"
          description="Partner operator platforms you federate with will appear here."
        />
      </PageContent>
    </>
  );
}
+9 −2
Changes for portal-gui/src/layouts/app-sidebar.tsx: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -9,11 +9,14 @@ import {
  SidebarFooter,
  SidebarHeader,
} from '@/components/ui/sidebar';
import { mainNavItems } from '@/app/config/navigation';
import { canSeeNavItem, mainNavItems } from '@/app/config/navigation';
import { useAuth } from '@/features/auth/auth-context';

import { LogoIcon } from '@/lib/icons';

export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
  const { user } = useAuth();
  const roles = user?.roles ?? [];
  return (
    <Sidebar collapsible="offcanvas" {...props}>
      <SidebarHeader className="px-2 py-0">
@@ -25,7 +28,11 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
        </Link>
      </SidebarHeader>
      <SidebarContent>
        <NavMain items={mainNavItems.filter((item) => item.showInSidebar)} />
        <NavMain
          items={mainNavItems.filter(
            (item) => item.showInSidebar && canSeeNavItem(item, roles),
          )}
        />
      </SidebarContent>
      <SidebarFooter>
        <NavUser />
Loading