From 222555c4c9e5f9bfd05b46fc632b6459e33ab533 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 7 Oct 2020 09:04:55 +0100 Subject: [PATCH] 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 --- .../consul-service-search-bar/index.hbs | 4 ++-- ui-v2/app/filter/predicates/service.js | 16 ++++++++++------ ui-v2/app/models/service.js | 7 +++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ui-v2/app/components/consul-service-search-bar/index.hbs b/ui-v2/app/components/consul-service-search-bar/index.hbs index 9013c715f0..d093ed1bcc 100644 --- a/ui-v2/app/components/consul-service-search-bar/index.hbs +++ b/ui-v2/app/components/consul-service-search-bar/index.hbs @@ -44,8 +44,8 @@ - - + + {{/let}} diff --git a/ui-v2/app/filter/predicates/service.js b/ui-v2/app/filter/predicates/service.js index 9aa5d4f09e..ed0a77ed9f 100644 --- a/ui-v2/app/filter/predicates/service.js +++ b/ui-v2/app/filter/predicates/service.js @@ -6,8 +6,8 @@ export default () => ({ instances = [], sources = [], statuses = [], types = [] 'terminating-gateway', 'mesh-gateway', 'service', - 'mesh-enabled', - 'mesh-disabled', + 'in-mesh', + 'not-in-mesh', ].reduce((prev, item) => { prev[item] = types.includes(item); return prev; @@ -48,11 +48,15 @@ export default () => ({ instances = [], sources = [], statuses = [], types = [] if (typeIncludes['service'] && typeof item.Kind === 'undefined') { return true; } - if (typeIncludes['mesh-enabled'] && typeof item.Proxy !== 'undefined') { - return true; + if (typeIncludes['in-mesh']) { + if (item.InMesh) { + return true; + } } - if (typeIncludes['mesh-disabled'] && typeof item.Proxy === 'undefined') { - return true; + if (typeIncludes['not-in-mesh']) { + if (!item.InMesh) { + return true; + } } return false; } diff --git a/ui-v2/app/models/service.js b/ui-v2/app/models/service.js index 181b5b7ab3..6f1a13294a 100644 --- a/ui-v2/app/models/service.js +++ b/ui-v2/app/models/service.js @@ -16,6 +16,7 @@ export default Model.extend({ InstanceCount: attr('number'), ConnectedWithGateway: attr(), ConnectedWithProxy: attr(), + Proxy: attr(), GatewayConfig: attr(), Kind: attr('string'), ExternalSources: attr(), @@ -39,6 +40,12 @@ export default Model.extend({ SyncTime: attr('number'), meta: attr(), /* 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() { switch (true) { case this.MeshChecksCritical !== 0: