diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx index 77b0372e24994..b99d828b8bbd0 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public/context'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock'; import { licensingMock } from '../../../../licensing/public/mocks'; import { App } from '../../../public/application/app'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts index 36f04be3b30b1..18af96dd2804b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts @@ -5,15 +5,17 @@ * 2.0. */ +import { act } from 'react-dom/test-utils'; + +import { getDefaultHotPhasePolicy, POLICY_NAME } from '../edit_policy/constants'; +import { setupEnvironment } from '../helpers'; + import { AppTestBed, getDoubleEncodedPolicyEditPath, getEncodedPolicyEditPath, setup, } from './app.helpers'; -import { setupEnvironment } from '../helpers/setup_environment'; -import { getDefaultHotPhasePolicy, POLICY_NAME } from '../edit_policy/constants'; -import { act } from 'react-dom/test-utils'; const SPECIAL_CHARS_NAME = 'test?#$+=&@:'; const PERCENT_SIGN_NAME = 'test%'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx index 58da73942000d..6f1c58b2e9b18 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx @@ -8,8 +8,9 @@ import { TestBedConfig } from '@kbn/test/jest'; import { AppServicesContext } from '../../../public/types'; +import { Phase } from '../../../common/types'; + import { - Phase, createNodeAllocationActions, createFormToggleAction, createFormSetValueAction, @@ -27,7 +28,6 @@ import { createReadonlyActions, createIndexPriorityActions, } from '../helpers'; - import { initTestBed } from './init_test_bed'; type SetupReturn = ReturnType; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts index 6403cfead8bd0..0c24101461f24 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/delete_phase.test.ts @@ -5,16 +5,16 @@ * 2.0. */ +import { act } from 'react-dom/test-utils'; +import { API_BASE_PATH } from '../../../../common/constants'; +import { setupEnvironment } from '../../helpers'; +import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; import { DELETE_PHASE_POLICY, getDefaultHotPhasePolicy, NEW_SNAPSHOT_POLICY_NAME, SNAPSHOT_POLICY_NAME, } from '../constants'; -import { act } from 'react-dom/test-utils'; -import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { API_BASE_PATH } from '../../../../common/constants'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' delete phase', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts index 3736e9c43e269..982377e2a0365 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' frozen phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts index 7ca68bd76759e..136865329eb50 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { CloudNodeAllocationTestBed, setupCloudNodeAllocation, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts index 3b968c1dca4ab..e2093e04b7779 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cold_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { NodeAllocationTestBed, setupColdPhaseNodeAllocation } from './cold_phase.helpers'; describe(' node allocation in the cold phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts index d45e1cfe9567b..cac6c174b769e 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/general_behavior.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { GeneralNodeAllocationTestBed, setupGeneralNodeAllocation, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts index 1a1ed988d266e..8d4d0afcf052d 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/warm_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../../helpers/setup_environment'; +import { setupEnvironment } from '../../../helpers'; import { NodeAllocationTestBed, setupWarmPhaseNodeAllocation } from './warm_phase.helpers'; describe(' node allocation in the warm phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts index de9a1b403ad33..1cb895e9ac86a 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/request_flyout.test.ts @@ -6,8 +6,8 @@ */ import { act } from 'react-dom/test-utils'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' request flyout', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts index b58fe4086c7f0..8e9586e52577b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/rollover.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' rollover', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts index 21a76b16c17ef..d400966cdae38 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/searchable_snapshots.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { licensingMock } from '../../../../../licensing/public/mocks'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { getDefaultHotPhasePolicy } from '../constants'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts index 5a117caa99378..a4f2a24bcee8b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/timeline.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' timeline', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts index 8ec2f2e1b4598..ae9f306483820 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/warm_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' warm phase', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts index 669bcfdd34f63..9a14571c6ec3b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/cold_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' cold phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts index 5c70a9025df67..0a047714bd345 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/error_indicators.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' error indicators', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts index 879aab872b19b..296b128eb8f52 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/hot_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' hot phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts index 41d2b6d166dce..08b794466da49 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/policy_name_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; import { getGeneratedPolicies } from '../constants'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts index c164605e5cd4b..ac11e8a162e02 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/timing.test.ts @@ -8,8 +8,9 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; +import { PhaseWithTiming } from '../../../../common/types'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { setupEnvironment } from '../../helpers/setup_environment'; describe(' timing validation', () => { let testBed: EditPolicyTestBed; @@ -69,12 +70,12 @@ describe(' timing validation', () => { ['warm', 'cold', 'delete', 'frozen'].forEach((phase: string) => { const { name, value, error } = testConfig; test(`${phase}: ${name}`, async () => { - await actions.togglePhase(phase as 'warm' | 'cold' | 'delete' | 'frozen'); + await actions.togglePhase(phase as PhaseWithTiming); // 1. We first set as dummy value to have a starting min_age value - await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue('111'); + await actions[phase as PhaseWithTiming].setMinAgeValue('111'); // 2. At this point we are sure there will be a change of value and that any validation // will be displayed under the field. - await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].setMinAgeValue(value); + await actions[phase as PhaseWithTiming].setMinAgeValue(value); actions.errors.waitForValidation(); diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts index 70794491d4edd..bef99ea8cb891 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/warm_phase_validation.test.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { setupEnvironment } from '../../helpers'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; describe(' warm phase validation', () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts index dfc81e9e0d9d7..8c345cf784f9f 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts @@ -6,14 +6,14 @@ */ import { act } from 'react-dom/test-utils'; -import { setupEnvironment } from '../../helpers/setup_environment'; +import { licensingMock } from '../../../../../licensing/public/mocks'; +import { setupEnvironment } from '../../helpers'; import { getDefaultHotPhasePolicy, POLICY_WITH_INCLUDE_EXCLUDE, POLICY_WITH_KNOWN_AND_UNKNOWN_FIELDS, } from '../constants'; import { EditPolicyTestBed, setup } from '../edit_policy.helpers'; -import { licensingMock } from '../../../../../licensing/public/mocks'; describe(' serialization', () => { let testBed: EditPolicyTestBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts index 8d5708950a75f..a92747a95a2ca 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; const createWaitForValidationAction = (testBed: TestBed) => () => { const { component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts index 61b16d18648f5..a7e4983165bac 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts @@ -7,9 +7,9 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; const createFormCheckboxAction = (testBed: TestBed, dataTestSubject: string) => async ( checked: boolean diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts index 87b03ff4e1deb..ad3d9d3bfbcb8 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/freeze_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; -import { Phase } from '../types'; export const createFreezeActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts index a0423c12be5c3..3b48da2a0c69f 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createIndexPriorityActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts index 4a2491f3561ee..551474c8b16e6 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createMinAgeActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts index b4b97b7c88a5e..7c0f8fea7299d 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; import { DataTierAllocationType } from '../../../../public/application/sections/edit_policy/types'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; export const createNodeAllocationActions = (testBed: TestBed, phase: Phase) => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts index ee9161c91209e..b76143eccf1f2 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts @@ -6,8 +6,8 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; -import { Phase } from '../types'; export const createReadonlyActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts index d7ccd32694759..f1a64c3943511 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; export const createSearchableSnapshotActions = (testBed: TestBed, phase: Phase) => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts index cabd3012001b7..b07d7783379fb 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/set_replicas_action.ts @@ -7,7 +7,7 @@ import { TestBed } from '@kbn/test/jest'; -import { Phase } from '../types'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts index 9d227ef2624a4..0531850384124 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; +import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; -import { Phase } from '../types'; export const createShrinkActions = (testBed: TestBed, phase: Phase) => { const { exists } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts index fb1575d05bdef..a0bed0e1644e6 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts @@ -6,9 +6,9 @@ */ import { TestBed } from '@kbn/test/jest'; - import { act } from 'react-dom/test-utils'; -import { Phase } from '../types'; + +import { Phase } from '../../../../common/types'; const toggleDeletePhase = async (testBed: TestBed) => { const { find, component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts index 5b2e1827cd6e8..f9cd1f27b72be 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/index.ts @@ -5,6 +5,6 @@ * 2.0. */ -export { Phase } from './types'; - export * from './actions'; + +export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts deleted file mode 100644 index 644ada96a9f05..0000000000000 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/types.ts +++ /dev/null @@ -1,10 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { Phases } from '../../../common/types'; - -export type Phase = keyof Phases; diff --git a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts index 385751f31d5bc..b08f87e5a172b 100644 --- a/x-pack/plugins/index_lifecycle_management/common/types/policies.ts +++ b/x-pack/plugins/index_lifecycle_management/common/types/policies.ts @@ -7,8 +7,14 @@ import { Index as IndexInterface } from '../../../index_management/common/types'; +export type Phase = keyof Phases; + export type PhaseWithAllocation = 'warm' | 'cold'; +export type PhaseWithTiming = keyof Omit; + +export type PhaseExceptDelete = keyof Omit; + export interface SerializedPolicy { name: string; phases: Phases; @@ -22,8 +28,6 @@ export interface Phases { delete?: SerializedDeletePhase; } -export type PhasesExceptDelete = keyof Omit; - export interface PolicyFromES { modified_date: string; name: string; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx index 22422ceab8a04..0428c2939050d 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phase_footer/phase_footer.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { EuiText, EuiButtonGroup, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { PhasesExceptDelete } from '../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../common/types'; import { usePhaseTimings } from '../../form'; @@ -32,7 +32,7 @@ const keepDataLabel = i18n.translate( ); interface Props { - phase: PhasesExceptDelete; + phase: PhaseExceptDelete; } export const PhaseFooter: FunctionComponent = ({ phase }) => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx index 040baf3625eb8..f5ab67c0b3ee7 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/phase/phase.tsx @@ -20,7 +20,7 @@ import { import { get } from 'lodash'; import { FormattedMessage } from '@kbn/i18n/react'; -import { PhasesExceptDelete } from '../../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../../common/types'; import { ToggleField, useFormData } from '../../../../../../shared_imports'; import { i18nTexts } from '../../../i18n_texts'; import { FormInternal } from '../../../types'; @@ -33,7 +33,7 @@ import { PhaseErrorIndicator } from './phase_error_indicator'; import './phase.scss'; interface Props { - phase: PhasesExceptDelete; + phase: PhaseExceptDelete; /** * Settings that should always be visible on the phase when it is enabled. */ diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx index 47d2aa6ba92df..0f5288df36119 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/index_priority_field.tsx @@ -10,15 +10,16 @@ import React, { FunctionComponent, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, EuiTextColor } from '@elastic/eui'; -import { NumericField } from '../../../../../../shared_imports'; +import { PhaseExceptDelete } from '../../../../../../../common/types'; +import { NumericField } from '../../../../../../shared_imports'; import { useEditPolicyContext } from '../../../edit_policy_context'; -import { UseField } from '../../../form'; +import { UseField } from '../../../form'; import { LearnMoreLink, DescribedFormRow } from '../..'; interface Props { - phase: 'hot' | 'warm' | 'cold' | 'frozen'; + phase: PhaseExceptDelete; } export const IndexPriorityField: FunctionComponent = ({ phase }) => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 136a37140cca7..ad92ef2d44479 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -21,13 +21,12 @@ import { EuiIconTip, } from '@elastic/eui'; +import { PhaseWithTiming } from '../../../../../../../../common/types'; import { getFieldValidityAndErrorMessage, useFormData } from '../../../../../../../shared_imports'; import { UseField, useConfiguration, useGlobalFields } from '../../../../form'; import { getPhaseMinAgeInMilliseconds } from '../../../../lib'; import { getUnitsAriaLabelForPhase, getTimingLabelForPhase } from './util'; -type PhaseWithMinAgeAction = 'warm' | 'cold' | 'delete'; - const i18nTexts = { daysOptionLabel: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.daysOptionLabel', { defaultMessage: 'days', @@ -77,7 +76,7 @@ const i18nTexts = { }; interface Props { - phase: PhaseWithMinAgeAction; + phase: PhaseWithTiming; } export const MinAgeField: FunctionComponent = ({ phase }): React.ReactElement => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts index a626a0a62f551..5f1b98c6dbda2 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/util.ts @@ -6,12 +6,9 @@ */ import { i18n } from '@kbn/i18n'; -import { Phases } from '../../../../../../../../common/types'; +import { PhaseWithTiming } from '../../../../../../../../common/types'; -type PhaseWithMinAgeAction = 'warm' | 'cold' | 'delete'; - -export function getUnitsAriaLabelForPhase(phase: keyof Phases) { - // NOTE: Hot phase isn't necessary, because indices begin in the hot phase. +export function getUnitsAriaLabelForPhase(phase: PhaseWithTiming) { switch (phase) { case 'warm': return i18n.translate( @@ -29,6 +26,14 @@ export function getUnitsAriaLabelForPhase(phase: keyof Phases) { } ); + case 'frozen': + return i18n.translate( + 'xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeUnitsAriaLabel', + { + defaultMessage: 'Units for timing of frozen phase', + } + ); + case 'delete': return i18n.translate( 'xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeUnitsAriaLabel', @@ -38,8 +43,7 @@ export function getUnitsAriaLabelForPhase(phase: keyof Phases) { ); } } -export function getTimingLabelForPhase(phase: PhaseWithMinAgeAction) { - // NOTE: Hot phase isn't necessary, because indices begin in the hot phase. +export function getTimingLabelForPhase(phase: PhaseWithTiming) { switch (phase) { case 'warm': return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseWarm.minimumAgeLabel', { @@ -51,6 +55,11 @@ export function getTimingLabelForPhase(phase: PhaseWithMinAgeAction) { defaultMessage: 'Timing for cold phase', }); + case 'frozen': + return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeLabel', { + defaultMessage: 'Timing for frozen phase', + }); + case 'delete': return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeLabel', { defaultMessage: 'Timing for delete phase', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx index 6edc6568ef766..de5c258ab82fa 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import React, { FunctionComponent, memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiText, EuiIconTip } from '@elastic/eui'; -import { PhasesExceptDelete } from '../../../../../../common/types'; +import { PhaseExceptDelete } from '../../../../../../common/types'; import { calculateRelativeFromAbsoluteMilliseconds, @@ -136,7 +136,7 @@ export const Timeline: FunctionComponent = memo( const widths = calculateWidths(phaseAgeInMilliseconds); - const getDurationInPhaseContent = (phase: PhasesExceptDelete): string | React.ReactNode => + const getDurationInPhaseContent = (phase: PhaseExceptDelete): string | React.ReactNode => phaseAgeInMilliseconds.phases[phase] === Infinity ? ( ) : null; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts index f24d350432d80..c26f54cbb6f5a 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts @@ -7,10 +7,10 @@ import { i18n } from '@kbn/i18n'; +import { PhaseExceptDelete, PhaseWithTiming } from '../../../../../common/types'; import { FormSchema, fieldValidators } from '../../../../shared_imports'; import { defaultIndexPriority } from '../../../constants'; import { ROLLOVER_FORM_PATHS, CLOUD_DEFAULT_REPO } from '../constants'; -import { MinAgePhase } from '../types'; import { i18nTexts } from '../i18n_texts'; import { ifExistsNumberGreaterThanZero, @@ -107,8 +107,8 @@ const numberOfShardsField = { serializer: serializers.stringToNumber, }; -const getPriorityField = (phase: 'hot' | 'warm' | 'cold' | 'frozen') => ({ - defaultValue: defaultIndexPriority[phase] as any, +const getPriorityField = (phase: PhaseExceptDelete) => ({ + defaultValue: defaultIndexPriority[phase], label: i18nTexts.editPolicy.indexPriorityFieldLabel, validations: [ { @@ -119,7 +119,7 @@ const getPriorityField = (phase: 'hot' | 'warm' | 'cold' | 'frozen') => ({ serializer: serializers.stringToNumber, }); -const getMinAgeField = (phase: MinAgePhase, defaultValue?: string) => ({ +const getMinAgeField = (phase: PhaseWithTiming, defaultValue?: string) => ({ defaultValue, // By passing an empty array we make sure to *not* trigger the validation when the field value changes. // The validation will be triggered when the millisecond variant (in the _meta) is updated (in sync) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts index b39b3f3cd4226..892e40f80f4b8 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/validations.ts @@ -16,8 +16,8 @@ import { import { ROLLOVER_FORM_PATHS } from '../constants'; import { i18nTexts } from '../i18n_texts'; -import { PolicyFromES } from '../../../../../common/types'; -import { FormInternal, MinAgePhase } from '../types'; +import { PhaseWithTiming, PolicyFromES } from '../../../../../common/types'; +import { FormInternal } from '../types'; const { numberGreaterThanField, containsCharsField, emptyField, startsWithField } = fieldValidators; @@ -164,7 +164,7 @@ export const createPolicyNameValidations = ({ * For example, the user can't define '5 days' for cold phase if the * warm phase is set to '10 days'. */ -export const minAgeGreaterThanPreviousPhase = (phase: MinAgePhase) => ({ +export const minAgeGreaterThanPreviousPhase = (phase: PhaseWithTiming) => ({ formData, }: { formData: Record; @@ -173,7 +173,7 @@ export const minAgeGreaterThanPreviousPhase = (phase: MinAgePhase) => ({ return; } - const getValueFor = (_phase: MinAgePhase) => { + const getValueFor = (_phase: PhaseWithTiming) => { const milli = formData[`_meta.${_phase}.minAgeToMilliSeconds`]; const esFormat = diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts index 9d55f542db4c4..71e2741c27cdc 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts @@ -22,17 +22,16 @@ import moment from 'moment'; -import { splitSizeAndUnits } from '../../../lib/policies'; +import { Phase, PhaseWithTiming } from '../../../../../common/types'; -import { FormInternal, MinAgePhase } from '../types'; +import { splitSizeAndUnits } from '../../../lib/policies'; +import { FormInternal } from '../types'; /* -===- Private functions and types -===- */ -type Phase = 'hot' | MinAgePhase; - const phaseOrder: Phase[] = ['hot', 'warm', 'cold', 'frozen', 'delete']; -const getMinAge = (phase: MinAgePhase, formData: FormInternal) => ({ +const getMinAge = (phase: PhaseWithTiming, formData: FormInternal) => ({ min_age: formData.phases?.[phase]?.min_age ? formData.phases[phase]!.min_age! + formData._meta[phase].minAgeUnit : '0ms', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts index 987cbbcfde45b..ba7d31cf6da49 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/types.ts @@ -18,8 +18,6 @@ export interface MinAgeField { minAgeToMilliSeconds: number; } -export type MinAgePhase = 'warm' | 'cold' | 'frozen' | 'delete'; - export interface ForcemergeFields { bestCompression: boolean; }