import debug from 'debug'; import React from 'react'; import classNames from 'classnames'; import { connect } from 'react-redux'; import { Map as makeMap } from 'immutable'; import { clickCloseDetails, clickShowTopologyForNode } from '../actions/app-actions'; import { brightenColor, getNeutralColor, getNodeColorDark } from '../utils/color-utils'; import { isGenericTable, isPropertyList } from '../utils/node-details-utils'; import { resetDocumentTitle, setDocumentTitle } from '../utils/title-utils'; import MatchedText from './matched-text'; import NodeDetailsControls from './node-details/node-details-controls'; import NodeDetailsGenericTable from './node-details/node-details-generic-table'; import NodeDetailsPropertyList from './node-details/node-details-property-list'; import NodeDetailsHealth from './node-details/node-details-health'; import NodeDetailsInfo from './node-details/node-details-info'; import NodeDetailsRelatives from './node-details/node-details-relatives'; import NodeDetailsTable from './node-details/node-details-table'; import Warning from './warning'; import CloudFeature from './cloud-feature'; import NodeDetailsImageStatus from './node-details/node-details-image-status'; const log = debug('scope:node-details'); function getTruncationText(count) { return 'This section was too long to be handled efficiently and has been truncated' + ` (${count} extra entries not included). We are working to remove this limitation.`; } class NodeDetails extends React.Component { constructor(props, context) { super(props, context); this.handleClickClose = this.handleClickClose.bind(this); this.handleShowTopologyForNode = this.handleShowTopologyForNode.bind(this); } handleClickClose(ev) { ev.preventDefault(); this.props.clickCloseDetails(this.props.nodeId); } handleShowTopologyForNode(ev) { ev.preventDefault(); this.props.clickShowTopologyForNode(this.props.topologyId, this.props.nodeId); } componentDidMount() { this.updateTitle(); } componentWillUnmount() { resetDocumentTitle(); } static collectMetrics(details) { const metrics = details.metrics || []; // collect by metric id (id => link) const metricLinks = (details.metric_links || []) .reduce((agg, link) => Object.assign(agg, {[link.id]: link}), {}); const availableMetrics = metrics.reduce( (agg, m) => Object.assign(agg, {[m.id]: true}), {} ); // append links with no metrics as fake metrics (details.metric_links || []).forEach((link) => { if (availableMetrics[link.id] === undefined) { metrics.push({id: link.id, label: link.label}); } }); return { metrics, metricLinks }; } renderTools() { const showSwitchTopology = this.props.nodeId !== this.props.selectedNodeId; const topologyTitle = `View ${this.props.label} in ${this.props.topologyId}`; return (
{this.props.label} is not visible to Scope when it is not communicating. Details will become available here when it communicates again.