Add help text for runtime fields source. (#85204)

* Add help text for runtime fields source.

* fix help text

* Text changes and defining EuiCode element for _source.

Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>
This commit is contained in:
Adam Locke 2020-12-08 14:51:47 -05:00 committed by GitHub
parent 3f32b56192
commit 72ed936aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 16 deletions

View file

@ -5,6 +5,8 @@
*/ */
import React, { useEffect, useState, useCallback } from 'react'; import React, { useEffect, useState, useCallback } from 'react';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCode } from '@elastic/eui';
import { PainlessLang, PainlessContext } from '@kbn/monaco'; import { PainlessLang, PainlessContext } from '@kbn/monaco';
import { import {
EuiFlexGroup, EuiFlexGroup,
@ -260,20 +262,25 @@ const RuntimeFieldFormComp = ({
error={getErrorsMessages()} error={getErrorsMessages()}
isInvalid={!isValid} isInvalid={!isValid}
helpText={ helpText={
<EuiFlexGroup justifyContent="flexEnd"> <FormattedMessage
<EuiFlexItem grow={false}> id="xpack.runtimeFields.form.source.scriptFieldHelpText"
<EuiLink defaultMessage="Runtime fields without a script retrieve values from a field with the same name in {source}. If a field with the same name doesnt exist, no values return when a search request includes the runtime field. {learnMoreLink}"
href={links.runtimePainless} values={{
target="_blank" learnMoreLink: (
external <EuiLink
data-test-subj="painlessSyntaxLearnMoreLink" href={links.runtimePainless}
> target="_blank"
{i18n.translate('xpack.runtimeFields.form.script.learnMoreLinkText', { external
defaultMessage: 'Learn more about syntax.', data-test-subj="painlessSyntaxLearnMoreLink"
})} >
</EuiLink> {i18n.translate('xpack.runtimeFields.form.script.learnMoreLinkText', {
</EuiFlexItem> defaultMessage: 'Learn about script syntax.',
</EuiFlexGroup> })}
</EuiLink>
),
source: <EuiCode>{'_source'}</EuiCode>,
}}
/>
} }
fullWidth fullWidth
> >

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormSchema, fieldValidators } from '../../shared_imports'; import { FormSchema, fieldValidators } from '../../shared_imports';
import { RUNTIME_FIELD_OPTIONS } from '../../constants'; import { RUNTIME_FIELD_OPTIONS } from '../../constants';
import { RuntimeField, RuntimeType, ComboBoxOption } from '../../types'; import { RuntimeField, RuntimeType, ComboBoxOption } from '../../types';
@ -44,7 +43,7 @@ export const schema: FormSchema<RuntimeField> = {
script: { script: {
source: { source: {
label: i18n.translate('xpack.runtimeFields.form.defineFieldLabel', { label: i18n.translate('xpack.runtimeFields.form.defineFieldLabel', {
defaultMessage: 'Define field (optional)', defaultMessage: 'Define script (optional)',
}), }),
}, },
}, },