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:
parent
92181a2df0
commit
9802bba502
@ -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
|
||||||
|
@ -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;
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user