mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +00:00
respect both ways of adjacency for selected node
This commit is contained in:
@@ -4,6 +4,7 @@ const debug = require('debug')('scope:nodes-chart');
|
||||
const React = require('react');
|
||||
const timely = require('timely');
|
||||
|
||||
const AppStore = require('../stores/app-store');
|
||||
const Edge = require('./edge');
|
||||
const Naming = require('../constants/naming');
|
||||
const NodesLayout = require('./nodes-layout');
|
||||
@@ -83,7 +84,7 @@ const NodesChart = React.createClass({
|
||||
|
||||
renderGraphNodes: function(nodes, scale) {
|
||||
const hasSelectedNode = this.props.selectedNodeId && this.props.nodes.has(this.props.selectedNodeId);
|
||||
const adjacency = hasSelectedNode ? this.props.nodes.get(this.props.selectedNodeId).get('adjacency') : null;
|
||||
const adjacency = hasSelectedNode ? AppStore.getAdjacentNodes() : null;
|
||||
return _.map(nodes, function(node) {
|
||||
const highlighted = _.includes(this.props.highlightedNodeIds, node.id)
|
||||
|| this.props.selectedNodeId === node.id;
|
||||
@@ -214,7 +215,7 @@ const NodesChart = React.createClass({
|
||||
return;
|
||||
}
|
||||
|
||||
const adjacency = this.props.nodes.get(props.selectedNodeId).get('adjacency');
|
||||
const adjacency = AppStore.getAdjacentNodes();
|
||||
const adjacentLayoutNodes = [];
|
||||
|
||||
adjacency.forEach(function(adjacentId) {
|
||||
|
||||
@@ -9,6 +9,7 @@ const ActionTypes = require('../constants/action-types');
|
||||
const Naming = require('../constants/naming');
|
||||
|
||||
const makeOrderedMap = Immutable.OrderedMap;
|
||||
const makeSet = Immutable.Set;
|
||||
|
||||
// Helpers
|
||||
|
||||
@@ -44,6 +45,7 @@ function makeNode(node) {
|
||||
// Initial values
|
||||
|
||||
let activeTopologyOptions = null;
|
||||
let adjacentNodes = makeSet();
|
||||
let currentTopology = null;
|
||||
let currentTopologyId = 'containers';
|
||||
let errorUrl = null;
|
||||
@@ -94,9 +96,19 @@ const AppStore = assign({}, EventEmitter.prototype, {
|
||||
},
|
||||
|
||||
getAdjacentNodes: function() {
|
||||
adjacentNodes = adjacentNodes.clear();
|
||||
|
||||
if (nodes.has(selectedNodeId)) {
|
||||
return nodes.get(selectedNodeId).get('adjacency');
|
||||
adjacentNodes = makeSet(nodes.get(selectedNodeId).get('adjacency'));
|
||||
// fill up set with reverse edges
|
||||
nodes.forEach(function(node, nodeId) {
|
||||
if (node.get('adjacency').includes(selectedNodeId)) {
|
||||
adjacentNodes = adjacentNodes.add(nodeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return adjacentNodes;
|
||||
},
|
||||
|
||||
getCurrentTopology: function() {
|
||||
|
||||
@@ -210,7 +210,7 @@ body {
|
||||
|
||||
.link {
|
||||
stroke: @text-secondary-color;
|
||||
stroke-width: 1.5px;
|
||||
stroke-width: 1px;
|
||||
fill: none;
|
||||
stroke-opacity: 0.5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user