Merge pull request 'api/machines: move configuration data into subattribute' (#5048) from api-list-machines into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5048
This commit is contained in:
hsjobeki
2025-09-01 14:55:26 +00:00
8 changed files with 114 additions and 28 deletions

View File

@@ -136,7 +136,7 @@ export const SidebarBody = (props: SidebarProps) => {
<MachineRoute
clanURI={clanURI}
machineID={id}
name={machine.name || id}
name={machine.data.name || id}
serviceCount={0}
/>
)}

View File

@@ -26,13 +26,19 @@ const mockFetcher: Fetcher = <K extends OperationNames>(
const resultData: Partial<ResultDataMap> = {
list_machines: {
pandora: {
name: "pandora",
data: {
name: "pandora",
},
},
enceladus: {
name: "enceladus",
data: {
name: "enceladus",
},
},
dione: {
name: "dione",
data: {
name: "dione",
},
},
},
};

View File

@@ -62,20 +62,28 @@ const mockFetcher: Fetcher = <K extends OperationNames>(
},
list_machines: {
jon: {
name: "jon",
tags: ["all", "nixos", "tag1"],
data: {
name: "jon",
tags: ["all", "nixos", "tag1"],
},
},
sara: {
name: "sara",
tags: ["all", "darwin", "tag2"],
data: {
name: "sara",
tags: ["all", "darwin", "tag2"],
},
},
kyra: {
name: "kyra",
tags: ["all", "darwin", "tag2"],
data: {
name: "kyra",
tags: ["all", "darwin", "tag2"],
},
},
leila: {
name: "leila",
tags: ["all", "darwin", "tag2"],
data: {
name: "leila",
tags: ["all", "darwin", "tag2"],
},
},
},
list_tags: {

View File

@@ -120,7 +120,7 @@ const SelectService = () => {
label: t,
type: "tag" as const,
members: Object.entries(machinesQuery.data || {})
.filter(([_, m]) => m.tags?.includes(t))
.filter(([_, m]) => m.data.tags?.includes(t))
.map(([k]) => k),
};
});
@@ -206,7 +206,7 @@ const useOptions = (tagsQuery: TagsQuery, machinesQuery: MachinesQuery) =>
label: tag,
value: "t_" + tag,
members: Object.entries(machines)
.filter(([_, v]) => v.tags?.includes(tag))
.filter(([_, v]) => v.data.tags?.includes(tag))
.map(([k]) => k),
}));