mirror of
https://github.com/gethomepage/homepage.git
synced 2025-07-09 03:04:18 -04:00
Enhancement: support nested services via labels for mixed layout-only groups (#5295)
This commit is contained in:
parent
564a0880b0
commit
ea37ab2f78
@ -135,6 +135,28 @@ function pruneEmptyGroups(groups) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mergeLayoutGroupsIntoConfigured(configuredGroups, layoutGroups) {
|
||||||
|
for (const layoutGroup of layoutGroups) {
|
||||||
|
const existing = findGroupByName(configuredGroups, layoutGroup.name);
|
||||||
|
if (existing) {
|
||||||
|
if (layoutGroup.groups?.length) {
|
||||||
|
existing.groups ??= [];
|
||||||
|
for (const sub of layoutGroup.groups) {
|
||||||
|
const existingSub = findGroupByName(existing.groups, sub.name);
|
||||||
|
if (!existingSub) {
|
||||||
|
existing.groups.push(sub);
|
||||||
|
} else {
|
||||||
|
// recursive merge if needed
|
||||||
|
mergeLayoutGroupsIntoConfigured([existingSub], [sub]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
configuredGroups.push(layoutGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function servicesResponse() {
|
export async function servicesResponse() {
|
||||||
let discoveredDockerServices;
|
let discoveredDockerServices;
|
||||||
let discoveredKubernetesServices;
|
let discoveredKubernetesServices;
|
||||||
@ -191,14 +213,10 @@ export async function servicesResponse() {
|
|||||||
const definedLayouts = initialSettings.layout ? Object.keys(initialSettings.layout) : null;
|
const definedLayouts = initialSettings.layout ? Object.keys(initialSettings.layout) : null;
|
||||||
if (definedLayouts) {
|
if (definedLayouts) {
|
||||||
// this handles cases where groups are only defined in the settings.yaml layout and not in the services.yaml
|
// this handles cases where groups are only defined in the settings.yaml layout and not in the services.yaml
|
||||||
const layoutConfiguredGroups = Object.entries(initialSettings.layout).map(([key, value]) =>
|
const layoutGroups = Object.entries(initialSettings.layout).map(([key, value]) =>
|
||||||
convertLayoutGroupToGroup(key, value),
|
convertLayoutGroupToGroup(key, value),
|
||||||
);
|
);
|
||||||
layoutConfiguredGroups.forEach((group) => {
|
mergeLayoutGroupsIntoConfigured(configuredServices, layoutGroups);
|
||||||
if (!configuredServices.find((serviceGroup) => serviceGroup.name === group.name)) {
|
|
||||||
configuredServices.push(group);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mergedGroupsNames.forEach((groupName) => {
|
mergedGroupsNames.forEach((groupName) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user