From 6d8a706b4d47d1801ed269a12db3ffdc400b756f Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 20 Jun 2019 12:12:14 +0100 Subject: [PATCH] ui: Adds the ability to frontend search instances by address (ip:port) (#5993) --- ui-v2/app/search/filters/service/node.js | 3 ++- .../unit/search/filters/service/node-test.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ui-v2/app/search/filters/service/node.js b/ui-v2/app/search/filters/service/node.js index 5f12724218..b156254655 100644 --- a/ui-v2/app/search/filters/service/node.js +++ b/ui-v2/app/search/filters/service/node.js @@ -8,7 +8,8 @@ export default function(filterable) { .indexOf(term) !== -1 || get(item, 'Service.ID') .toLowerCase() - .indexOf(term) !== -1 + .indexOf(term) !== -1 || + `${get(item, 'Service.Address')}:${get(item, 'Service.Port')}`.indexOf(term) !== -1 ); }); } diff --git a/ui-v2/tests/unit/search/filters/service/node-test.js b/ui-v2/tests/unit/search/filters/service/node-test.js index ca6f6ae326..d0c1b18275 100644 --- a/ui-v2/tests/unit/search/filters/service/node-test.js +++ b/ui-v2/tests/unit/search/filters/service/node-test.js @@ -29,6 +29,24 @@ test('items are found by properties', function(assert) { assert.ok(actual); }); }); +test('items are found by address:port', function(assert) { + const instance = { + Service: { + ID: 'id', + Address: '0.0.0.0', + Port: 8000, + }, + Node: { + Node: 'node-0', + }, + }; + ['0.0.0.0', '8000', '0:8000', '0.0.0.0:8000'].forEach(function(item) { + let actual = filter(instance, { + s: item, + }); + assert.ok(actual); + }); +}); test('items are not found', function(assert) { [ {