ui: Fix up Service filtering by whether a Service is in the mesh or not in the mesh (#8836)

* Add MeshEnabled, InMesh properties and add Proxy back in

* Change query param to in-mesh/not-in-mesh

* Use new computed properties
This commit is contained in:
John Cowen 2020-10-07 09:04:55 +01:00 committed by GitHub
parent 35c4efd220
commit ccf0e257ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View File

@ -44,8 +44,8 @@
<Option @value="mesh-gateway" @selected={{contains 'mesh-gateway' filter.types}}>Mesh Gateway</Option> <Option @value="mesh-gateway" @selected={{contains 'mesh-gateway' filter.types}}>Mesh Gateway</Option>
</Optgroup> </Optgroup>
<Optgroup @label="Mesh"> <Optgroup @label="Mesh">
<Option @value="mesh-enabled" @selected={{contains 'mesh-enabled' filter.types}}>In service mesh</Option> <Option @value="in-mesh" @selected={{contains 'in-mesh' filter.types}}>In service mesh</Option>
<Option @value="mesh-disabled" @selected={{contains 'mesh-disabled' filter.types}}>Not in service mesh</Option> <Option @value="not-in-mesh" @selected={{contains 'not-in-mesh' filter.types}}>Not in service mesh</Option>
</Optgroup> </Optgroup>
{{/let}} {{/let}}
</BlockSlot> </BlockSlot>

View File

@ -6,8 +6,8 @@ export default () => ({ instances = [], sources = [], statuses = [], types = []
'terminating-gateway', 'terminating-gateway',
'mesh-gateway', 'mesh-gateway',
'service', 'service',
'mesh-enabled', 'in-mesh',
'mesh-disabled', 'not-in-mesh',
].reduce((prev, item) => { ].reduce((prev, item) => {
prev[item] = types.includes(item); prev[item] = types.includes(item);
return prev; return prev;
@ -48,11 +48,15 @@ export default () => ({ instances = [], sources = [], statuses = [], types = []
if (typeIncludes['service'] && typeof item.Kind === 'undefined') { if (typeIncludes['service'] && typeof item.Kind === 'undefined') {
return true; return true;
} }
if (typeIncludes['mesh-enabled'] && typeof item.Proxy !== 'undefined') { if (typeIncludes['in-mesh']) {
return true; if (item.InMesh) {
return true;
}
} }
if (typeIncludes['mesh-disabled'] && typeof item.Proxy === 'undefined') { if (typeIncludes['not-in-mesh']) {
return true; if (!item.InMesh) {
return true;
}
} }
return false; return false;
} }

View File

@ -16,6 +16,7 @@ export default Model.extend({
InstanceCount: attr('number'), InstanceCount: attr('number'),
ConnectedWithGateway: attr(), ConnectedWithGateway: attr(),
ConnectedWithProxy: attr(), ConnectedWithProxy: attr(),
Proxy: attr(),
GatewayConfig: attr(), GatewayConfig: attr(),
Kind: attr('string'), Kind: attr('string'),
ExternalSources: attr(), ExternalSources: attr(),
@ -39,6 +40,12 @@ export default Model.extend({
SyncTime: attr('number'), SyncTime: attr('number'),
meta: attr(), meta: attr(),
/* Mesh properties involve both the service and the associated proxy */ /* Mesh properties involve both the service and the associated proxy */
MeshEnabled: computed('ConnectedWithProxy', 'ConnectedWithGateway', function() {
return this.ConnectedWithProxy || this.ConnectedWithGateway;
}),
InMesh: computed('Kind', function() {
return this.MeshEnabled || (this.Kind || '').length > 0;
}),
MeshStatus: computed('MeshChecksPassing', 'MeshChecksWarning', 'MeshChecksCritical', function() { MeshStatus: computed('MeshChecksPassing', 'MeshChecksWarning', 'MeshChecksCritical', function() {
switch (true) { switch (true) {
case this.MeshChecksCritical !== 0: case this.MeshChecksCritical !== 0: