diff --git a/client/app/scripts/components/node-details/node-details-table-row.js b/client/app/scripts/components/node-details/node-details-table-row.js index 1b7277013..2f17cd33c 100644 --- a/client/app/scripts/components/node-details/node-details-table-row.js +++ b/client/app/scripts/components/node-details/node-details-table-row.js @@ -1,8 +1,6 @@ import React from 'react'; import classNames from 'classnames'; -import groupBy from 'lodash/groupBy'; -import forEach from 'lodash/forEach'; -import mapValues from 'lodash/mapValues'; +import { groupBy, mapValues } from 'lodash'; import { intersperse } from '../../utils/array-utils'; @@ -11,7 +9,7 @@ import NodeDetailsTableNodeMetric from './node-details-table-node-metric'; import { formatDataType } from '../../utils/string-utils'; function getValuesForNode(node) { - const values = {}; + let values = {}; ['metrics', 'metadata'].forEach((collection) => { if (node[collection]) { node[collection].forEach((field) => { @@ -32,9 +30,10 @@ function getValuesForNode(node) { relatives, })); - forEach(relativesByTopologyId, (columnData, topologyId) => { - values[topologyId] = columnData; - }); + values = { + ...values, + ...relativesByTopologyId, + }; } return values; diff --git a/client/app/scripts/utils/array-utils.js b/client/app/scripts/utils/array-utils.js index 8c4ac8562..2ad6218a6 100644 --- a/client/app/scripts/utils/array-utils.js +++ b/client/app/scripts/utils/array-utils.js @@ -28,5 +28,14 @@ export function moveElement(array, from, to) { } export function intersperse(items, value) { + // + // intersperse([1, 2, 3], 'a') => [1, 'a', 2, 'a', 3] + // + // Useful for when you wanna do: [, ].join(' ') + // But you can't because React Components aren't strings. + // + // intersperse([, ], ' ') + // Will get you there! + // return [].concat(...items.map(e => [value, e])).slice(1); }