1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 07:40:07 +02:00

feat(cp-frontend): handle removal of parent property

This commit is contained in:
Sérgio Ramos 2017-07-14 12:15:57 +01:00 committed by Judit Greskovits
parent 92181a2df0
commit 9802bba502
2 changed files with 17 additions and 27 deletions

View File

@ -6,7 +6,15 @@ query Services($deploymentGroupSlug: String!){
...DeploymentGroupInfo ...DeploymentGroupInfo
services { services {
...ServiceInfo ...ServiceInfo
parent branches {
name
slug
instances {
id
status
healthy
}
}
connections connections
instances { instances {
id id

View File

@ -132,34 +132,16 @@ const getService = (service, index) => {
const processServices = services => { const processServices = services => {
return forceArray(services).reduce((ss, s, i) => { return forceArray(services).reduce((ss, s, i) => {
if (s.parent) { const serviceIndex = ss.findIndex(existingS => existingS.id === s.id);
const parents = ss.filter(parentS => parentS.id === s.parent); if (serviceIndex === -1) {
let parent; ss.push(getService(s, i));
if (parents.length) {
parent = parents[0];
} else {
parent = { id: s.parent };
ss.push(parent);
}
if (!parent.children) {
parent.children = [];
}
const child = getService(s, i);
parent.instancesActive = parent.instancesActive
? true
: child.instancesActive;
parent.children.push(child);
} else { } else {
const serviceIndex = ss.findIndex(existingS => existingS.id === s.id); ss.splice(serviceIndex, 1, {
if (serviceIndex === -1) { ...ss[serviceIndex],
ss.push(getService(s, i)); ...getService(s, i)
} else { });
ss.splice(serviceIndex, 1, {
...ss[serviceIndex],
...getService(s, i)
});
}
} }
return ss; return ss;
}, []); }, []);
}; };