import React from 'react'; import { connect } from 'react-redux'; import { Map as makeMap } from 'immutable'; import MatchedText from '../matched-text'; import ShowMore from '../show-more'; import { formatDataType } from '../../utils/string-utils'; class NodeDetailsInfo extends React.Component { constructor(props, context) { super(props, context); this.state = { expanded: false }; this.handleClickMore = this.handleClickMore.bind(this); } handleClickMore() { this.setState(prevState => ({ expanded: !prevState.expanded })); } render() { const { timestamp, 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 (
{rows.map((field) => { const { value, title } = formatDataType(field, timestamp); return (
{field.label}
{field.dataType === 'link' ? ( {value} ) : ( ) }
); })}
); } } function mapStateToProps(state) { return { timestamp: state.get('pausedAt'), }; } export default connect(mapStateToProps)(NodeDetailsInfo);