From d30558028f48749608473fdb8e1710403f446531 Mon Sep 17 00:00:00 2001 From: Camille TJHOA Date: Mon, 22 Jan 2024 14:13:38 +0100 Subject: [PATCH] WIP --- libs/shared/routes/src/lib/route-tree.gen.ts | 42 +++++++++++++++++++ .../clusters/$clusterId/_logs.tsx | 12 ++++++ .../clusters/$clusterId/_logs/index.tsx | 15 +++++++ 3 files changed, 69 insertions(+) create mode 100644 libs/shared/routes/src/lib/route-tree.gen.ts create mode 100644 libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs.tsx create mode 100644 libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs/index.tsx diff --git a/libs/shared/routes/src/lib/route-tree.gen.ts b/libs/shared/routes/src/lib/route-tree.gen.ts new file mode 100644 index 00000000000..352abb98949 --- /dev/null +++ b/libs/shared/routes/src/lib/route-tree.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by TanStack Router +// Import Routes +import { Route as rootRoute } from './routes/__root' +import { Route as OrganizationsOrganizationIdClustersClusterIdLogsImport } from './routes/organizations/$organizationId/clusters/$clusterId/_logs' +import { Route as OrganizationsOrganizationIdClustersClusterIdLogsIndexImport } from './routes/organizations/$organizationId/clusters/$clusterId/_logs/index' + +// Create/Update Routes + +const OrganizationsOrganizationIdClustersClusterIdLogsRoute = + OrganizationsOrganizationIdClustersClusterIdLogsImport.update({ + path: '/organizations/$organizationId/clusters/$clusterId/logs', + getParentRoute: () => rootRoute, + } as any) + +const OrganizationsOrganizationIdClustersClusterIdLogsIndexRoute = + OrganizationsOrganizationIdClustersClusterIdLogsIndexImport.update({ + path: '/', + getParentRoute: () => OrganizationsOrganizationIdClustersClusterIdLogsRoute, + } as any) + +// Populate the FileRoutesByPath interface + +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/organizations/$organizationId/clusters/$clusterId/_logs': { + preLoaderRoute: typeof OrganizationsOrganizationIdClustersClusterIdLogsImport + parentRoute: typeof rootRoute + } + '/organizations/$organizationId/clusters/$clusterId/_logs/': { + preLoaderRoute: typeof OrganizationsOrganizationIdClustersClusterIdLogsIndexImport + parentRoute: typeof OrganizationsOrganizationIdClustersClusterIdLogsImport + } + } +} + +// Create and export the route tree + +export const routeTree = rootRoute.addChildren([ + OrganizationsOrganizationIdClustersClusterIdLogsRoute.addChildren([ + OrganizationsOrganizationIdClustersClusterIdLogsIndexRoute, + ]), +]) diff --git a/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs.tsx b/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs.tsx new file mode 100644 index 00000000000..4760fee0472 --- /dev/null +++ b/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs.tsx @@ -0,0 +1,12 @@ +import { FileRoute, Outlet } from '@tanstack/react-router' +import { DarkModeEnabler, Layout } from '@qovery/pages/layout' + +export const Route = new FileRoute('/organizations/$organizationId/clusters/$clusterId/_logs').createRoute({ + component: () => ( + + + + + + ), +}) diff --git a/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs/index.tsx b/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs/index.tsx new file mode 100644 index 00000000000..ffb8d2419fc --- /dev/null +++ b/libs/shared/routes/src/lib/routes/organizations/$organizationId/clusters/$clusterId/_logs/index.tsx @@ -0,0 +1,15 @@ +import { FileRoute } from '@tanstack/react-router' +import { PageInfraLogs } from '@qovery/pages/logs/infra' +import { queries } from '@qovery/state/util-queries' + +export const Route = new FileRoute('/organizations/$organizationId/clusters/$clusterId/_logs/').createRoute({ + loader: async ({ context: { queryClient }, params: { organizationId, clusterId } }) => { + const clusters = await queryClient.ensureQueryData({ ...queries.clusters.list({ organizationId }) }) + const cluster = (clusters ?? []).find(({ id }) => id === clusterId) + if (!cluster) { + throw Error('Unknown cluster') + } + return cluster + }, + component: PageInfraLogs, +})