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 new file mode 100644 index 000000000..30b734900 --- /dev/null +++ b/ui/packages/consul-ui/app/components/providers/reject-by/index.hbs @@ -0,0 +1 @@ +{{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 new file mode 100644 index 000000000..f4bd99c91 --- /dev/null +++ b/ui/packages/consul-ui/app/components/providers/reject-by/index.js @@ -0,0 +1,36 @@ +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 a2096231f..6842c000c 100644 --- a/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs +++ b/ui/packages/consul-ui/app/templates/dc/nodes/index.hbs @@ -76,52 +76,54 @@ as |route|> {{/if}} - - - - - - - -

- {{t 'routes.dc.nodes.index.empty.header' + + + + + + + + +

+ {{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 }} -

-
- - {{t 'routes.dc.nodes.index.empty.body' - items=items.length - canUseACLs=(can 'use acls') - htmlSafe=true - }} - - - - - -
-
-
+
+ + + + + + + + {{/let}} diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes b/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes index 8b63b7997..26a2ac501 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes @@ -24,7 +24,8 @@ "wan":"${fake.internet.ip()}" }, "Meta": { - "consul-network-segment":"" + "consul-network-segment":"", + "synthetic-node": "${fake.helpers.randomize(["true", "false", "false", "false"])}" }, "Services":[ ${ diff --git a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature index beb759c61..09347ed4c 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature @@ -21,6 +21,31 @@ Feature: dc / nodes / index Then the url should be /dc-1/nodes Then I see 1 node models And I see status on the nodes.0 like "critical" + Scenario: Viewing nodes list page should not show synthetic nodes + Given 3 node model from yaml + --- + - Meta: + synthetic-node: "true" + Checks: + - Status: passing + ServiceID: "" + - Meta: + synthetic-node: "false" + Checks: + - Status: passing + ServiceID: "" + - Meta: + synthetic-node: "false" + Checks: + - Status: critical + ServiceID: "" + --- + When I visit the nodes page for yaml + --- + dc: dc-1 + --- + Then the url should be /dc-1/nodes + Then I see 2 node models Scenario: Viewing a node with an unhealthy ServiceCheck Given 1 node model from yaml --- @@ -29,6 +54,8 @@ Feature: dc / nodes / index ServiceID: "" - Status: critical ServiceID: web + Meta: + synthetic-node: "false" --- When I visit the nodes page for yaml --- @@ -38,7 +65,24 @@ Feature: dc / nodes / index Then I see 1 node models And I see status on the nodes.0 like "passing" Scenario: Viewing nodes in the listing - Given 3 node models + Given 3 node model from yaml + --- + - Meta: + synthetic-node: "false" + Checks: + - Status: passing + ServiceID: "" + - Meta: + synthetic-node: "false" + Checks: + - Status: passing + ServiceID: "" + - Meta: + synthetic-node: "false" + Checks: + - Status: critical + ServiceID: "" + --- When I visit the nodes page for yaml --- dc: dc-1 @@ -54,12 +98,18 @@ Feature: dc / nodes / index Checks: - Status: critical Name: Warning check + Meta: + synthetic-node: "false" - Address: 10.0.0.1 Checks: - Status: passing + Meta: + synthetic-node: "false" - Address: 10.0.0.3 Checks: - Status: passing + Meta: + synthetic-node: "false" --- When I visit the nodes page for yaml --- @@ -73,10 +123,16 @@ Feature: dc / nodes / index --- - Node: node-01 Address: 10.0.0.0 + Meta: + synthetic-node: "false" - Node: node-02 Address: 10.0.0.1 + Meta: + synthetic-node: "false" - Node: node-03 Address: 10.0.0.2 + Meta: + synthetic-node: "false" --- When I visit the nodes page for yaml ---