Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter scripted fields preview field list to source fields #53826

Merged
merged 4 commits into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
EuiTitle,
EuiCallOut,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

import { npStart } from 'ui/new_platform';
const { SearchBar } = npStart.plugins.data.ui;
Expand Down Expand Up @@ -116,7 +118,13 @@ export class TestScript extends Component {

if (previewData.error) {
return (
<EuiCallOut title="There's an error in your script" color="danger" iconType="cross">
<EuiCallOut
title={i18n.translate('common.ui.fieldEditor.testScript.errorMessage', {
defaultMessage: `There's an error in your script`,
})}
color="danger"
iconType="cross"
>
<EuiCodeBlock
language="json"
className="scriptPreviewCodeBlock"
Expand All @@ -131,7 +139,12 @@ export class TestScript extends Component {
return (
<Fragment>
<EuiTitle size="xs">
<p>First 10 results</p>
<p>
<FormattedMessage
id="common.ui.fieldEditor.testScript.resultsLabel"
defaultMessage="First 10 results"
/>
</p>
</EuiTitle>
<EuiSpacer size="s" />
<EuiCodeBlock
Expand All @@ -151,7 +164,8 @@ export class TestScript extends Component {

this.props.indexPattern.fields
.filter(field => {
return !field.name.startsWith('_');
const isMultiField = field.subType && field.subType.multi;
return !field.name.startsWith('_') && !isMultiField && !field.scripted;
})
.forEach(field => {
if (fieldsByTypeMap.has(field.type)) {
Expand Down Expand Up @@ -180,9 +194,16 @@ export class TestScript extends Component {

return (
<Fragment>
<EuiFormRow label="Additional fields" fullWidth>
<EuiFormRow
label={i18n.translate('common.ui.fieldEditor.testScript.fieldsLabel', {
defaultMessage: 'Additional fields',
})}
fullWidth
>
<EuiComboBox
placeholder="Select..."
placeholder={i18n.translate('common.ui.fieldEditor.testScript.fieldsPlaceholder', {
defaultMessage: 'Select...',
})}
options={fields}
selectedOptions={this.state.additionalFields}
onChange={this.onAdditionalFieldsChange}
Expand All @@ -205,7 +226,10 @@ export class TestScript extends Component {
isLoading={this.state.isLoading}
data-test-subj="runScriptButton"
>
Run script
<FormattedMessage
id="common.ui.fieldEditor.testScript.submitButtonLabel"
defaultMessage="Run script"
/>
</EuiButton>
}
/>
Expand All @@ -219,11 +243,19 @@ export class TestScript extends Component {
<Fragment>
<EuiSpacer />
<EuiText>
<h3>Preview results</h3>
<h3>
<FormattedMessage
id="common.ui.fieldEditor.testScript.resultsTitle"
defaultMessage="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 or add a query to filter on
specific documents.
<FormattedMessage
id="common.ui.fieldEditor.testScript.instructions"
defaultMessage="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 or add a query to filter on
specific documents."
/>
</p>
</EuiText>
<EuiSpacer />
Expand Down