diff --git a/x-pack/platform/plugins/private/upgrade_assistant/common/types.ts b/x-pack/platform/plugins/private/upgrade_assistant/common/types.ts index 9304e54560fd2..50568ea85acbd 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/common/types.ts +++ b/x-pack/platform/plugins/private/upgrade_assistant/common/types.ts @@ -203,6 +203,11 @@ export interface ReindexAction { * In future this could be an array of blockers. */ blockerForReindexing?: 'index-closed'; // 'index-closed' can be handled automatically, but requires more resources, user should be warned + + /** + * The transform IDs that are currently targeting this index + */ + transformIds?: string[]; } export interface UnfreezeAction { diff --git a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/container.tsx b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/container.tsx index cda76c81b6e2c..c81ff4f132164 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/container.tsx +++ b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/container.tsx @@ -154,6 +154,7 @@ export const IndexFlyout: React.FunctionComponent = ({ startReadonly={() => { setFlyoutStep('confirmReadonly'); }} + deprecation={deprecation} updateIndexState={updateIndexState} reindexState={reindexState} /> @@ -214,6 +215,7 @@ export const IndexFlyout: React.FunctionComponent = ({ }, [ flyoutStep, correctiveAction?.type, + deprecation, closeFlyout, updateIndexState, reindexState, diff --git a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/es_transform_target_guidance.tsx b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/es_transform_target_guidance.tsx new file mode 100644 index 0000000000000..7a674d6d0bc95 --- /dev/null +++ b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/es_transform_target_guidance.tsx @@ -0,0 +1,79 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; +import { EuiCallOut, EuiLink, EuiText, EuiSpacer } from '@elastic/eui'; +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n-react'; +import type { EnrichedDeprecationInfo } from '../../../../../../../../../common/types'; +import { useAppContext } from '../../../../../../../app_context'; + +interface Props { + deprecation: EnrichedDeprecationInfo; +} + +/** + * We get copy directly from ES. This contains information that applies to indices + * that are read-only or not. + */ +export const ESTransformsTargetGuidance = ({ deprecation }: Props) => { + const { + services: { + core: { http }, + }, + } = useAppContext(); + return ( + <> + + {deprecation.details} + + + +

+ +

+

+ + {i18n.translate( + 'xpack.upgradeAssistant.esDeprecations.indices.indexFlyout.detailsStep.esTransform.migrationGuideLink', + { defaultMessage: 'migration guide' } + )} + + ), + transformsLink: ( + + + + ), + }} + /> +

+
+ + ); +}; diff --git a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.test.tsx b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.test.tsx index 7861ccd9e482f..2b225299b2772 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.test.tsx +++ b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.test.tsx @@ -12,6 +12,7 @@ import type { ReindexState } from '../../../use_reindex'; import type { UpdateIndexState } from '../../../use_update_index'; import { LoadingState } from '../../../../../../types'; import { cloneDeep } from 'lodash'; +import { EnrichedDeprecationInfo } from '../../../../../../../../../common/types'; jest.mock('../../../../../../../app_context', () => { const { docLinksServiceMock } = jest.requireActual('@kbn/core-doc-links-browser-mocks'); @@ -38,6 +39,13 @@ jest.mock('../../../../../../../app_context', () => { }); describe('ReindexDetailsFlyoutStep', () => { + const deprecation: EnrichedDeprecationInfo = { + isCritical: true, + message: 'foo', + resolveDuringUpgrade: false, + type: 'index_settings', + url: 'https://te.st', + }; const defaultReindexState: ReindexState = { loadingState: LoadingState.Success, meta: { @@ -65,6 +73,7 @@ describe('ReindexDetailsFlyoutStep', () => { startReadonly={jest.fn()} reindexState={defaultReindexState} updateIndexState={defaultUpdateIndexState} + deprecation={deprecation} /> ); @@ -206,6 +215,94 @@ describe('ReindexDetailsFlyoutStep', () => { `); }); + it('renders correct guidance for indices with transforms', () => { + const wrapper = shallow( + + ); + expect(wrapper).toMatchInlineSnapshot(` + + + + + + + + + + + + + + + + + + + + + + + + + + + `); + }); + it('renders for readonly indices (warning deprecation)', () => { const props = cloneDeep(defaultReindexState); props.meta.isReadonly = true; @@ -217,6 +314,7 @@ describe('ReindexDetailsFlyoutStep', () => { startReadonly={jest.fn()} reindexState={props} updateIndexState={defaultUpdateIndexState} + deprecation={deprecation} /> ); diff --git a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.tsx b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.tsx index b246081a955e7..0ef7438b38a82 100644 --- a/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.tsx +++ b/x-pack/platform/plugins/private/upgrade_assistant/public/application/components/es_deprecations/deprecation_types/indices/flyout/steps/details/reindex_details_step.tsx @@ -23,7 +23,11 @@ import { import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { ReindexStatus } from '../../../../../../../../../common/types'; +import { + EnrichedDeprecationInfo, + ReindexAction, + ReindexStatus, +} from '../../../../../../../../../common/types'; import { LoadingState } from '../../../../../../types'; import type { ReindexState } from '../../../use_reindex'; import { useAppContext } from '../../../../../../../app_context'; @@ -32,6 +36,7 @@ import { FrozenCallOut } from '../frozen_callout'; import type { UpdateIndexState } from '../../../use_update_index'; import { FetchFailedCallOut } from '../fetch_failed_callout'; import { ReindexingFailedCallOut } from '../reindexing_failed_callout'; +import { ESTransformsTargetGuidance } from './es_transform_target_guidance'; /** * Displays a flyout that shows the details / corrective action for a "reindex" deprecation for a given index. @@ -39,10 +44,18 @@ import { ReindexingFailedCallOut } from '../reindexing_failed_callout'; export const ReindexDetailsFlyoutStep: React.FunctionComponent<{ reindexState: ReindexState; updateIndexState: UpdateIndexState; + deprecation: EnrichedDeprecationInfo; startReindex: () => void; startReadonly: () => void; closeFlyout: () => void; -}> = ({ reindexState, updateIndexState, startReindex, startReadonly, closeFlyout }) => { +}> = ({ + reindexState, + updateIndexState, + deprecation, + startReindex, + startReadonly, + closeFlyout, +}) => { const { services: { api, @@ -57,6 +70,8 @@ export const ReindexDetailsFlyoutStep: React.FunctionComponent<{ const isCompleted = reindexStatus === ReindexStatus.completed || updateIndexStatus === 'complete'; const hasFetchFailed = reindexStatus === ReindexStatus.fetchFailed; const hasReindexingFailed = reindexStatus === ReindexStatus.failed; + const correctiveAction = deprecation.correctiveAction as ReindexAction | undefined; + const isESTransformTarget = !!correctiveAction?.transformIds?.length; const { data: nodes } = api.useLoadNodeDiskSpace(); @@ -145,7 +160,8 @@ export const ReindexDetailsFlyoutStep: React.FunctionComponent<{

)} - {!meta.isReadonly && ( + {isESTransformTarget && } + {!meta.isReadonly && !isESTransformTarget && (

- {!meta.isReadonly && !hasFetchFailed && !isCompleted && hasRequiredPrivileges && ( - - - - - - )} + {!meta.isReadonly && + !hasFetchFailed && + !isCompleted && + hasRequiredPrivileges && + !isESTransformTarget && ( + + + + + + )} {!hasFetchFailed && !isCompleted && hasRequiredPrivileges && (