Skip to content

Commit

Permalink
Merge branch 'master' into 43444
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Dec 27, 2019
2 parents 34791b9 + 3ed5264 commit ddf66fc
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/legacy/ui/public/field_editor/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import './components/field_format_editor/samples/index';
@import './components/scripting_help/test_script';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.testScript__searchBar {
.globalQueryBar {
padding: $euiSize 0 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jest.mock('ui/documentation_links', () => ({
getDocLink: doc => `(docLink for ${doc})`,
}));

jest.mock('./test_script', () => ({
TestScript: () => {
return `<div>mockTestScript</div>`;
},
}));

const indexPatternMock = {};

describe('ScriptingHelpFlyout', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ import {
EuiCallOut,
} from '@elastic/eui';

import { npStart } from 'ui/new_platform';
const { SearchBar } = npStart.plugins.data.ui;

const { uiSettings } = npStart.core;

import { esQuery } from '../../../../../../plugins/data/public';

export class TestScript extends Component {
state = {
isLoading: false,
Expand All @@ -43,7 +50,7 @@ export class TestScript extends Component {
}
}

previewScript = async () => {
previewScript = async searchContext => {
const { indexPattern, lang, name, script, executeScript } = this.props;

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

let query;
if (searchContext) {
const esQueryConfigs = esQuery.getEsQueryConfig(uiSettings);
query = esQuery.buildEsQuery(
this.props.indexPattern,
searchContext.query,
null,
esQueryConfigs
);
}

const scriptResponse = await executeScript({
name,
lang,
script,
indexPatternTitle: indexPattern.title,
query,
additionalFields: this.state.additionalFields.map(option => {
return option.value;
}),
Expand Down Expand Up @@ -161,24 +180,36 @@ export class TestScript extends Component {

return (
<Fragment>
<EuiFormRow label="Additional fields">
<EuiFormRow label="Additional fields" fullWidth>
<EuiComboBox
placeholder="Select..."
options={fields}
selectedOptions={this.state.additionalFields}
onChange={this.onAdditionalFieldsChange}
data-test-subj="additionalFieldsSelect"
fullWidth
/>
</EuiFormRow>

<EuiButton
onClick={this.previewScript}
disabled={this.props.script ? false : true}
isLoading={this.state.isLoading}
data-test-subj="runScriptButton"
>
Run script
</EuiButton>
<div className="testScript__searchBar">
<SearchBar
showFilterBar={false}
showDatePicker={false}
showQueryInput={true}
query={{ language: uiSettings.get('search:queryLanguage'), query: '' }}
onQuerySubmit={this.previewScript}
indexPatterns={[this.props.indexPattern]}
customSubmitButton={
<EuiButton
disabled={this.props.script ? false : true}
isLoading={this.state.isLoading}
data-test-subj="runScriptButton"
>
Run script
</EuiButton>
}
/>
</div>
</Fragment>
);
}
Expand All @@ -191,7 +222,8 @@ export class TestScript extends Component {
<h3>Preview results</h3>
<p>
Run your script to preview the first 10 results. You can also select some additional
fields to include in your results to gain more context.
fields to include in your results to gain more context or add a query to filter on
specific documents.
</p>
</EuiText>
<EuiSpacer />
Expand Down
5 changes: 5 additions & 0 deletions src/legacy/ui/public/field_editor/lib/validate_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const executeScript = async ({
lang,
script,
indexPatternTitle,
query,
additionalFields = [],
}) => {
// Using _msearch because _search with index name in path dorks everything up
Expand Down Expand Up @@ -52,6 +53,10 @@ export const executeScript = async ({
search._source = additionalFields;
}

if (query) {
search.query = query;
}

const body = `${JSON.stringify(header)}\n${JSON.stringify(search)}\n`;
const esResp = await kfetch({ method: 'POST', pathname: '/elasticsearch/_msearch', body });
// unwrap _msearch response
Expand Down
12 changes: 11 additions & 1 deletion x-pack/legacy/plugins/maps/mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
},
"maps-telemetry": {
"properties": {
"settings": {
"properties": {
"showMapVisualizationTypes": {
"type": "boolean"
}
}
},
"indexPatternsWithGeoFieldCount": {
"type": "long"
},
"mapsTotalCount": {
"type": "long"
},
Expand Down Expand Up @@ -72,4 +82,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export class TOCEntry extends React.Component {
};

async _loadHasLegendDetails() {
const hasLegendDetails = await this.props.layer.hasLegendDetails();
const hasLegendDetails =
(await this.props.layer.hasLegendDetails()) &&
this.props.layer.isVisible() &&
this.props.layer.showAtZoomLevel(this.props.zoom);
if (this._isMounted && hasLegendDetails !== this.state.hasLegendDetails) {
this.setState({ hasLegendDetails });
}
Expand Down

0 comments on commit ddf66fc

Please sign in to comment.