From bec4d281c3612e4c4071ac23e134acd302540b5e Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Mon, 10 Oct 2016 15:15:31 +0200 Subject: [PATCH 1/2] Add label_minor to tooltips in connections table Sometimes label is not enough to distinguish between rows. --- .../node-details-table-node-link.js | 13 +++++---- render/detailed/connections.go | 21 ++++++++------- render/detailed/node_test.go | 27 ++++++++++--------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/client/app/scripts/components/node-details/node-details-table-node-link.js b/client/app/scripts/components/node-details/node-details-table-node-link.js index f821f0f11..b8d787abf 100644 --- a/client/app/scripts/components/node-details/node-details-table-node-link.js +++ b/client/app/scripts/components/node-details/node-details-table-node-link.js @@ -18,17 +18,20 @@ class NodeDetailsTableNodeLink extends React.Component { } render() { - if (this.props.linkable) { + const { label, label_minor: labelMinor, linkable } = this.props; + const title = !labelMinor ? label : `${label} (${labelMinor})`; + + if (linkable) { return ( - - {this.props.label} + {label} ); } return ( - - {this.props.label} + + {label} ); } diff --git a/render/detailed/connections.go b/render/detailed/connections.go index f6af81e44..8a43af3c8 100644 --- a/render/detailed/connections.go +++ b/render/detailed/connections.go @@ -43,11 +43,12 @@ type ConnectionsSummary struct { // Connection is a row in the connections table. type Connection struct { - ID string `json:"id"` // ID of this element in the UI. Must be unique for a given ConnectionsSummary. - NodeID string `json:"nodeId"` // ID of a node in the topology. Optional, must be set if linkable is true. - Label string `json:"label"` - Linkable bool `json:"linkable"` - Metadata []report.MetadataRow `json:"metadata,omitempty"` + ID string `json:"id"` // ID of this element in the UI. Must be unique for a given ConnectionsSummary. + NodeID string `json:"nodeId"` // ID of a node in the topology. Optional, must be set if linkable is true. + Label string `json:"label"` + LabelMinor string `json:"label_minor,omitempty"` + Linkable bool `json:"linkable"` + Metadata []report.MetadataRow `json:"metadata,omitempty"` } type connectionsByID []Connection @@ -128,13 +129,15 @@ func (c *connectionCounters) rows(r report.Report, ns report.Nodes, includeLocal // MakeNodeID(ns[row.remoteNodeID]). As we don't need the whole summary. summary, _ := MakeNodeSummary(r, ns[row.remoteNodeID]) connection := Connection{ - ID: fmt.Sprintf("%s-%s-%s-%s", row.remoteNodeID, row.remoteAddr, row.localAddr, row.port), - NodeID: summary.ID, - Label: summary.Label, - Linkable: true, + ID: fmt.Sprintf("%s-%s-%s-%s", row.remoteNodeID, row.remoteAddr, row.localAddr, row.port), + NodeID: summary.ID, + Label: summary.Label, + LabelMinor: summary.LabelMinor, + Linkable: true, } if row.remoteAddr != "" { connection.Label = row.remoteAddr + connection.LabelMinor = "" } if includeLocal { connection.Metadata = append(connection.Metadata, diff --git a/render/detailed/node_test.go b/render/detailed/node_test.go index eb834c640..fce374776 100644 --- a/render/detailed/node_test.go +++ b/render/detailed/node_test.go @@ -153,10 +153,11 @@ func TestMakeDetailedHostNode(t *testing.T) { Columns: detailed.NormalColumns, Connections: []detailed.Connection{ { - ID: connectionID(fixture.ServerHostNodeID, ""), - NodeID: fixture.ServerHostNodeID, - Label: "server", - Linkable: true, + ID: connectionID(fixture.ServerHostNodeID, ""), + NodeID: fixture.ServerHostNodeID, + Label: "server", + LabelMinor: "hostname.com", + Linkable: true, Metadata: []report.MetadataRow{ { ID: "port", @@ -259,10 +260,11 @@ func TestMakeDetailedContainerNode(t *testing.T) { Columns: detailed.NormalColumns, Connections: []detailed.Connection{ { - ID: connectionID(fixture.ClientContainerNodeID, ""), - NodeID: fixture.ClientContainerNodeID, - Label: "client", - Linkable: true, + ID: connectionID(fixture.ClientContainerNodeID, ""), + NodeID: fixture.ClientContainerNodeID, + Label: "client", + LabelMinor: "client.hostname.com", + Linkable: true, Metadata: []report.MetadataRow{ { ID: "port", @@ -375,10 +377,11 @@ func TestMakeDetailedPodNode(t *testing.T) { Columns: detailed.NormalColumns, Connections: []detailed.Connection{ { - ID: connectionID(fixture.ClientPodNodeID, ""), - NodeID: fixture.ClientPodNodeID, - Label: "pong-a", - Linkable: true, + ID: connectionID(fixture.ClientPodNodeID, ""), + NodeID: fixture.ClientPodNodeID, + Label: "pong-a", + LabelMinor: "1 container", + Linkable: true, Metadata: []report.MetadataRow{ { ID: "port", From 2ca23507de955d45fccf85b29154f4bdd3afe7a8 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Wed, 19 Oct 2016 10:50:11 +0200 Subject: [PATCH 2/2] label_minor -> labelMinor, closer to all camelCase api --- client/app/scripts/charts/nodes-grid.js | 2 +- client/app/scripts/components/debug-toolbar.js | 2 +- .../components/node-details/node-details-table-node-link.js | 2 +- client/app/scripts/reducers/__tests__/root-test.js | 4 ++-- client/app/scripts/selectors/chartSelectors.js | 2 +- client/app/scripts/utils/search-utils.js | 2 +- render/detailed/connections.go | 2 +- render/detailed/summary.go | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/app/scripts/charts/nodes-grid.js b/client/app/scripts/charts/nodes-grid.js index 6456c0224..0d26f182e 100644 --- a/client/app/scripts/charts/nodes-grid.js +++ b/client/app/scripts/charts/nodes-grid.js @@ -66,7 +66,7 @@ function renderIdCell(props) {
{props.label} {showSubLabel && - {props.label_minor}} + {props.labelMinor}}
); diff --git a/client/app/scripts/components/debug-toolbar.js b/client/app/scripts/components/debug-toolbar.js index 369238d1e..8a5220155 100644 --- a/client/app/scripts/components/debug-toolbar.js +++ b/client/app/scripts/components/debug-toolbar.js @@ -54,7 +54,7 @@ const deltaAdd = ( node_count: nodeCount, id: name, label: name, - label_minor: name, + labelMinor: name, latest: {}, origins: [], rank: name, diff --git a/client/app/scripts/components/node-details/node-details-table-node-link.js b/client/app/scripts/components/node-details/node-details-table-node-link.js index b8d787abf..af66e9609 100644 --- a/client/app/scripts/components/node-details/node-details-table-node-link.js +++ b/client/app/scripts/components/node-details/node-details-table-node-link.js @@ -18,7 +18,7 @@ class NodeDetailsTableNodeLink extends React.Component { } render() { - const { label, label_minor: labelMinor, linkable } = this.props; + const { label, labelMinor, linkable } = this.props; const title = !labelMinor ? label : `${label} (${labelMinor})`; if (linkable) { diff --git a/client/app/scripts/reducers/__tests__/root-test.js b/client/app/scripts/reducers/__tests__/root-test.js index 0121da97d..c7238471b 100644 --- a/client/app/scripts/reducers/__tests__/root-test.js +++ b/client/app/scripts/reducers/__tests__/root-test.js @@ -30,7 +30,7 @@ describe('RootReducer', () => { adjacency: ['n1', 'n2'], pseudo: undefined, label: undefined, - label_minor: undefined, + labelMinor: undefined, filtered: false, metrics: undefined, node_count: undefined, @@ -43,7 +43,7 @@ describe('RootReducer', () => { adjacency: undefined, pseudo: undefined, label: undefined, - label_minor: undefined, + labelMinor: undefined, filtered: false, metrics: undefined, node_count: undefined, diff --git a/client/app/scripts/selectors/chartSelectors.js b/client/app/scripts/selectors/chartSelectors.js index 5792a56b2..76ff85390 100644 --- a/client/app/scripts/selectors/chartSelectors.js +++ b/client/app/scripts/selectors/chartSelectors.js @@ -84,7 +84,7 @@ export const dataNodesSelector = createSelector( id, label: node.get('label'), pseudo: node.get('pseudo'), - subLabel: node.get('label_minor'), + subLabel: node.get('labelMinor'), nodeCount: node.get('node_count'), metrics: node.get('metrics'), rank: node.get('rank'), diff --git a/client/app/scripts/utils/search-utils.js b/client/app/scripts/utils/search-utils.js index 77d67cc35..4c20c617e 100644 --- a/client/app/scripts/utils/search-utils.js +++ b/client/app/scripts/utils/search-utils.js @@ -6,7 +6,7 @@ import { slugify } from './string-utils'; // topolevel search fields const SEARCH_FIELDS = makeMap({ label: 'label', - sublabel: 'label_minor' + sublabel: 'labelMinor' }); const COMPARISONS = makeMap({ diff --git a/render/detailed/connections.go b/render/detailed/connections.go index 8a43af3c8..b89ebb723 100644 --- a/render/detailed/connections.go +++ b/render/detailed/connections.go @@ -46,7 +46,7 @@ type Connection struct { ID string `json:"id"` // ID of this element in the UI. Must be unique for a given ConnectionsSummary. NodeID string `json:"nodeId"` // ID of a node in the topology. Optional, must be set if linkable is true. Label string `json:"label"` - LabelMinor string `json:"label_minor,omitempty"` + LabelMinor string `json:"labelMinor,omitempty"` Linkable bool `json:"linkable"` Metadata []report.MetadataRow `json:"metadata,omitempty"` } diff --git a/render/detailed/summary.go b/render/detailed/summary.go index 1cf384be0..6f5f59698 100644 --- a/render/detailed/summary.go +++ b/render/detailed/summary.go @@ -45,7 +45,7 @@ type Column struct { type NodeSummary struct { ID string `json:"id"` Label string `json:"label"` - LabelMinor string `json:"label_minor"` + LabelMinor string `json:"labelMinor"` Rank string `json:"rank"` Shape string `json:"shape,omitempty"` Stack bool `json:"stack,omitempty"`