Skip to content

Commit

Permalink
Adds support for filtering node/table by relatives
Browse files Browse the repository at this point in the history
Now that they are available in the summary data.
  • Loading branch information
foot committed Aug 9, 2016
1 parent d06547e commit fc2fcfb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 4 additions & 2 deletions client/app/scripts/charts/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';
import classnames from 'classnames';
import { Map as makeMap } from 'immutable';
import { Map as makeMap, List as makeList } from 'immutable';

import { clickNode, enterNode, leaveNode } from '../actions/app-actions';
import { getNodeColor } from '../utils/color-utils';
Expand Down Expand Up @@ -110,6 +110,8 @@ class Node extends React.Component {
onMouseEnter: this.handleMouseEnter,
onMouseLeave: this.handleMouseLeave,
};
const matchedNodeDetails = matches.get('metadata', makeList())
.concat(matches.get('parents', makeList()));

return (
<g className={nodeClassName} transform={transform}>
Expand All @@ -127,7 +129,7 @@ class Node extends React.Component {
<div className={subLabelClassName}>
<MatchedText text={subLabel} match={matches.get('sublabel')} />
</div>
{!blurred && <MatchedResults matches={matches.get('metadata')} />}
{!blurred && <MatchedResults matches={matchedNodeDetails} />}
</div>
</foreignObject>}

Expand Down
4 changes: 3 additions & 1 deletion client/app/scripts/components/node-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ export class NodeDetails extends React.Component {
<MatchedText text={details.label} match={nodeMatches.get('label')} />
</h2>
<div className="node-details-header-relatives">
{details.parents && <NodeDetailsRelatives relatives={details.parents} />}
{details.parents && <NodeDetailsRelatives
matches={nodeMatches.get('parents')}
relatives={details.parents} />}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
import { connect } from 'react-redux';

import { clickRelative } from '../../actions/app-actions';
import MatchedText from '../matched-text';

class NodeDetailsRelativesLink extends React.Component {

Expand All @@ -21,7 +22,7 @@ class NodeDetailsRelativesLink extends React.Component {
const title = `View in ${this.props.topologyId}: ${this.props.label}`;
return (
<span className="node-details-relatives-link" title={title} onClick={this.handleClick}>
{this.props.label}
<MatchedText text={this.props.label} match={this.props.match} />
</span>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { Map as makeMap } from 'immutable';

import NodeDetailsRelativesLink from './node-details-relatives-link';

Expand All @@ -20,7 +21,9 @@ export default class NodeDetailsRelatives extends React.Component {
}

render() {
let relatives = this.props.relatives;
let { relatives } = this.props;
const { matches = makeMap() } = this.props;

const limited = this.state.limit > 0 && relatives.length > this.state.limit;
const showLimitAction = limited || (this.state.limit === 0
&& relatives.length > this.DEFAULT_LIMIT);
Expand All @@ -31,7 +34,11 @@ export default class NodeDetailsRelatives extends React.Component {

return (
<div className="node-details-relatives">
{relatives.map(relative => <NodeDetailsRelativesLink {...relative} key={relative.id} />)}
{relatives.map(relative => (
<NodeDetailsRelativesLink
key={relative.id}
match={matches.get(relative.id)}
{...relative} />))}
{showLimitAction && <span className="node-details-relatives-more"
onClick={this.handleLimitClick}>{limitActionText}</span>}
</div>
Expand Down
9 changes: 9 additions & 0 deletions client/app/scripts/utils/search-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ export function searchTopology(nodes, { prefix, query, metric, comp, value }) {
});
}

// parents and relatives
if (node.get('parents')) {
node.get('parents').forEach(parent => {
const keyPath = [nodeId, 'parents', parent.get('id')];
nodeMatches = findNodeMatch(nodeMatches, keyPath, parent.get('label'),
query, prefix, parent.get('topologyId'));
});
}

// tables (envvars and labels)
const tables = node.get('tables');
if (tables) {
Expand Down

0 comments on commit fc2fcfb

Please sign in to comment.