From e01d538e329f41c7f9e982b6285190521db019f9 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Tue, 6 Oct 2020 06:48:47 -0700 Subject: [PATCH] Revert "Add support for runtime field types to mappings editor. (#77420)" (#79611) This reverts commit 0dc89cb7165a8ed3ec93ce8dadc51d93360ca3ae. --- .../public/application/app_context.tsx | 3 +- .../document_fields/field_parameters/index.ts | 4 - .../painless_script_parameter.tsx | 80 ---------------- .../field_parameters/path_parameter.tsx | 22 ++--- .../runtime_type_parameter.tsx | 96 ------------------- .../term_vector_parameter.tsx | 15 ++- .../fields/create_field/create_field.tsx | 23 ++--- .../required_parameters_forms/index.ts | 4 +- .../runtime_type.tsx | 18 ---- .../edit_field/edit_field_header_form.tsx | 66 +++++-------- .../edit_field/field_description_section.tsx | 3 +- .../fields/field_beta_badge.tsx | 21 ---- .../fields/field_types/index.ts | 2 - .../fields/field_types/runtime_type.tsx | 19 ---- .../fields/fields_list_item.tsx | 7 +- .../search_fields/search_result_item.tsx | 4 +- .../constants/data_types_definition.tsx | 20 ---- .../constants/field_options.tsx | 30 ------ .../constants/parameters_definition.tsx | 48 ---------- .../components/mappings_editor/lib/index.ts | 22 +---- .../mappings_editor/lib/utils.test.ts | 49 +--------- .../components/mappings_editor/lib/utils.ts | 19 +--- .../mappings_editor/shared_imports.ts | 2 - .../mappings_editor/types/document_fields.ts | 9 +- .../public/application/index.tsx | 33 +++---- .../application/mount_management_section.ts | 2 - .../index_management/public/shared_imports.ts | 5 +- 27 files changed, 74 insertions(+), 552 deletions(-) delete mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/painless_script_parameter.tsx delete mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/runtime_type_parameter.tsx delete mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/runtime_type.tsx delete mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_beta_badge.tsx delete mode 100644 x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/runtime_type.tsx diff --git a/x-pack/plugins/index_management/public/application/app_context.tsx b/x-pack/plugins/index_management/public/application/app_context.tsx index 22e6f09907d75..6fbe177d24e06 100644 --- a/x-pack/plugins/index_management/public/application/app_context.tsx +++ b/x-pack/plugins/index_management/public/application/app_context.tsx @@ -8,7 +8,7 @@ import React, { createContext, useContext } from 'react'; import { ScopedHistory } from 'kibana/public'; import { ManagementAppMountParams } from 'src/plugins/management/public'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; -import { CoreSetup, CoreStart } from '../../../../../src/core/public'; +import { CoreStart } from '../../../../../src/core/public'; import { IngestManagerSetup } from '../../../ingest_manager/public'; import { IndexMgmtMetricsType } from '../types'; @@ -34,7 +34,6 @@ export interface AppDependencies { }; history: ScopedHistory; setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; - uiSettings: CoreSetup['uiSettings']; } export const AppContextProvider = ({ diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/index.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/index.ts index c47ea4a884111..b3bf071948956 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/index.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/index.ts @@ -73,10 +73,6 @@ export * from './meta_parameter'; export * from './ignore_above_parameter'; -export { RuntimeTypeParameter } from './runtime_type_parameter'; - -export { PainlessScriptParameter } from './painless_script_parameter'; - export const PARAMETER_SERIALIZERS = [relationsSerializer, dynamicSerializer]; export const PARAMETER_DESERIALIZERS = [relationsDeserializer, dynamicDeserializer]; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/painless_script_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/painless_script_parameter.tsx deleted file mode 100644 index 19746034b530c..0000000000000 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/painless_script_parameter.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 ( - - {(scriptField) => { - const error = scriptField.getErrorsMessages(); - const isInvalid = error ? Boolean(error.length) : false; - - const field = ( - - - - ); - - 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 ( - - {field} - - ); - } - - return ( - {fieldTitle}} - description={fieldDescription} - fullWidth={true} - > - {field} - - ); - }} - - ); -}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/path_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/path_parameter.tsx index 62810df44b5af..6575fe1fac7b8 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/path_parameter.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/path_parameter.tsx @@ -93,17 +93,17 @@ export const PathParameter = ({ field, allFields }: Props) => { <> {!Boolean(suggestedFields.length) && ( <> - + +

+ {i18n.translate( + 'xpack.idxMgmt.mappingsEditor.aliasType.noFieldsAddedWarningMessage', + { + defaultMessage: + 'You need to add at least one field before creating an alias.', + } + )} +

+
)} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/runtime_type_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/runtime_type_parameter.tsx deleted file mode 100644 index 4bdb15af5e7d9..0000000000000 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/runtime_type_parameter.tsx +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 ( - - {(runtimeTypeField) => { - const { label, value, setValue } = runtimeTypeField; - const typeDefinition = - TYPE_DEFINITION[(value as EuiComboBoxOptionOption[])[0]!.value as DataType]; - - const field = ( - <> - - - - - - - {/* Field description */} - {typeDefinition && ( - - {typeDefinition.description?.() as JSX.Element} - - )} - - ); - - 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 ( - - {field} - - ); - } - - return ( - {fieldTitle}} - description={fieldDescription} - fullWidth={true} - > - {field} - - ); - }} - - ); -}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/term_vector_parameter.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/term_vector_parameter.tsx index 69d56032eed6a..6752bb6d6af2b 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/term_vector_parameter.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/term_vector_parameter.tsx @@ -56,17 +56,14 @@ export const TermVectorParameter = ({ field, defaultToggleValue }: Props) => { {formData.term_vector === 'with_positions_offsets' && ( <> - +

+ {i18n.translate('xpack.idxMgmt.mappingsEditor.termVectorFieldWarningMessage', { defaultMessage: 'Setting "With positions and offsets" will double the size of a field’s index.', - } - )} - /> + })} +

