From 549bb201a51fcf71ebd7af7fe4c015c90c83c7fe Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Fri, 13 Jan 2017 14:30:42 +0100 Subject: [PATCH] Addressed David's comments --- client/app/scripts/components/node-details.js | 6 +++--- .../node-details/node-details-generic-table.js | 9 ++++++--- client/app/scripts/utils/node-details-utils.js | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/client/app/scripts/components/node-details.js b/client/app/scripts/components/node-details.js index cc5465b4a8..ffd99e6a17 100644 --- a/client/app/scripts/components/node-details.js +++ b/client/app/scripts/components/node-details.js @@ -19,7 +19,7 @@ import NodeDetailsTable from './node-details/node-details-table'; import Warning from './warning'; -const logError = debug('scope:error'); +const log = debug('scope:node-details'); function getTruncationText(count) { return 'This section was too long to be handled efficiently and has been truncated' @@ -213,7 +213,7 @@ class NodeDetails extends React.Component { return (
- {table.label.length > 0 && table.label} + {table.label && table.label.length > 0 && table.label} {table.truncationCount > 0 && @@ -249,7 +249,7 @@ class NodeDetails extends React.Component { ); } - logError(`Undefined type '${table.type}' for table ${table.id}`); + log(`Undefined type '${table.type}' for table ${table.id}`); return null; } diff --git a/client/app/scripts/components/node-details/node-details-generic-table.js b/client/app/scripts/components/node-details/node-details-generic-table.js index b4d45474f7..54e295ad80 100644 --- a/client/app/scripts/components/node-details/node-details-generic-table.js +++ b/client/app/scripts/components/node-details/node-details-generic-table.js @@ -1,10 +1,13 @@ import React from 'react'; +import sortBy from 'lodash/sortBy'; import { Map as makeMap } from 'immutable'; -import { sortBy } from 'lodash'; import { NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT } from '../../constants/limits'; + import { - isNumber, getTableColumnsStyles, genericTableEntryKey + isNumber, + getTableColumnsStyles, + genericTableEntryKey } from '../../utils/node-details-utils'; import NodeDetailsTableHeaders from './node-details-table-headers'; import MatchedText from '../matched-text'; @@ -31,7 +34,7 @@ export default class NodeDetailsGenericTable extends React.Component { super(props, context); this.state = { limit: NODE_DETAILS_DATA_ROWS_DEFAULT_LIMIT, - sortedBy: props.columns[0].id, + sortedBy: props.columns && props.columns[0].id, sortedDesc: true }; this.handleLimitClick = this.handleLimitClick.bind(this); diff --git a/client/app/scripts/utils/node-details-utils.js b/client/app/scripts/utils/node-details-utils.js index 7d9c3d2aa4..a7c84bde08 100644 --- a/client/app/scripts/utils/node-details-utils.js +++ b/client/app/scripts/utils/node-details-utils.js @@ -9,11 +9,11 @@ export function isPropertyList(table) { } export function isNumber(data) { - return data.dataType && data.dataType === 'number'; + return data && data.dataType && data.dataType === 'number'; } export function isIP(data) { - return data.dataType && data.dataType === 'ip'; + return data && data.dataType && data.dataType === 'ip'; } export function genericTableEntryKey(row, column) {