Skip to content

Commit ddf66fc

Browse files
Merge branch 'master' into 43444
2 parents 34791b9 + 3ed5264 commit ddf66fc

File tree

8 files changed

+75
-14
lines changed

8 files changed

+75
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@import './components/field_format_editor/samples/index';
2+
@import './components/scripting_help/test_script';

src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.js.snap

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.testScript__searchBar {
2+
.globalQueryBar {
3+
padding: $euiSize 0 0;
4+
}
5+
}

src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ jest.mock('ui/documentation_links', () => ({
2626
getDocLink: doc => `(docLink for ${doc})`,
2727
}));
2828

29+
jest.mock('./test_script', () => ({
30+
TestScript: () => {
31+
return `<div>mockTestScript</div>`;
32+
},
33+
}));
34+
2935
const indexPatternMock = {};
3036

3137
describe('ScriptingHelpFlyout', () => {

src/legacy/ui/public/field_editor/components/scripting_help/test_script.js

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ import {
3131
EuiCallOut,
3232
} from '@elastic/eui';
3333

34+
import { npStart } from 'ui/new_platform';
35+
const { SearchBar } = npStart.plugins.data.ui;
36+
37+
const { uiSettings } = npStart.core;
38+
39+
import { esQuery } from '../../../../../../plugins/data/public';
40+
3441
export class TestScript extends Component {
3542
state = {
3643
isLoading: false,
@@ -43,7 +50,7 @@ export class TestScript extends Component {
4350
}
4451
}
4552

46-
previewScript = async () => {
53+
previewScript = async searchContext => {
4754
const { indexPattern, lang, name, script, executeScript } = this.props;
4855

4956
if (!script || script.length === 0) {
@@ -54,11 +61,23 @@ export class TestScript extends Component {
5461
isLoading: true,
5562
});
5663

64+
let query;
65+
if (searchContext) {
66+
const esQueryConfigs = esQuery.getEsQueryConfig(uiSettings);
67+
query = esQuery.buildEsQuery(
68+
this.props.indexPattern,
69+
searchContext.query,
70+
null,
71+
esQueryConfigs
72+
);
73+
}
74+
5775
const scriptResponse = await executeScript({
5876
name,
5977
lang,
6078
script,
6179
indexPatternTitle: indexPattern.title,
80+
query,
6281
additionalFields: this.state.additionalFields.map(option => {
6382
return option.value;
6483
}),
@@ -161,24 +180,36 @@ export class TestScript extends Component {
161180

162181
return (
163182
<Fragment>
164-
<EuiFormRow label="Additional fields">
183+
<EuiFormRow label="Additional fields" fullWidth>
165184
<EuiComboBox
166185
placeholder="Select..."
167186
options={fields}
168187
selectedOptions={this.state.additionalFields}
169188
onChange={this.onAdditionalFieldsChange}
170189
data-test-subj="additionalFieldsSelect"
190+
fullWidth
171191
/>
172192
</EuiFormRow>
173193

174-
<EuiButton
175-
onClick={this.previewScript}
176-
disabled={this.props.script ? false : true}
177-
isLoading={this.state.isLoading}
178-
data-test-subj="runScriptButton"
179-
>
180-
Run script
181-
</EuiButton>
194+
<div className="testScript__searchBar">
195+
<SearchBar
196+
showFilterBar={false}
197+
showDatePicker={false}
198+
showQueryInput={true}
199+
query={{ language: uiSettings.get('search:queryLanguage'), query: '' }}
200+
onQuerySubmit={this.previewScript}
201+
indexPatterns={[this.props.indexPattern]}
202+
customSubmitButton={
203+
<EuiButton
204+
disabled={this.props.script ? false : true}
205+
isLoading={this.state.isLoading}
206+
data-test-subj="runScriptButton"
207+
>
208+
Run script
209+
</EuiButton>
210+
}
211+
/>
212+
</div>
182213
</Fragment>
183214
);
184215
}
@@ -191,7 +222,8 @@ export class TestScript extends Component {
191222
<h3>Preview results</h3>
192223
<p>
193224
Run your script to preview the first 10 results. You can also select some additional
194-
fields to include in your results to gain more context.
225+
fields to include in your results to gain more context or add a query to filter on
226+
specific documents.
195227
</p>
196228
</EuiText>
197229
<EuiSpacer />

src/legacy/ui/public/field_editor/lib/validate_script.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const executeScript = async ({
2424
lang,
2525
script,
2626
indexPatternTitle,
27+
query,
2728
additionalFields = [],
2829
}) => {
2930
// Using _msearch because _search with index name in path dorks everything up
@@ -52,6 +53,10 @@ export const executeScript = async ({
5253
search._source = additionalFields;
5354
}
5455

56+
if (query) {
57+
search.query = query;
58+
}
59+
5560
const body = `${JSON.stringify(header)}\n${JSON.stringify(search)}\n`;
5661
const esResp = await kfetch({ method: 'POST', pathname: '/elasticsearch/_msearch', body });
5762
// unwrap _msearch response

x-pack/legacy/plugins/maps/mappings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
},
2727
"maps-telemetry": {
2828
"properties": {
29+
"settings": {
30+
"properties": {
31+
"showMapVisualizationTypes": {
32+
"type": "boolean"
33+
}
34+
}
35+
},
36+
"indexPatternsWithGeoFieldCount": {
37+
"type": "long"
38+
},
2939
"mapsTotalCount": {
3040
"type": "long"
3141
},
@@ -72,4 +82,4 @@
7282
}
7383
}
7484
}
75-
}
85+
}

x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export class TOCEntry extends React.Component {
4646
};
4747

4848
async _loadHasLegendDetails() {
49-
const hasLegendDetails = await this.props.layer.hasLegendDetails();
49+
const hasLegendDetails =
50+
(await this.props.layer.hasLegendDetails()) &&
51+
this.props.layer.isVisible() &&
52+
this.props.layer.showAtZoomLevel(this.props.zoom);
5053
if (this._isMounted && hasLegendDetails !== this.state.hasLegendDetails) {
5154
this.setState({ hasLegendDetails });
5255
}

0 commit comments

Comments
 (0)