open-consul/ui-v2/app/sort/comparators/service.js
John Cowen 7238089fc7
ui: Add new Service.Mesh* properties for improved sorting (#8542)
* ui: Serialize proxies into the model, add Mesh* model props

Serializes the proxies associated with a service onto the Service model
itself, then adds various Mesh* properties

* ui: Uses the new Mesh* properties throughout the app
2020-08-21 08:53:22 +01:00

38 lines
1,010 B
JavaScript

export default () => key => {
if (key.startsWith('Status:')) {
return function(serviceA, serviceB) {
const [, dir] = key.split(':');
let a, b;
if (dir === 'asc') {
b = serviceA;
a = serviceB;
} else {
a = serviceA;
b = serviceB;
}
switch (true) {
case a.MeshChecksCritical > b.MeshChecksCritical:
return 1;
case a.MeshChecksCritical < b.MeshChecksCritical:
return -1;
default:
switch (true) {
case a.MeshChecksWarning > b.MeshChecksWarning:
return 1;
case a.MeshChecksWarning < b.MeshChecksWarning:
return -1;
default:
switch (true) {
case a.MeshChecksPassing < b.MeshChecksPassing:
return 1;
case a.MeshChecksPassing > b.MeshChecksPassing:
return -1;
}
}
return 0;
}
};
}
return key;
};