-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rk/bar-to-spinner
- Loading branch information
Showing
75 changed files
with
1,839 additions
and
193 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
80 changes: 80 additions & 0 deletions
80
...mappings_editor/components/document_fields/field_parameters/painless_script_parameter.tsx
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,80 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiFormRow, EuiDescribedFormGroup } from '@elastic/eui'; | ||
|
||
import { CodeEditor, UseField } from '../../../shared_imports'; | ||
import { getFieldConfig } from '../../../lib'; | ||
import { EditFieldFormRow } from '../fields/edit_field'; | ||
|
||
interface Props { | ||
stack?: boolean; | ||
} | ||
|
||
export const PainlessScriptParameter = ({ stack }: Props) => { | ||
return ( | ||
<UseField path="script.source" config={getFieldConfig('script')}> | ||
{(scriptField) => { | ||
const error = scriptField.getErrorsMessages(); | ||
const isInvalid = error ? Boolean(error.length) : false; | ||
|
||
const field = ( | ||
<EuiFormRow label={scriptField.label} error={error} isInvalid={isInvalid} fullWidth> | ||
<CodeEditor | ||
languageId="painless" | ||
// 99% width allows the editor to resize horizontally. 100% prevents it from resizing. | ||
width="99%" | ||
height="400px" | ||
value={scriptField.value as string} | ||
onChange={scriptField.setValue} | ||
options={{ | ||
fontSize: 12, | ||
minimap: { | ||
enabled: false, | ||
}, | ||
scrollBeyondLastLine: false, | ||
wordWrap: 'on', | ||
wrappingIndent: 'indent', | ||
automaticLayout: true, | ||
}} | ||
/> | ||
</EuiFormRow> | ||
); | ||
|
||
const fieldTitle = i18n.translate('xpack.idxMgmt.mappingsEditor.painlessScript.title', { | ||
defaultMessage: 'Emitted value', | ||
}); | ||
|
||
const fieldDescription = i18n.translate( | ||
'xpack.idxMgmt.mappingsEditor.painlessScript.description', | ||
{ | ||
defaultMessage: 'Use emit() to define the value of this runtime field.', | ||
} | ||
); | ||
|
||
if (stack) { | ||
return ( | ||
<EditFieldFormRow title={fieldTitle} description={fieldDescription} withToggle={false}> | ||
{field} | ||
</EditFieldFormRow> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiDescribedFormGroup | ||
title={<h3>{fieldTitle}</h3>} | ||
description={fieldDescription} | ||
fullWidth={true} | ||
> | ||
{field} | ||
</EuiDescribedFormGroup> | ||
); | ||
}} | ||
</UseField> | ||
); | ||
}; |
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
96 changes: 96 additions & 0 deletions
96
...ts/mappings_editor/components/document_fields/field_parameters/runtime_type_parameter.tsx
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,96 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiFormRow, | ||
EuiComboBox, | ||
EuiComboBoxOptionOption, | ||
EuiDescribedFormGroup, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
|
||
import { UseField } from '../../../shared_imports'; | ||
import { DataType } from '../../../types'; | ||
import { getFieldConfig } from '../../../lib'; | ||
import { RUNTIME_FIELD_OPTIONS, TYPE_DEFINITION } from '../../../constants'; | ||
import { EditFieldFormRow, FieldDescriptionSection } from '../fields/edit_field'; | ||
|
||
interface Props { | ||
stack?: boolean; | ||
} | ||
|
||
export const RuntimeTypeParameter = ({ stack }: Props) => { | ||
return ( | ||
<UseField path="runtime_type" config={getFieldConfig('runtime_type')}> | ||
{(runtimeTypeField) => { | ||
const { label, value, setValue } = runtimeTypeField; | ||
const typeDefinition = | ||
TYPE_DEFINITION[(value as EuiComboBoxOptionOption[])[0]!.value as DataType]; | ||
|
||
const field = ( | ||
<> | ||
<EuiFormRow label={label} fullWidth> | ||
<EuiComboBox | ||
placeholder={i18n.translate( | ||
'xpack.idxMgmt.mappingsEditor.runtimeType.placeholderLabel', | ||
{ | ||
defaultMessage: 'Select a type', | ||
} | ||
)} | ||
singleSelection={{ asPlainText: true }} | ||
options={RUNTIME_FIELD_OPTIONS} | ||
selectedOptions={value as EuiComboBoxOptionOption[]} | ||
onChange={setValue} | ||
isClearable={false} | ||
fullWidth | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer size="m" /> | ||
|
||
{/* Field description */} | ||
{typeDefinition && ( | ||
<FieldDescriptionSection isMultiField={false}> | ||
{typeDefinition.description?.() as JSX.Element} | ||
</FieldDescriptionSection> | ||
)} | ||
</> | ||
); | ||
|
||
const fieldTitle = i18n.translate('xpack.idxMgmt.mappingsEditor.runtimeType.title', { | ||
defaultMessage: 'Emitted type', | ||
}); | ||
|
||
const fieldDescription = i18n.translate( | ||
'xpack.idxMgmt.mappingsEditor.runtimeType.description', | ||
{ | ||
defaultMessage: 'Select the type of value emitted by the runtime field.', | ||
} | ||
); | ||
|
||
if (stack) { | ||
return ( | ||
<EditFieldFormRow title={fieldTitle} description={fieldDescription} withToggle={false}> | ||
{field} | ||
</EditFieldFormRow> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiDescribedFormGroup | ||
title={<h3>{fieldTitle}</h3>} | ||
description={fieldDescription} | ||
fullWidth={true} | ||
> | ||
{field} | ||
</EuiDescribedFormGroup> | ||
); | ||
}} | ||
</UseField> | ||
); | ||
}; |
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
18 changes: 18 additions & 0 deletions
18
...components/document_fields/fields/create_field/required_parameters_forms/runtime_type.tsx
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,18 @@ | ||
/* | ||
* 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 React from 'react'; | ||
|
||
import { RuntimeTypeParameter, PainlessScriptParameter } from '../../../field_parameters'; | ||
|
||
export const RuntimeTypeRequiredParameters = () => { | ||
return ( | ||
<> | ||
<RuntimeTypeParameter /> | ||
<PainlessScriptParameter /> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.