Conditionally show node links in CIS Scans

If nodes have been deleted previous reports with missing nodes were
breaking. To resolve that we now only show links to nodes that we can
find.

rancher/rancher#24676
This commit is contained in:
Cody Jackson 2019-12-19 12:30:15 -07:00
parent ded77b7208
commit 867239fa1b
3 changed files with 18 additions and 6 deletions

View File

@ -76,11 +76,16 @@ export default Controller.extend({
const state = this.getCheckState(test);
const nodeNames = get(this, 'model.scan').getNodeNamesFromNodeType(test.node_type);
const checkNodes = test.nodes || [];
const nodes = nodeNames.map((nodeName) => ({
state: this.getNodeState(test, nodeName, checkNodes),
nodeId: get(this, 'model.nodes').findBy('nodeName', nodeName).id,
name: nodeName
}));
const nodes = nodeNames.map((nodeName) => {
const node = get(this, 'model.nodes').findBy('nodeName', nodeName);
const nodeId = node ? node.id : null;
return {
state: this.getNodeState(test, nodeName, checkNodes),
nodeId,
name: nodeName
};
});
return {
state,

View File

@ -1,4 +1,10 @@
<tr class="main-row">
<td width="100" class="pl-15 pr-15 vertical-top pt-15"><BadgeState @model={{badgeState}} class="text-center full-width" /></td>
<td><a href="{{href-to 'authenticated.cluster.monitoring.node-detail' scope.currentCluster.id model.nodeId}}">{{model.name}}</a></td>
<td>
{{#if model.nodeId}}
<a href="{{href-to 'authenticated.cluster.monitoring.node-detail' scope.currentCluster.id model.nodeId}}">{{model.name}}</a>
{{else}}
{{model.name}} - {{t 'cis.scan.detail.table.nodesTable.notAvailable'}}
{{/if}}
</td>
</tr>

View File

@ -1074,6 +1074,7 @@ cis:
unskip: Unskip
nodesTable:
title: Nodes
notAvailable: Node is not part of the cluster
row:
remediation: "Remediation: {remediation}"