diff --git a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.container.js b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.container.js
index 4e68a51aee931..3f98f4a24f037 100644
--- a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.container.js
+++ b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.container.js
@@ -4,16 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
-
-
import { connect } from 'react-redux';
-import { WarmPhase as PresentationComponent } from './warm_phase';
+
import {
getPhase,
} from '../../../../store/selectors';
import { setPhaseData } from '../../../../store/actions';
import { PHASE_WARM, PHASE_HOT, PHASE_ROLLOVER_ENABLED } from '../../../../constants';
+import { WarmPhase as PresentationComponent } from './warm_phase';
export const WarmPhase = connect(
state => ({
diff --git a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.js b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.js
index b25e3db0cedab..54794f8f4e095 100644
--- a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.js
+++ b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/components/warm_phase/warm_phase.js
@@ -40,6 +40,7 @@ class WarmPhaseUi extends PureComponent {
isShowingErrors: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
};
+
render() {
const {
setPhaseData,
@@ -50,18 +51,22 @@ class WarmPhaseUi extends PureComponent {
hotPhaseRolloverEnabled,
intl,
} = this.props;
+
const shrinkLabel = intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.warmPhase.shrinkIndexLabel',
defaultMessage: 'Shrink index',
});
+
const moveToWarmPhaseOnRolloverLabel = intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.warmPhase.moveToWarmPhaseOnRolloverLabel',
defaultMessage: 'Move to warm phase on rollover',
});
+
const forcemergeLabel = intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.warmPhase.forceMergeDataLabel',
defaultMessage: 'Force merge data',
});
+
return (
+
{phaseData[PHASE_SHRINK_ENABLED] ? (
diff --git a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.container.js b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.container.js
index 5b3a97bb13213..e497446b71b3e 100644
--- a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.container.js
+++ b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.container.js
@@ -5,7 +5,7 @@
*/
import { connect } from 'react-redux';
-import { EditPolicy as PresentationComponent } from './edit_policy';
+
import {
getSaveAsNewPolicy,
getSelectedPolicy,
@@ -16,6 +16,7 @@ import {
getIsNewPolicy,
getSelectedOriginalPolicyName
} from '../../store/selectors';
+
import {
setSelectedPolicy,
setSelectedPolicyName,
@@ -23,7 +24,9 @@ import {
saveLifecyclePolicy,
fetchPolicies,
} from '../../store/actions';
+
import { findFirstError } from '../../services/find_errors';
+import { EditPolicy as PresentationComponent } from './edit_policy';
export const EditPolicy = connect(
state => {
diff --git a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.js b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.js
index 8e9fcc281ad27..627b40e10defe 100644
--- a/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.js
+++ b/x-pack/plugins/index_lifecycle_management/public/sections/edit_policy/edit_policy.js
@@ -7,8 +7,8 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { toastNotifications } from 'ui/notify';
-import { goToPolicyList } from '../../services/navigation';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
+
import {
EuiPage,
EuiPageBody,
@@ -26,10 +26,7 @@ import {
EuiFlexItem,
EuiDescribedFormGroup,
} from '@elastic/eui';
-import { HotPhase } from './components/hot_phase';
-import { WarmPhase } from './components/warm_phase';
-import { DeletePhase } from './components/delete_phase';
-import { ColdPhase } from './components/cold_phase';
+
import {
PHASE_HOT,
PHASE_COLD,
@@ -37,11 +34,18 @@ import {
PHASE_WARM,
STRUCTURE_POLICY_NAME,
} from '../../constants';
+
+import { goToPolicyList } from '../../services/navigation';
import { findFirstError } from '../../services/find_errors';
+import { LearnMoreLink } from '../components';
import { NodeAttrsDetails } from './components/node_attrs_details';
import { PolicyJsonFlyout } from './components/policy_json_flyout';
import { ErrableFormRow } from './form_errors';
-import { LearnMoreLink } from '../components';
+import { HotPhase } from './components/hot_phase';
+import { WarmPhase } from './components/warm_phase';
+import { DeletePhase } from './components/delete_phase';
+import { ColdPhase } from './components/cold_phase';
+
class EditPolicyUi extends Component {
static propTypes = {
selectedPolicy: PropTypes.object.isRequired,
@@ -57,17 +61,22 @@ class EditPolicyUi extends Component {
isShowingPolicyJsonFlyout: false,
};
}
+
selectPolicy = policyName => {
const { setSelectedPolicy, policies } = this.props;
+
const selectedPolicy = policies.find(policy => {
return policy.name === policyName;
});
+
if (selectedPolicy) {
setSelectedPolicy(selectedPolicy);
}
};
+
componentDidMount() {
window.scrollTo(0, 0);
+
const {
isPolicyListLoaded,
fetchPolicies,
@@ -75,6 +84,7 @@ class EditPolicyUi extends Component {
params: { policyName },
} = { params: {} },
} = this.props;
+
if (policyName) {
const decodedPolicyName = decodeURIComponent(policyName);
if (isPolicyListLoaded) {
@@ -88,10 +98,12 @@ class EditPolicyUi extends Component {
this.props.setSelectedPolicy(null);
}
}
+
backToPolicyList = () => {
this.props.setSelectedPolicy(null);
goToPolicyList();
};
+
submit = async () => {
const { intl } = this.props;
this.setState({ isShowingErrors: true });
diff --git a/x-pack/plugins/index_lifecycle_management/public/store/selectors/general.js b/x-pack/plugins/index_lifecycle_management/public/store/selectors/general.js
index 41459d1bbb2c8..d0f0973ad81f2 100644
--- a/x-pack/plugins/index_lifecycle_management/public/store/selectors/general.js
+++ b/x-pack/plugins/index_lifecycle_management/public/store/selectors/general.js
@@ -4,9 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
-
-
export const getBootstrapEnabled = state => state.general.bootstrapEnabled;
export const getIndexName = state => state.general.indexName;
export const getAliasName = state => state.general.aliasName;
diff --git a/x-pack/plugins/index_lifecycle_management/public/store/selectors/lifecycle.js b/x-pack/plugins/index_lifecycle_management/public/store/selectors/lifecycle.js
index b89e74781b344..2463a7fed8799 100644
--- a/x-pack/plugins/index_lifecycle_management/public/store/selectors/lifecycle.js
+++ b/x-pack/plugins/index_lifecycle_management/public/store/selectors/lifecycle.js
@@ -3,7 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+
import { i18n } from '@kbn/i18n';
+
import {
PHASE_HOT,
PHASE_WARM,
@@ -26,6 +28,7 @@ import {
PHASE_INDEX_PRIORITY,
PHASE_ROLLOVER_MAX_DOCUMENTS
} from '../../constants';
+
import {
getPhase,
getPhases,
@@ -36,28 +39,36 @@ import {
getSelectedOriginalPolicyName,
getPolicies
} from '.';
+
import { getPolicyByName } from './policies';
+
export const numberRequiredMessage = i18n.translate('xpack.indexLifecycleMgmt.editPolicy.numberRequiredError', {
defaultMessage: 'A number is required.'
});
+
export const positiveNumberRequiredMessage = i18n.translate('xpack.indexLifecycleMgmt.editPolicy.positiveNumberRequiredError', {
defaultMessage: 'Only positive numbers are allowed.'
});
+
export const maximumAgeRequiredMessage = i18n.translate('xpack.indexLifecycleMgmt.editPolicy.maximumAgeMissingError', {
defaultMessage: 'A maximum age is required.'
});
+
export const maximumSizeRequiredMessage =
i18n.translate('xpack.indexLifecycleMgmt.editPolicy.maximumIndexSizeMissingError', {
defaultMessage: 'A maximum index size is required.'
});
+
export const maximumDocumentsRequiredMessage =
i18n.translate('xpack.indexLifecycleMgmt.editPolicy.maximumDocumentsMissingError', {
defaultMessage: 'Maximum documents is required.'
});
+
export const positiveNumbersAboveZeroErrorMessage =
i18n.translate('xpack.indexLifecycleMgmt.editPolicy.positiveNumberAboveZeroRequiredError', {
defaultMessage: 'Only numbers above 0 are allowed.'
});
+
export const validatePhase = (type, phase, errors) => {
const phaseErrors = {};
diff --git a/x-pack/plugins/index_lifecycle_management/public/store/selectors/nodes.js b/x-pack/plugins/index_lifecycle_management/public/store/selectors/nodes.js
index 82774559fe275..7e46d9c1ea172 100644
--- a/x-pack/plugins/index_lifecycle_management/public/store/selectors/nodes.js
+++ b/x-pack/plugins/index_lifecycle_management/public/store/selectors/nodes.js
@@ -7,6 +7,7 @@
import { createSelector } from 'reselect';
export const getNodes = state => state.nodes.nodes;
+
export const getNodeOptions = createSelector(
[state => getNodes(state)],
nodes => {
@@ -30,9 +31,12 @@ export const getNodeOptions = createSelector(
export const getSelectedPrimaryShardCount = state =>
state.nodes.selectedPrimaryShardCount;
+
export const getSelectedReplicaCount = state =>
state.nodes.selectedReplicaCount !== undefined ? state.nodes.selectedReplicaCount : 1;
+
export const getSelectedNodeAttrs = state => state.nodes.selectedNodeAttrs;
+
export const getNodesFromSelectedNodeAttrs = state => {
const nodes = getNodes(state)[getSelectedNodeAttrs(state)];
if (nodes) {
diff --git a/x-pack/plugins/index_lifecycle_management/public/store/selectors/policies.js b/x-pack/plugins/index_lifecycle_management/public/store/selectors/policies.js
index c65d1978720ce..2a824471586f2 100644
--- a/x-pack/plugins/index_lifecycle_management/public/store/selectors/policies.js
+++ b/x-pack/plugins/index_lifecycle_management/public/store/selectors/policies.js
@@ -4,10 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
-
-
import { createSelector } from 'reselect';
import { Pager } from '@elastic/eui';
+
import {
PHASE_HOT,
PHASE_WARM,
@@ -33,14 +32,15 @@ import {
PHASE_INDEX_PRIORITY,
PHASE_ROLLOVER_MAX_DOCUMENTS
} from '../../constants';
+
+import { filterItems, sortTable } from '../../services';
+
import {
defaultEmptyDeletePhase,
defaultEmptyColdPhase,
defaultEmptyWarmPhase,
defaultEmptyHotPhase
} from '../defaults';
-import { filterItems, sortTable } from '../../services';
-
export const getPolicies = state => state.policies.policies;
export const getPolicyByName = (state, name) => getPolicies(state).find((policy) => policy.name === name) || {};
@@ -97,8 +97,10 @@ export const getSelectedPolicyName = state => {
};
export const getPhases = state => state.policies.selectedPolicy.phases;
+
export const getPhase = (state, phase) =>
getPhases(state)[phase];
+
export const getPhaseData = (state, phase, key) => {
if (PHASE_ATTRIBUTES_THAT_ARE_NUMBERS.includes(key)) {
return parseInt(getPhase(state, phase)[key]);
@@ -127,7 +129,7 @@ export const isEmptyObject = (obj) => {
return !obj || (Object.entries(obj).length === 0 && obj.constructor === Object);
};
-export const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
+const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
const policy = { ...defaultEmptyPolicy };
if (!phase) {
return policy;
@@ -196,11 +198,14 @@ export const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
}
if (actions.shrink) {
+ policy[PHASE_SHRINK_ENABLED] = true;
policy[PHASE_PRIMARY_SHARD_COUNT] = actions.shrink.number_of_shards;
}
+
if (actions.freeze) {
policy[PHASE_FREEZE_ENABLED] = true;
}
+
if (actions.set_priority) {
policy[PHASE_INDEX_PRIORITY] = actions.set_priority.priority;
}
@@ -210,6 +215,7 @@ export const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
export const policyFromES = (policy) => {
const { name, policy: { phases } } = policy;
+
return {
name,
phases: {
diff --git a/x-pack/plugins/index_lifecycle_management/public/store/store.js b/x-pack/plugins/index_lifecycle_management/public/store/store.js
index 151a7a5bf8b50..f44a81c499686 100644
--- a/x-pack/plugins/index_lifecycle_management/public/store/store.js
+++ b/x-pack/plugins/index_lifecycle_management/public/store/store.js
@@ -15,7 +15,6 @@ import {
indexLifecycleManagement
} from './reducers/';
-
export const indexLifecycleManagementStore = (initialState = {}) => {
const enhancers = [applyMiddleware(thunk)];