[Maps] only show top hits checkbox if index has date fields (#43056) (#43060)

* [Maps] only show top hits checkbox if index has date fields

* rename useTopHitsCheckbox to topHitsCheckbox
This commit is contained in:
Nathan Reese 2019-08-09 16:04:08 -06:00 committed by GitHub
parent 50f9e2b7f1
commit d322b609d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,6 +191,23 @@ export class UpdateSourceEditor extends Component {
}
render() {
let topHitsCheckbox;
if (this.state.dateFields && this.state.dateFields.length) {
topHitsCheckbox = (
<EuiFormRow>
<EuiSwitch
label={
i18n.translate('xpack.maps.source.esSearch.useTopHitsLabel', {
defaultMessage: `Show most recent documents by entity`
})
}
checked={this.props.useTopHits}
onChange={this.onUseTopHitsChange}
/>
</EuiFormRow>
);
}
return (
<Fragment>
<TooltipSelector
@ -212,17 +229,7 @@ export class UpdateSourceEditor extends Component {
/>
</EuiFormRow>
<EuiFormRow>
<EuiSwitch
label={
i18n.translate('xpack.maps.source.esSearch.useTopHitsLabel', {
defaultMessage: `Show most recent documents by entity`
})
}
checked={this.props.useTopHits}
onChange={this.onUseTopHitsChange}
/>
</EuiFormRow>
{topHitsCheckbox}
{this.renderTopHitsForm()}
</Fragment>