Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maps] add Where clause to terms joins (#39593)
* [Maps] add Where clause to terms joins * add functional test * rename layerQuery to sourceQuery
- Loading branch information
Showing
10 changed files
with
194 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...gacy/plugins/maps/public/components/layer_panel/join_editor/resources/where_expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import chrome from 'ui/chrome'; | ||
import React, { Component } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiButton, | ||
EuiPopover, | ||
EuiExpression, | ||
} from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { data } from 'plugins/data/setup'; | ||
const { QueryBar } = data.query.ui; | ||
import { Storage } from 'ui/storage'; | ||
|
||
const settings = chrome.getUiSettingsClient(); | ||
const localStorage = new Storage(window.localStorage); | ||
|
||
export class WhereExpression extends Component { | ||
|
||
state = { | ||
isPopoverOpen: false, | ||
}; | ||
|
||
_togglePopover = () => { | ||
this.setState((prevState) => ({ | ||
isPopoverOpen: !prevState.isPopoverOpen, | ||
})); | ||
} | ||
|
||
_closePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: false, | ||
}); | ||
} | ||
|
||
_onQueryChange = ({ query }) => { | ||
this.props.onChange(query); | ||
this._closePopover(); | ||
} | ||
|
||
render() { | ||
const { whereQuery, indexPattern } = this.props; | ||
const expressionValue = whereQuery && whereQuery.query | ||
? whereQuery.query | ||
: i18n.translate('xpack.maps.layerPanel.whereExpression.expressionValuePlaceholder', { | ||
defaultMessage: '-- add filter --' | ||
}); | ||
|
||
return ( | ||
<EuiPopover | ||
id="whereClausePopover" | ||
isOpen={this.state.isPopoverOpen} | ||
closePopover={this._closePopover} | ||
ownFocus | ||
withTitle | ||
anchorPosition="leftCenter" | ||
button={ | ||
<EuiExpression | ||
onClick={this._togglePopover} | ||
description={i18n.translate('xpack.maps.layerPanel.whereExpression.expressionDescription', { | ||
defaultMessage: 'where' | ||
})} | ||
uppercase={false} | ||
value={expressionValue} | ||
data-test-subj="mapJoinWhereExpressionButton" | ||
/> | ||
} | ||
> | ||
<div className="mapFilterEditor" data-test-subj="mapJoinWhereFilterEditor"> | ||
<QueryBar | ||
query={whereQuery ? whereQuery : { language: settings.get('search:queryLanguage'), query: '' }} | ||
onSubmit={this._onQueryChange} | ||
appName="maps" | ||
showDatePicker={false} | ||
indexPatterns={[indexPattern]} | ||
store={localStorage} | ||
customSubmitButton={ | ||
<EuiButton | ||
fill | ||
data-test-subj="mapWhereFilterEditorSubmitButton" | ||
> | ||
<FormattedMessage | ||
id="xpack.maps.layerPanel.whereExpression.queryBarSubmitButtonLabel" | ||
defaultMessage="Set filter" | ||
/> | ||
</EuiButton> | ||
} | ||
/> | ||
</div> | ||
</EuiPopover> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters