From 4218124b10cb9091478900045a5e244d6717a527 Mon Sep 17 00:00:00 2001 From: wenincode Date: Thu, 13 Oct 2022 07:29:51 -0600 Subject: [PATCH] Use reject-by composable helper instead of provider --- .../components/providers/reject-by/index.hbs | 1 - .../components/providers/reject-by/index.js | 36 --- .../app/templates/dc/nodes/index.hbs | 234 +++++++++--------- 3 files changed, 111 insertions(+), 160 deletions(-) delete mode 100644 ui/packages/consul-ui/app/components/providers/reject-by/index.hbs delete mode 100644 ui/packages/consul-ui/app/components/providers/reject-by/index.js diff --git a/ui/packages/consul-ui/app/components/providers/reject-by/index.hbs b/ui/packages/consul-ui/app/components/providers/reject-by/index.hbs deleted file mode 100644 index 30b7349001..0000000000 --- a/ui/packages/consul-ui/app/components/providers/reject-by/index.hbs +++ /dev/null @@ -1 +0,0 @@ -{{yield (hash data=this.data)}} diff --git a/ui/packages/consul-ui/app/components/providers/reject-by/index.js b/ui/packages/consul-ui/app/components/providers/reject-by/index.js deleted file mode 100644 index f4bd99c91b..0000000000 --- a/ui/packages/consul-ui/app/components/providers/reject-by/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import Component from '@glimmer/component'; -import { isArray } from '@ember/array'; -import { get } from '@ember/object'; -import { isEmpty, isEqual, isPresent } from '@ember/utils'; - -export default class RejectByProvider extends Component { - get items() { - const { items, path, value } = this.args; - - if (!isArray) { - return []; - } else if (isEmpty(path)) { - return items; - } - - let filterFn; - if (isPresent(value)) { - if (typeof value === 'function') { - filterFn = (item) => !value(get(item, path)); - } else { - filterFn = (item) => !isEqual(get(item, path), value); - } - } else { - filterFn = (item) => !get(item, path); - } - - return items.filter(filterFn); - } - - get data() { - const { items } = this; - return { - items, - }; - } -} diff --git a/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs b/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs index 6842c000cb..fb2c1a9d11 100644 --- a/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs +++ b/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs @@ -1,133 +1,121 @@ - + - + + as |api| + > - - - - - - {{#let - - (hash - value=(or sortBy "Status:asc") - change=(action (mut sortBy) value="target.selected") - ) - - (hash - status=(hash - value=(if status (split status ',') undefined) - change=(action (mut status) value="target.selectedItems") - ) - searchproperty=(hash - value=(if (not-eq searchproperty undefined) - (split searchproperty ',') - this._searchProperties - ) - change=(action (mut searchproperty) value="target.selectedItems") - default=this._searchProperties - ) - ) - - api.data - - leader.data - - as |sort filters items leader|}} - - -

- {{format-number items.length}} total -

- + + - - {{#if (gt items.length 0) }} - - {{/if}} + + {{#let + (hash value=(or sortBy 'Status:asc') change=(action (mut sortBy) value='target.selected')) + (hash + status=(hash + value=(if status (split status ',') undefined) + change=(action (mut status) value='target.selectedItems') + ) + searchproperty=(hash + value=(if + (not-eq searchproperty undefined) (split searchproperty ',') this._searchProperties + ) + change=(action (mut searchproperty) value='target.selectedItems') + default=this._searchProperties + ) + ) + api.data + leader.data + as |sort filters items leader| + }} + {{#let (reject-by 'Meta.synthetic-node' 'true' items) as |filtered|}} + + +

+ + {{format-number items.length}} total +

+ +
+ + {{#if (gt filtered.length 0)}} + + {{/if}} + + + + + + + + + +

+ {{t 'routes.dc.nodes.index.empty.header' items=items.length}} +

+
+ + {{t + 'routes.dc.nodes.index.empty.body' + items=items.length + canUseACLs=(can 'use acls') + htmlSafe=true + }} + + + + + +
+
+
+
+
+ {{/let}} + {{/let}}
- - - - - - - - - -

- {{t 'routes.dc.nodes.index.empty.header' - items=items.length - }} -

-
- - {{t 'routes.dc.nodes.index.empty.body' - items=items.length - canUseACLs=(can 'use acls') - htmlSafe=true - }} - - - - - -
-
-
-
-
-
- {{/let}} -
-
+