Review feedback on supporting multiple relatives in node-grid columns

This commit is contained in:
Simon Howe
2017-07-03 17:49:37 +02:00
parent ffd531e44a
commit ee55d17b0e
2 changed files with 15 additions and 7 deletions

View File

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

View File

@@ -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: [<MyReactListItem />, <MyReactListItem />].join(' ')
// But you can't because React Components aren't strings.
//
// intersperse([<MyReactListItem />, <MyReactListItem />], ' ')
// Will get you there!
//
return [].concat(...items.map(e => [value, e])).slice(1);
}