import React from 'react';
import { MatchedText } from 'weaveworks-ui-components';
const SHOW_ROW_COUNT = 2;
const Match = (searchTerms, match) => (
);
export default class MatchedResults extends React.PureComponent {
render() {
const { matches, searchTerms, style } = 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 (
{matches
.keySeq()
.take(SHOW_ROW_COUNT)
.map(fieldId => Match(searchTerms, matches.get(fieldId)))
}
{moreFieldMatches
&& (
{`${moreFieldMatches.size} more matches`}
)
}
);
}
}