Filter synthetic nodes on nodes list page

This commit is contained in:
wenincode 2022-10-12 15:11:05 -06:00
parent be1a4438a9
commit 1de0af4be1
5 changed files with 142 additions and 46 deletions

View File

@ -0,0 +1 @@
{{yield (hash data=this.data)}}

View File

@ -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,
};
}
}

View File

@ -76,12 +76,13 @@ as |route|>
{{/if}}
</BlockSlot>
<BlockSlot @name="content">
<Providers::RejectBy @items={{items}} @path="Meta.synthetic-node" @value="true" as |filtered|>
<DataCollection
@type="node"
@sort={{sort.value}}
@filters={{filters}}
@search={{search}}
@items={{items}}
@items={{filtered.data.items}}
as |collection|>
<collection.Collection>
<Consul::Node::List
@ -122,6 +123,7 @@ as |route|>
</EmptyState>
</collection.Empty>
</DataCollection>
</Providers::RejectBy>
</BlockSlot>
</AppView>
{{/let}}

View File

@ -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":[
${

View File

@ -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
---