From f68d989d846d2197ba9ae25e92abbc02540ea988 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 12 Nov 2020 18:45:11 +0000 Subject: [PATCH] ui: Upstream Instance Search and Sort (#9172) * ui: Add predicate, comparator and necessary files for the search/sort * Implement search and sort for upstream instance list * ui: Tweak CSS so its all part of the component * Remove the old proxy test attribute --- .../consul/upstream-instance/list/index.hbs | 116 ++++++++++-------- .../consul/upstream-instance/list/index.js | 24 ++++ .../consul/upstream-instance/list/index.scss | 18 ++- .../upstream-instance/list/pageobject.js | 11 ++ .../upstream-instance/search-bar/index.hbs | 41 +++++++ .../dc/services/instance/upstreams.js | 11 ++ .../routes/dc/services/instance/upstreams.js | 8 ++ .../search/predicates/upstream-instance.js | 12 ++ ui/packages/consul-ui/app/services/search.js | 3 + ui/packages/consul-ui/app/services/sort.js | 2 + .../app/sort/comparators/upstream-instance.js | 7 ++ .../consul-ui/app/styles/components.scss | 2 + .../app/styles/components/composite-row.scss | 4 +- .../dc/services/instance/upstreams.hbs | 32 ++++- ui/packages/consul-ui/tests/pages.js | 6 +- .../tests/pages/dc/services/instance.js | 7 +- 16 files changed, 239 insertions(+), 65 deletions(-) create mode 100644 ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.js create mode 100644 ui/packages/consul-ui/app/components/consul/upstream-instance/list/pageobject.js create mode 100644 ui/packages/consul-ui/app/components/consul/upstream-instance/search-bar/index.hbs create mode 100644 ui/packages/consul-ui/app/controllers/dc/services/instance/upstreams.js create mode 100644 ui/packages/consul-ui/app/search/predicates/upstream-instance.js create mode 100644 ui/packages/consul-ui/app/sort/comparators/upstream-instance.js diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs index 0b90b4312..cf5a08726 100644 --- a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs @@ -1,52 +1,66 @@ - + diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.js b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.js new file mode 100644 index 000000000..a02657584 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.js @@ -0,0 +1,24 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { sort } from '@ember/object/computed'; + +export default class ConsulUpstreamInstanceList extends Component { + @service('sort') sort; + @service('search') search; + + @sort('searched', 'comparator') sorted; + + get items() { + return this.sorted; + } + get searched() { + if (typeof this.args.search === 'undefined') { + return this.args.items; + } + const predicate = this.search.predicate('upstream-instance'); + return this.args.items.filter(predicate(this.args.search)); + } + get comparator() { + return this.sort.comparator('upstream-instance')(this.args.sort); + } +} diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.scss b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.scss index 983f72b9c..ea1017138 100644 --- a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.scss +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.scss @@ -1,6 +1,14 @@ -.consul-upstream-instance-list > li { - @extend %composite-row; +.consul-upstream-instance-list { + li { + @extend %composite-row; + } + dl { + @extend %icon-definition; + } + dl.datacenter dt::before { + @extend %with-user-organization-mask, %as-pseudo; + } + dl.nspace dt::before { + @extend %with-folder-outline-mask, %as-pseudo; + } } -.consul-upstream-instance-list > ul { - border-top: 1px solid $gray-200; -} \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/pageobject.js b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/pageobject.js new file mode 100644 index 000000000..552200a39 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/pageobject.js @@ -0,0 +1,11 @@ +export default (collection, text) => (scope = '.consul-upstream-instance-list') => { + return { + scope, + item: collection('li', { + name: text('.header p'), + nspace: text('.nspace dd'), + datacenter: text('.datacenter dd'), + localAddress: text('.local-address dd'), + }), + }; +}; diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/search-bar/index.hbs b/ui/packages/consul-ui/app/components/consul/upstream-instance/search-bar/index.hbs new file mode 100644 index 000000000..fee027149 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/search-bar/index.hbs @@ -0,0 +1,41 @@ +