From 9ecc2076515e3d15e5e0bb5b0a126f069c76600e Mon Sep 17 00:00:00 2001 From: Sander Philipse Date: Thu, 25 Apr 2024 17:08:57 +0200 Subject: [PATCH 1/2] [Search] Fix mapping tab breaking docLinks and refresh --- .../search_index/index_mappings.tsx | 20 +++++++++++++++---- .../index_mapping_with_context.tsx | 2 ++ .../index_mappings_embeddable.tsx | 6 ------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx index b7e5a117c638f..b35415cc2e0e0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_mappings.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { useActions, useValues } from 'kea'; @@ -46,7 +46,9 @@ import './index_mappings.scss'; export const SearchIndexIndexMappings: React.FC = () => { const { indexName } = useValues(IndexNameLogic); const { hasDocumentLevelSecurityFeature, isHiddenIndex } = useValues(IndexViewLogic); - const { indexMappingComponent: IndexMappingComponent, productFeatures } = useValues(KibanaLogic); + const { indexMappingComponent, productFeatures } = useValues(KibanaLogic); + + const IndexMappingComponent = useMemo(() => indexMappingComponent, []); const [selectedIndexType, setSelectedIndexType] = useState('content-index'); @@ -154,7 +156,12 @@ export const SearchIndexIndexMappings: React.FC = () => {

- + {i18n.translate('xpack.enterpriseSearch.content.searchIndex.mappings.docLink', { defaultMessage: 'Learn how to customize index mappings and settings', })} @@ -187,7 +194,12 @@ export const SearchIndexIndexMappings: React.FC = () => {

- + {i18n.translate('xpack.enterpriseSearch.content.searchIndex.transform.docLink', { defaultMessage: 'Learn more', })} diff --git a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mapping_with_context.tsx b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mapping_with_context.tsx index 5f8eb213a2af5..7aa0f07e8e492 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mapping_with_context.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mapping_with_context.tsx @@ -6,6 +6,7 @@ */ import React from 'react'; +import { documentationService } from '../../../../services'; import { UIM_APP_NAME } from '../../../../../../common/constants/ui_metric'; import { httpService } from '../../../../services/http'; import { notificationService } from '../../../../services/notification'; @@ -28,6 +29,7 @@ export const IndexMappingWithContext: React.FC = ( httpService.setup(core.http); notificationService.setup(core.notifications); } + documentationService.setup(core.docLinks); const newDependencies: AppDependencies = { ...dependencies, diff --git a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mappings_embeddable.tsx b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mappings_embeddable.tsx index 9102ba14859cd..8a9d4c1b2c4f4 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mappings_embeddable.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/index_mappings_embeddable.tsx @@ -10,12 +10,6 @@ import { dynamic } from '@kbn/shared-ux-utility'; import React, { Suspense, ComponentType } from 'react'; import { IndexMappingWithContextProps } from './index_mapping_with_context_types'; -// const IndexMappingWithContext = lazy>(async () => { -// return { -// default: (await import('./index_mapping_with_context')).IndexMappingWithContext, -// }; -// }); - const IndexMappingWithContext = dynamic>(() => import('./index_mapping_with_context').then((mod) => ({ default: mod.IndexMappingWithContext })) ); From 9e6976074c293f3f43ce0531e1f25db1794ca8d9 Mon Sep 17 00:00:00 2001 From: Sander Philipse Date: Thu, 25 Apr 2024 18:27:14 +0200 Subject: [PATCH 2/2] Fix unnecessary label translation --- .../field_parameters/select_inference_id.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/select_inference_id.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/select_inference_id.tsx index da1a5c4c33fc8..997920f5e8581 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/select_inference_id.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/document_fields/field_parameters/select_inference_id.tsx @@ -141,7 +141,7 @@ export const SelectInferenceId = ({ onChange, 'data-test-subj': dataTestSubj }: return subscription.unsubscribe; }, [subscribe, onChange]); - const selectedOptions = options.filter((option) => option.checked).find((k) => k.label); + const selectedOptionLabel = options.find((option) => option.checked)?.label; const [isInferencePopoverVisible, setIsInferencePopoverVisible] = useState(false); const [inferenceEndpointError, setInferenceEndpointError] = useState( undefined @@ -180,11 +180,13 @@ export const SelectInferenceId = ({ onChange, 'data-test-subj': dataTestSubj }: setIsInferencePopoverVisible(!isInferencePopoverVisible); }} > - + {selectedOptionLabel || + i18n.translate( + 'xpack.idxMgmt.mappingsEditor.parameters.inferenceId.popover.defaultLabel', + { + defaultMessage: 'No model selected', + } + )} )}