Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for filtering graph/table by relatives #1775

Merged
merged 1 commit into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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