diff --git a/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx b/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx index 7665ca482..11c52a6ca 100644 --- a/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx +++ b/pkgs/clan-app/ui/src/components/Sidebar/SidebarBody.tsx @@ -10,6 +10,7 @@ import { useMachineStateQuery } from "@/src/hooks/queries"; import { SidebarProps } from "./Sidebar"; import { Button } from "../Button/Button"; import { useClanContext } from "@/src/routes/Clan/Clan"; +import { Instance } from "@/src/workflows/Service/models"; interface MachineProps { clanURI: string; @@ -129,22 +130,42 @@ const Machines = () => { export const ServiceRoute = (props: { clanURI: string; - machineName?: string; label: string; id: string; - module: { input?: string | null | undefined; name: string }; + instance: Instance; }) => ( - + - - {props.label} - + + + {props.id} + + + + + + {props.instance.resolved.usage_ref.name} + + ); @@ -165,8 +186,12 @@ const Services = () => { const moduleName = instance.module.name; const label = moduleName == id ? moduleName : `${moduleName} (${id})`; - - return { id, label, module: instance.module }; + console.log("Service instance", id, instance, label); + return { + id, + label, + instance: instance, + }; }, ); }; @@ -191,7 +216,14 @@ const Services = () => { - {(instance) => } + {(mapped) => ( + + )} diff --git a/pkgs/clan-app/ui/src/routes/Machine/SectionServices.tsx b/pkgs/clan-app/ui/src/routes/Machine/SectionServices.tsx index 64d82f146..a7f689fdd 100644 --- a/pkgs/clan-app/ui/src/routes/Machine/SectionServices.tsx +++ b/pkgs/clan-app/ui/src/routes/Machine/SectionServices.tsx @@ -20,14 +20,15 @@ export const SectionServices = () => { return (ctx.machinesQuery.data[machineName].instance_refs ?? []).map( (id) => { - const module = ctx.serviceInstancesQuery.data?.[id].module; - if (!module) { - throw new Error(`Service instance ${id} has no module`); + const instance = ctx.serviceInstancesQuery.data?.[id]; + if (!instance) { + throw new Error(`Service instance ${id} not found`); } + const module = instance.module; return { id, - module, + instance, label: module.name == id ? module.name : `${module.name} (${id})`, }; }, @@ -41,11 +42,7 @@ export const SectionServices = () => { {(instance) => ( - + )} diff --git a/pkgs/clan-app/ui/src/workflows/Service/models.ts b/pkgs/clan-app/ui/src/workflows/Service/models.ts index 4a399f826..1d9d6825c 100644 --- a/pkgs/clan-app/ui/src/workflows/Service/models.ts +++ b/pkgs/clan-app/ui/src/workflows/Service/models.ts @@ -43,6 +43,8 @@ export interface Module { type ValueOf = T[keyof T]; +export type Instance = ValueOf>; + /** * Collect all members (machines and tags) for a given role in a service instance * @@ -50,7 +52,7 @@ type ValueOf = T[keyof T]; * */ export function getRoleMembers( - instance: ValueOf>, + instance: Instance, all_machines: NonNullable, role: string, ) {