+
)} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx index cff2b9af4fd10..a8170b1d59fbb 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/create_field.tsx @@ -14,17 +14,15 @@ import { EuiFlexGroup, EuiFlexItem, EuiOutsideClickDetector, - EuiSpacer, } from '@elastic/eui'; import { useForm, Form, FormDataProvider } from '../../../../shared_imports'; -import { EUI_SIZE, TYPE_DEFINITION } from '../../../../constants'; +import { EUI_SIZE } from '../../../../constants'; import { useDispatch } from '../../../../mappings_state_context'; import { fieldSerializer } from '../../../../lib'; -import { Field, NormalizedFields, MainType } from '../../../../types'; +import { Field, NormalizedFields } from '../../../../types'; import { NameParameter, TypeParameter, SubTypeParameter } from '../../field_parameters'; -import { FieldBetaBadge } from '../field_beta_badge'; -import { getRequiredParametersFormForType } from './required_parameters_forms'; +import { getParametersFormForType } from './required_parameters_forms'; const formWrapper = (props: any) =>
; @@ -197,27 +195,18 @@ export const CreateField = React.memo(function CreateFieldComponent({ {({ type, subType }) => { - const RequiredParametersForm = getRequiredParametersFormForType( + const ParametersForm = getParametersFormForType( type?.[0].value, subType?.[0].value ); - if (!RequiredParametersForm) { + if (!ParametersForm) { return null; } - const typeDefinition = TYPE_DEFINITION[type?.[0].value as MainType]; - return (
- {typeDefinition.isBeta ? ( - <> - - - - ) : null} - - +
); }} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/index.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/index.ts index 5c04b2fbb336c..1112bf99713ed 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/index.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/index.ts @@ -11,7 +11,6 @@ import { AliasTypeRequiredParameters } from './alias_type'; import { TokenCountTypeRequiredParameters } from './token_count_type'; import { ScaledFloatTypeRequiredParameters } from './scaled_float_type'; import { DenseVectorRequiredParameters } from './dense_vector_type'; -import { RuntimeTypeRequiredParameters } from './runtime_type'; export interface ComponentProps { allFields: NormalizedFields['byId']; @@ -22,10 +21,9 @@ const typeToParametersFormMap: { [key in DataType]?: ComponentType } = { token_count: TokenCountTypeRequiredParameters, scaled_float: ScaledFloatTypeRequiredParameters, dense_vector: DenseVectorRequiredParameters, - runtime: RuntimeTypeRequiredParameters, }; -export const getRequiredParametersFormForType = ( +export const getParametersFormForType = ( type: MainType, subType?: SubType ): ComponentType | undefined => diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/runtime_type.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/runtime_type.tsx deleted file mode 100644 index 54907295f8a15..0000000000000 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/create_field/required_parameters_forms/runtime_type.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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 ( - <> - - - - ); -}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx index e91a666cc4221..3b55c5ac076c2 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/edit_field_header_form.tsx @@ -5,13 +5,12 @@ */ import React from 'react'; -import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { FormDataProvider } from '../../../../shared_imports'; -import { MainType, SubType, Field, DataTypeDefinition } from '../../../../types'; +import { MainType, SubType, Field } from '../../../../types'; import { TYPE_DEFINITION } from '../../../../constants'; import { NameParameter, TypeParameter, SubTypeParameter } from '../../field_parameters'; -import { FieldBetaBadge } from '../field_beta_badge'; import { FieldDescriptionSection } from './field_description_section'; interface Props { @@ -20,25 +19,6 @@ interface Props { isMultiField: boolean; } -const getTypeDefinition = (type: MainType, subType: SubType): DataTypeDefinition | undefined => { - if (!type) { - return; - } - - const typeDefinition = TYPE_DEFINITION[type]; - const hasSubType = typeDefinition.subTypes !== undefined; - - if (hasSubType) { - if (subType) { - return TYPE_DEFINITION[subType]; - } - - return; - } - - return typeDefinition; -}; - export const EditFieldHeaderForm = React.memo( ({ defaultValue, isRootLevelField, isMultiField }: Props) => { return ( @@ -76,29 +56,27 @@ export const EditFieldHeaderForm = React.memo( {/* Field description */} - - {({ type, subType }) => { - const typeDefinition = getTypeDefinition( - type[0].value as MainType, - subType && (subType[0].value as SubType) - ); - const description = (typeDefinition?.description?.() as JSX.Element) ?? null; - - return ( - <> - - - {typeDefinition?.isBeta && } - - + + + {({ type, subType }) => { + if (!type) { + return null; + } + const typeDefinition = TYPE_DEFINITION[type[0].value as MainType]; + const hasSubType = typeDefinition.subTypes !== undefined; + + if (hasSubType) { + if (subType) { + const subTypeDefinition = TYPE_DEFINITION[subType as SubType]; + return (subTypeDefinition?.description?.() as JSX.Element) ?? null; + } + return null; + } - - {description} - - - ); - }} - + return typeDefinition.description?.() as JSX.Element; + }} + + ); } diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/field_description_section.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/field_description_section.tsx index 2301f7a47bf2f..2040d7f40d5cb 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/field_description_section.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/edit_field/field_description_section.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { EuiText } from '@elastic/eui'; +import { EuiSpacer, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; interface Props { @@ -19,6 +19,7 @@ export const FieldDescriptionSection = ({ children, isMultiField }: Props) => { return (
+ {children} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_beta_badge.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_beta_badge.tsx deleted file mode 100644 index 99c725e8a00b3..0000000000000 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_beta_badge.tsx +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 { EuiBetaBadge } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -export const FieldBetaBadge = () => { - const betaText = i18n.translate('xpack.idxMgmt.mappingsEditor.fieldBetaBadgeLabel', { - defaultMessage: 'Beta', - }); - - const tooltipText = i18n.translate('xpack.idxMgmt.mappingsEditor.fieldBetaBadgeTooltip', { - defaultMessage: 'This field type is not GA. Please help us by reporting any bugs.', - }); - - return ; -}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/index.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/index.ts index d135d1b81419c..0f9308aa43448 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/index.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/index.ts @@ -31,7 +31,6 @@ import { JoinType } from './join_type'; import { HistogramType } from './histogram_type'; import { ConstantKeywordType } from './constant_keyword_type'; import { RankFeatureType } from './rank_feature_type'; -import { RuntimeType } from './runtime_type'; import { WildcardType } from './wildcard_type'; import { PointType } from './point_type'; import { VersionType } from './version_type'; @@ -62,7 +61,6 @@ const typeToParametersFormMap: { [key in DataType]?: ComponentType } = { histogram: HistogramType, constant_keyword: ConstantKeywordType, rank_feature: RankFeatureType, - runtime: RuntimeType, wildcard: WildcardType, point: PointType, version: VersionType, diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/runtime_type.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/runtime_type.tsx deleted file mode 100644 index dcf5a74e0e304..0000000000000 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/field_types/runtime_type.tsx +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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'; -import { BasicParametersSection } from '../edit_field'; - -export const RuntimeType = () => { - return ( - - - - - ); -}; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list_item.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list_item.tsx index 1939f09fa6762..4ab0ea0fb355b 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list_item.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/fields/fields_list_item.tsx @@ -16,7 +16,7 @@ import { import { i18n } from '@kbn/i18n'; import { NormalizedField, NormalizedFields } from '../../../types'; -import { getTypeLabelFromField } from '../../../lib'; +import { getTypeLabelFromType } from '../../../lib'; import { CHILD_FIELD_INDENT_SIZE, LEFT_PADDING_SIZE_FIELD_ITEM_WRAPPER } from '../../../constants'; import { FieldsList } from './fields_list'; @@ -67,7 +67,6 @@ function FieldListItemComponent( isExpanded, path, } = field; - // When there aren't any "child" fields (the maxNestedDepth === 0), there is no toggle icon on the left of any field. // For that reason, we need to compensate and substract some indent to left align on the page. const substractIndentAmount = maxNestedDepth === 0 ? CHILD_FIELD_INDENT_SIZE * 0.5 : 0; @@ -281,10 +280,10 @@ function FieldListItemComponent( ? i18n.translate('xpack.idxMgmt.mappingsEditor.multiFieldBadgeLabel', { defaultMessage: '{dataType} multi-field', values: { - dataType: getTypeLabelFromField(source), + dataType: getTypeLabelFromType(source.type), }, }) - : getTypeLabelFromField(source)} + : getTypeLabelFromType(source.type)} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/search_fields/search_result_item.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/search_fields/search_result_item.tsx index a4cc4b4776e2b..a2d9a50f28394 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/search_fields/search_result_item.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/search_fields/search_result_item.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { SearchResult } from '../../../types'; import { TYPE_DEFINITION } from '../../../constants'; import { useDispatch } from '../../../mappings_state_context'; -import { getTypeLabelFromField } from '../../../lib'; +import { getTypeLabelFromType } from '../../../lib'; import { DeleteFieldProvider } from '../fields/delete_field_provider'; interface Props { @@ -121,7 +121,7 @@ export const SearchResultItem = React.memo(function FieldListItemFlatComponent({ dataType: TYPE_DEFINITION[source.type].label, }, }) - : getTypeLabelFromField(source)} + : getTypeLabelFromType(source.type)} diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx index 07ca0a69afefb..66be208fbb66b 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/data_types_definition.tsx @@ -13,25 +13,6 @@ import { documentationService } from '../../../services/documentation'; import { MainType, SubType, DataType, DataTypeDefinition } from '../types'; export const TYPE_DEFINITION: { [key in DataType]: DataTypeDefinition } = { - runtime: { - value: 'runtime', - isBeta: true, - label: i18n.translate('xpack.idxMgmt.mappingsEditor.dataType.runtimeFieldDescription', { - defaultMessage: 'Runtime', - }), - // TODO: Add this once the page exists. - // documentation: { - // main: '/runtime_field.html', - // }, - description: () => ( -

- -

- ), - }, text: { value: 'text', label: i18n.translate('xpack.idxMgmt.mappingsEditor.dataType.textDescription', { @@ -944,7 +925,6 @@ export const MAIN_TYPES: MainType[] = [ 'range', 'rank_feature', 'rank_features', - 'runtime', 'search_as_you_type', 'shape', 'text', diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/field_options.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/field_options.tsx index 25fdac5089b86..d16bf68b80e5d 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/field_options.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/field_options.tsx @@ -18,7 +18,6 @@ export const TYPE_NOT_ALLOWED_MULTIFIELD: DataType[] = [ 'object', 'nested', 'alias', - 'runtime', ]; export const FIELD_TYPES_OPTIONS = Object.entries(MAIN_DATA_TYPE_DEFINITION).map( @@ -28,35 +27,6 @@ export const FIELD_TYPES_OPTIONS = Object.entries(MAIN_DATA_TYPE_DEFINITION).map }) ) as ComboBoxOption[]; -export const RUNTIME_FIELD_OPTIONS = [ - { - label: 'Keyword', - value: 'keyword', - }, - { - label: 'Long', - value: 'long', - }, - { - label: 'Double', - value: 'double', - }, - { - label: 'Date', - value: 'date', - }, - { - label: 'IP', - value: 'ip', - }, - { - label: 'Boolean', - value: 'boolean', - }, -] as ComboBoxOption[]; - -export const RUNTIME_FIELD_TYPES = ['keyword', 'long', 'double', 'date', 'ip', 'boolean'] as const; - interface SuperSelectOptionConfig { inputDisplay: string; dropdownDisplay: JSX.Element; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx index 1434b7d4b4429..281b14a25fcb6 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/constants/parameters_definition.tsx @@ -20,7 +20,6 @@ import { import { AliasOption, DataType, - RuntimeType, ComboBoxOption, ParameterName, ParameterDefinition, @@ -28,7 +27,6 @@ import { import { documentationService } from '../../../services/documentation'; import { INDEX_DEFAULT } from './default_values'; import { TYPE_DEFINITION } from './data_types_definition'; -import { RUNTIME_FIELD_OPTIONS } from './field_options'; const { toInt } = fieldFormatters; const { emptyField, containsCharsField, numberGreaterThanField, isJsonField } = fieldValidators; @@ -187,52 +185,6 @@ export const PARAMETERS_DEFINITION: { [key in ParameterName]: ParameterDefinitio }, schema: t.string, }, - runtime_type: { - fieldConfig: { - type: FIELD_TYPES.COMBO_BOX, - label: i18n.translate('xpack.idxMgmt.mappingsEditor.parameters.runtimeTypeLabel', { - defaultMessage: 'Type', - }), - defaultValue: 'keyword', - deserializer: (fieldType: RuntimeType | undefined) => { - if (typeof fieldType === 'string' && Boolean(fieldType)) { - const label = - RUNTIME_FIELD_OPTIONS.find(({ value }) => value === fieldType)?.label ?? fieldType; - return [ - { - label, - value: fieldType, - }, - ]; - } - return []; - }, - serializer: (value: ComboBoxOption[]) => (value.length === 0 ? '' : value[0].value), - }, - schema: t.string, - }, - script: { - fieldConfig: { - defaultValue: '', - type: FIELD_TYPES.TEXT, - label: i18n.translate('xpack.idxMgmt.mappingsEditor.parameters.painlessScriptLabel', { - defaultMessage: 'Script', - }), - validations: [ - { - validator: emptyField( - i18n.translate( - 'xpack.idxMgmt.mappingsEditor.parameters.validations.scriptIsRequiredErrorMessage', - { - defaultMessage: 'Script must emit() a value.', - } - ) - ), - }, - ], - }, - schema: t.string, - }, store: { fieldConfig: { type: FIELD_TYPES.CHECKBOX, diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/index.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/index.ts index 0a59cafdcef47..8cd1bbf0764ab 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/index.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/index.ts @@ -4,27 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -export { - getUniqueId, - getChildFieldsName, - getFieldMeta, - getTypeLabelFromField, - getFieldConfig, - getTypeMetaFromSource, - normalize, - deNormalize, - updateFieldsPathAfterFieldNameChange, - getAllChildFields, - getAllDescendantAliases, - getFieldAncestors, - filterTypesForMultiField, - filterTypesForNonRootFields, - getMaxNestedDepth, - buildFieldTreeFromIds, - shouldDeleteChildFieldsAfterTypeChange, - canUseMappingsEditor, - stripUndefinedValues, -} from './utils'; +export * from './utils'; export * from './serializers'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.test.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.test.ts index e1988c071314e..bc495b05e07b7 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.test.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.test.ts @@ -4,12 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../constants', () => { - const { TYPE_DEFINITION } = jest.requireActual('../constants'); - return { MAIN_DATA_TYPE_DEFINITION: {}, TYPE_DEFINITION }; -}); +jest.mock('../constants', () => ({ MAIN_DATA_TYPE_DEFINITION: {} })); -import { stripUndefinedValues, getTypeLabelFromField } from './utils'; +import { stripUndefinedValues } from './utils'; describe('utils', () => { describe('stripUndefinedValues()', () => { @@ -56,46 +53,4 @@ describe('utils', () => { expect(stripUndefinedValues(dataIN)).toEqual(dataOUT); }); }); - - describe('getTypeLabelFromField()', () => { - test('returns an unprocessed label for non-runtime fields', () => { - expect( - getTypeLabelFromField({ - name: 'testField', - type: 'keyword', - }) - ).toBe('Keyword'); - }); - - test(`returns a label prepended with 'Other' for unrecognized fields`, () => { - expect( - getTypeLabelFromField({ - name: 'testField', - // @ts-ignore - type: 'hyperdrive', - }) - ).toBe('Other: hyperdrive'); - }); - - test("returns a label prepended with 'Runtime' for runtime fields", () => { - expect( - getTypeLabelFromField({ - name: 'testField', - type: 'runtime', - runtime_type: 'keyword', - }) - ).toBe('Runtime Keyword'); - }); - - test("returns a label prepended with 'Runtime Other' for unrecognized runtime fields", () => { - expect( - getTypeLabelFromField({ - name: 'testField', - type: 'runtime', - // @ts-ignore - runtime_type: 'hyperdrive', - }) - ).toBe('Runtime Other: hyperdrive'); - }); - }); }); diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.ts index fd7aa41638505..cbbef8700783c 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/lib/utils.ts @@ -71,23 +71,8 @@ export const getFieldMeta = (field: Field, isMultiField?: boolean): FieldMeta => }; }; -const getTypeLabel = (type?: DataType): string => { - return type && TYPE_DEFINITION[type] - ? TYPE_DEFINITION[type].label - : `${TYPE_DEFINITION.other.label}: ${type}`; -}; - -export const getTypeLabelFromField = (field: Field) => { - const { type, runtime_type: runtimeType } = field; - const typeLabel = getTypeLabel(type); - - if (type === 'runtime') { - const runtimeTypeLabel = getTypeLabel(runtimeType); - return `${typeLabel} ${runtimeTypeLabel}`; - } - - return typeLabel; -}; +export const getTypeLabelFromType = (type: DataType) => + TYPE_DEFINITION[type] ? TYPE_DEFINITION[type].label : `${TYPE_DEFINITION.other.label}: ${type}`; export const getFieldConfig = ( param: ParameterName, diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/shared_imports.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/shared_imports.ts index 54b2486108183..097d039527950 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/shared_imports.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/shared_imports.ts @@ -51,5 +51,3 @@ export { OnJsonEditorUpdateHandler, GlobalFlyout, } from '../../../../../../../src/plugins/es_ui_shared/public'; - -export { CodeEditor } from '../../../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts index ee4dd55a5801f..b1d2915ebb1aa 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/types/document_fields.ts @@ -8,7 +8,7 @@ import { ReactNode } from 'react'; import { GenericObject } from './mappings_editor'; import { FieldConfig } from '../shared_imports'; -import { PARAMETERS_DEFINITION, RUNTIME_FIELD_TYPES } from '../constants'; +import { PARAMETERS_DEFINITION } from '../constants'; export interface DataTypeDefinition { label: string; @@ -19,7 +19,6 @@ export interface DataTypeDefinition { }; subTypes?: { label: string; types: SubType[] }; description?: () => ReactNode; - isBeta?: boolean; } export interface ParameterDefinition { @@ -36,7 +35,6 @@ export interface ParameterDefinition { } export type MainType = - | 'runtime' | 'text' | 'keyword' | 'numeric' @@ -76,8 +74,6 @@ export type SubType = NumericType | RangeType; export type DataType = MainType | SubType; -export type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; - export type NumericType = | 'long' | 'integer' @@ -156,8 +152,6 @@ export type ParameterName = | 'depth_limit' | 'relations' | 'max_shingle_size' - | 'runtime_type' - | 'script' | 'value' | 'meta'; @@ -175,7 +169,6 @@ export interface Fields { interface FieldBasic { name: string; type: DataType; - runtime_type?: DataType; subType?: SubType; properties?: { [key: string]: Omit }; fields?: { [key: string]: Omit }; diff --git a/x-pack/plugins/index_management/public/application/index.tsx b/x-pack/plugins/index_management/public/application/index.tsx index d8b5da8361c43..f881c2e01cefc 100644 --- a/x-pack/plugins/index_management/public/application/index.tsx +++ b/x-pack/plugins/index_management/public/application/index.tsx @@ -11,7 +11,7 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { CoreStart } from '../../../../../src/core/public'; import { API_BASE_PATH } from '../../common'; -import { createKibanaReactContext, GlobalFlyout } from '../shared_imports'; +import { GlobalFlyout } from '../shared_imports'; import { AppContextProvider, AppDependencies } from './app_context'; import { App } from './app'; @@ -30,12 +30,7 @@ export const renderApp = ( const { i18n, docLinks, notifications, application } = core; const { Context: I18nContext } = i18n; - const { services, history, setBreadcrumbs, uiSettings } = dependencies; - - // uiSettings is required by the CodeEditor component used to edit runtime field Painless scripts. - const { Provider: KibanaReactContextProvider } = createKibanaReactContext({ - uiSettings, - }); + const { services, history, setBreadcrumbs } = dependencies; const componentTemplateProviderValues = { httpClient: services.httpService.httpClient, @@ -49,19 +44,17 @@ export const renderApp = ( render( - - - - - - - - - - - - - + + + + + + + + + + + , elem ); diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts index f7b728c875762..6257b68430cf0 100644 --- a/x-pack/plugins/index_management/public/application/mount_management_section.ts +++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts @@ -41,7 +41,6 @@ export async function mountManagementSection( fatalErrors, application, chrome: { docTitle }, - uiSettings, } = core; docTitle.change(PLUGIN.getI18nName(i18n)); @@ -61,7 +60,6 @@ export async function mountManagementSection( services, history, setBreadcrumbs, - uiSettings, }; const unmountAppCallback = renderApp(element, { core, dependencies: appDependencies }); diff --git a/x-pack/plugins/index_management/public/shared_imports.ts b/x-pack/plugins/index_management/public/shared_imports.ts index acb3eb512e2c1..d58545768732e 100644 --- a/x-pack/plugins/index_management/public/shared_imports.ts +++ b/x-pack/plugins/index_management/public/shared_imports.ts @@ -44,7 +44,4 @@ export { export { isJSON } from '../../../../src/plugins/es_ui_shared/static/validators/string'; -export { - createKibanaReactContext, - reactRouterNavigate, -} from '../../../../src/plugins/kibana_react/public'; +export { reactRouterNavigate } from '../../../../src/plugins/kibana_react/public';