diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
index 99e6984476f84..e2b643b99e3cf 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
@@ -30,10 +30,7 @@ const i18nTexts = {
};
export const ColdPhase: FunctionComponent = () => {
- const {
- isUsingSearchableSnapshotInHotPhase,
- isUsingSearchableSnapshotInColdPhase,
- } = useConfigurationIssues();
+ const { isUsingSearchableSnapshotInHotPhase, canUseRollupInColdPhase } = useConfigurationIssues();
return (
}>
@@ -48,9 +45,7 @@ export const ColdPhase: FunctionComponent = () => {
phase="cold"
/>
- {!isUsingSearchableSnapshotInColdPhase && !isUsingSearchableSnapshotInHotPhase && (
-
- )}
+ {canUseRollupInColdPhase && }
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.container.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.container.tsx
index a9f4320e4f17e..c8fbe1b0aa5a9 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.container.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.container.tsx
@@ -9,6 +9,7 @@ import React, { FunctionComponent } from 'react';
import { get } from 'lodash';
import { useFormData, FormHook } from '../../../../../shared_imports';
+
import { RollupWizard as RollupWizardView, Props as RollupWizardViewProps } from './rollup_wizard';
import { FieldChooserProvider } from './field_chooser_context';
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.tsx
index 8380d885d2ef8..302704f46704a 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/rollup_wizard.tsx
@@ -132,6 +132,7 @@ const deriveStepFields = (value: RollupAction['config'] | undefined): StepFields
);
};
+// TODO: This component should be migrated to use the ES UI generic FormWizard component that takes care functionality for navigating to steps.
export class RollupWizard extends Component {
lastIndexPatternValidationTime: number;
// @ts-ignore
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/steps/components/field_chooser/field_chooser.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/steps/components/field_chooser/field_chooser.tsx
index 3492ce37960da..f1d116f729eb2 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/steps/components/field_chooser/field_chooser.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/rollup_wizard/steps/components/field_chooser/field_chooser.tsx
@@ -330,7 +330,7 @@ export class FieldChooser extends Component {
return (
- {currentView.id === 'rollupAction' && hasCurrentRollupField && (
+ {currentView.id === 'rollupAction' && (
= ({ history }) => {
}}
onDone={(rollupAction) => {
const { phase } = currentView;
- const fieldPath = `phases.${phase}.actions.rollup.config`;
- const rollupField = form.getFields()[fieldPath];
+ const rollupConfigPath = `phases.${phase}.actions.rollup.config`;
+ const rollupField = form.getFields()[rollupConfigPath];
const newCurrentPolicy = cloneDeep({
...currentPolicy,
name: originalPolicyName,
});
- set(newCurrentPolicy, fieldPath, rollupAction);
+ set(newCurrentPolicy, rollupConfigPath, rollupAction);
setCurrentPolicy(newCurrentPolicy);
rollupField.setValue(rollupAction);
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_issues_context.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_issues_context.tsx
index fae017a20b26b..7e3621c4df4ff 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_issues_context.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_issues_context.tsx
@@ -6,12 +6,14 @@
*/
import { get } from 'lodash';
-import React, { FunctionComponent, createContext, useContext } from 'react';
+import React, { FunctionComponent, createContext, useContext, useEffect } from 'react';
import { useFormData } from '../../../../shared_imports';
import { isUsingDefaultRolloverPath, isUsingCustomRolloverPath } from '../constants';
+import { useNavigationContext } from '../navigation';
+
export interface ConfigurationIssues {
/**
* Whether the serialized policy will use rollover. This blocks certain actions in
@@ -26,6 +28,8 @@ export interface ConfigurationIssues {
*/
isUsingSearchableSnapshotInHotPhase: boolean;
isUsingSearchableSnapshotInColdPhase: boolean;
+
+ canUseRollupInColdPhase: boolean;
}
const ConfigurationIssuesContext = createContext(null as any);
@@ -37,6 +41,7 @@ const pathToColdPhaseSearchableSnapshot =
'phases.cold.actions.searchable_snapshot.snapshot_repository';
export const ConfigurationIssuesProvider: FunctionComponent = ({ children }) => {
+ const { setIsColdRollupActionBlocked } = useNavigationContext();
const [formData] = useFormData({
watch: [
pathToHotPhaseSearchableSnapshot,
@@ -49,14 +54,25 @@ export const ConfigurationIssuesProvider: FunctionComponent = ({ children }) =>
// Provide default value, as path may become undefined if removed from the DOM
const isUsingCustomRollover = get(formData, isUsingCustomRolloverPath, true);
+ const isUsingSearchableSnapshotInHotPhase =
+ get(formData, pathToHotPhaseSearchableSnapshot) != null;
+ const isUsingSearchableSnapshotInColdPhase =
+ get(formData, pathToColdPhaseSearchableSnapshot) != null;
+
+ const canUseRollupInColdPhase =
+ !isUsingSearchableSnapshotInHotPhase && !isUsingSearchableSnapshotInColdPhase;
+
+ useEffect(() => {
+ setIsColdRollupActionBlocked(!canUseRollupInColdPhase);
+ }, [setIsColdRollupActionBlocked, canUseRollupInColdPhase]);
+
return (
{children}
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/navigation/navigation_context.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/navigation/navigation_context.tsx
index 40f4982d9e79b..496c6442a7aca 100644
--- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/navigation/navigation_context.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/navigation/navigation_context.tsx
@@ -8,6 +8,7 @@
import React, {
FunctionComponent,
createContext,
+ useState,
useContext,
useMemo,
useEffect,
@@ -27,16 +28,16 @@ export type PolicyView = { id: 'policy' } | { id: 'rollupAction'; phase: 'hot' |
interface ContextValue {
currentView: PolicyView;
goToPolicyView: (scrollToFieldWithId?: string) => void;
+ setIsColdRollupActionBlocked: (value: boolean) => void;
}
-const NavigationContext = createContext({
- currentView: { id: 'policy' },
- goToPolicyView: () => {},
-});
+const NavigationContext = createContext(null);
export const NavigationContextProvider: FunctionComponent = ({ children }) => {
const { policyName } = useEditPolicyContext();
+ const [isColdRollupActionBlocked, setIsColdRollupActionBlocked] = useState(true);
+
const { search } = useLocation();
const history = useHistory();
@@ -45,12 +46,14 @@ export const NavigationContextProvider: FunctionComponent = ({ children }) => {
} = useKibana();
const currentView = useMemo(() => {
- const { rollup } = qs.parse(search) as { rollup: 'hot' | 'cold' };
- if (rollup) {
+ const { rollup } = qs.parse(search) as { rollup?: 'hot' | 'cold' };
+ const rollupBlocked = rollup === 'cold' && isColdRollupActionBlocked;
+ if (rollup && !rollupBlocked) {
return { id: 'rollupAction', phase: rollup };
}
+
return { id: 'policy' };
- }, [search]);
+ }, [search, isColdRollupActionBlocked]);
const { id: currentViewId } = currentView;
@@ -83,7 +86,9 @@ export const NavigationContextProvider: FunctionComponent = ({ children }) => {
}, [breadcrumbService, search, currentViewId, policyName]);
return (
-
+
{children}
);