Files
weave-scope/client/app/scripts/components/matched-results.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

56 lines
1.4 KiB
JavaScript

import React from 'react';
import { connect } from 'react-redux';
import MatchedText from './matched-text';
const SHOW_ROW_COUNT = 2;
const MAX_MATCH_LENGTH = 24;
class MatchedResults extends React.Component {
renderMatch(matches, field) {
const match = matches.get(field);
const text = match.text;
return (
<div className="matched-results-match" key={match.label}>
<div className="matched-results-match-wrapper">
<span className="matched-results-match-label">
{match.label}:
</span>
<MatchedText text={text} match={match} maxLength={MAX_MATCH_LENGTH} />
</div>
</div>
);
}
render() {
const { matches } = this.props;
if (!matches) {
return null;
}
let moreFieldMatches;
let moreFieldMatchesTitle;
if (matches.size > SHOW_ROW_COUNT) {
moreFieldMatches = matches
.valueSeq()
.skip(SHOW_ROW_COUNT)
.map(field => field.label);
moreFieldMatchesTitle = `More matches:\n${moreFieldMatches.join(',\n')}`;
}
return (
<div className="matched-results">
{matches.keySeq().take(SHOW_ROW_COUNT).map(fieldId => this.renderMatch(matches, fieldId))}
{moreFieldMatches && <div className="matched-results-more" title={moreFieldMatchesTitle}>
{`${moreFieldMatches.size} more matches`}
</div>}
</div>
);
}
}
export default connect()(MatchedResults);