Files
weave-scope/client/app/scripts/components/node-details/node-details-info.js
David Kaltschmidt 749571ebe9 Review feedback
* Fix node-details-test for search
* Label spacing and matched text truncation
* Delete pinned search on backspace, add hint for metrics, escape % in URL
* Fix text-bg on node highlight
* Added tests for search-utils
* Fix matching of other topologies, added comment re quick clear
* s/cx/classnames/
* Ignore MoC keys when search in focus, blur on Esc
* Fixes search term highlighting on-hover
* Fix SVG exports
* Fine-tuned search item rendering
* Fixed search highlighting in the details panel
* Dont throb node on hover
* Hotkey for search: '/'
* Keep focus on search when tabbing away from the browser
* bring hovered node to top
* background for search results on hover
* fixed height for foreign object to prevent layout glitches
* Dont blur focused nodes on search
* More robust metric matchers
* More meaningful search hints
2016-05-11 18:08:59 +02:00

55 lines
1.7 KiB
JavaScript

import React from 'react';
import { Map as makeMap } from 'immutable';
import MatchedText from '../matched-text';
import ShowMore from '../show-more';
export default class NodeDetailsInfo extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
expanded: false
};
this.handleClickMore = this.handleClickMore.bind(this);
}
handleClickMore() {
const expanded = !this.state.expanded;
this.setState({expanded});
}
render() {
const { matches = makeMap() } = this.props;
let rows = (this.props.rows || []);
let notShown = 0;
const prime = rows.filter(row => row.priority < 10);
if (!this.state.expanded && prime.length < rows.length) {
// check if there is a search match in non-prime fields
const hasNonPrimeMatch = matches && rows.filter(row => row.priority >= 10
&& matches.has(row.id)).length > 0;
if (!hasNonPrimeMatch) {
notShown = rows.length - prime.length;
rows = prime;
}
}
return (
<div className="node-details-info">
{rows.map(field => (<div className="node-details-info-field" key={field.id}>
<div className="node-details-info-field-label truncate" title={field.label}>
{field.label}
</div>
<div className="node-details-info-field-value truncate" title={field.value}>
<MatchedText text={field.value} match={matches.get(field.id)} />
</div>
</div>
))}
<ShowMore handleClick={this.handleClickMore} collection={this.props.rows}
expanded={this.state.expanded} notShown={notShown} />
</div>
);
}
}