Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing issues with maximum documents and maximum size being set #31998

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
policyNameContainsSpaceErrorMessage,
policyNameMustBeDifferentErrorMessage,
policyNameAlreadyUsedErrorMessage,
maximumDocumentsRequiredMessage,
} from '../../public/store/selectors/lifecycle';

let server;
Expand Down Expand Up @@ -184,7 +185,7 @@ describe('edit policy', () => {
maxAgeInput.simulate('change', { target: { value: '' } });
rendered.update();
save(rendered);
expectedErrorMessages(rendered, [maximumSizeRequiredMessage, maximumAgeRequiredMessage]);
expectedErrorMessages(rendered, [maximumSizeRequiredMessage, maximumAgeRequiredMessage, maximumDocumentsRequiredMessage]);
});
test('should show number above 0 required error when trying to save with -1 for max size', () => {
const rendered = mountWithIntl(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import {
import {
PHASE_COLD,
PHASE_ENABLED,
PHASE_ROLLOVER_ALIAS,
PHASE_ROLLOVER_MINIMUM_AGE,
PHASE_ROLLOVER_MINIMUM_AGE_UNITS,
PHASE_NODE_ATTRS,
PHASE_REPLICA_COUNT,
PHASE_FREEZE_ENABLED
} from '../../../../store/constants';
Expand All @@ -40,15 +36,6 @@ class ColdPhaseUi extends PureComponent {

isShowingErrors: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
phaseData: PropTypes.shape({
[PHASE_ENABLED]: PropTypes.bool.isRequired,
[PHASE_ROLLOVER_ALIAS]: PropTypes.string.isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE]: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
.isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: PropTypes.string.isRequired,
[PHASE_NODE_ATTRS]: PropTypes.string.isRequired,
[PHASE_REPLICA_COUNT]: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
}).isRequired,
};
render() {
const {
Expand Down Expand Up @@ -100,8 +87,8 @@ class ColdPhaseUi extends PureComponent {
}
id={`${PHASE_COLD}-${PHASE_ENABLED}`}
checked={phaseData[PHASE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_ENABLED, e.target.checked);
}}
aria-controls="coldPhaseContent"
/>
Expand Down Expand Up @@ -157,8 +144,8 @@ class ColdPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_COLD}-${PHASE_REPLICA_COUNT}`}
value={phaseData[PHASE_REPLICA_COUNT]}
onChange={async e => {
await setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
onChange={e => {
setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
}}
min={0}
/>
Expand Down Expand Up @@ -197,8 +184,8 @@ class ColdPhaseUi extends PureComponent {
<EuiSwitch
data-test-subj="freezeSwitch"
checked={phaseData[PHASE_FREEZE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_FREEZE_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_FREEZE_ENABLED, e.target.checked);
}}
label={freezeLabel}
aria-label={freezeLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
import {
PHASE_DELETE,
PHASE_ENABLED,
PHASE_ROLLOVER_MINIMUM_AGE,
PHASE_ROLLOVER_MINIMUM_AGE_UNITS,
} from '../../../../store/constants';
import { ActiveBadge, PhaseErrorMessage } from '../../../components';

Expand All @@ -29,14 +27,6 @@ export class DeletePhase extends PureComponent {
setPhaseData: PropTypes.func.isRequired,
isShowingErrors: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
phaseData: PropTypes.shape({
[PHASE_ENABLED]: PropTypes.bool.isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE]: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]).isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: PropTypes.string.isRequired
}).isRequired
};

render() {
Expand Down Expand Up @@ -85,8 +75,8 @@ export class DeletePhase extends PureComponent {
}
id={`${PHASE_DELETE}-${PHASE_ENABLED}`}
checked={phaseData[PHASE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_ENABLED, e.target.checked);
}}
aria-controls="deletePhaseContent"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import {
import { LearnMoreLink, ActiveBadge, PhaseErrorMessage } from '../../../components';
import {
PHASE_HOT,
PHASE_ROLLOVER_ALIAS,
PHASE_ROLLOVER_MAX_AGE,
PHASE_ROLLOVER_MAX_AGE_UNITS,
PHASE_ROLLOVER_MAX_DOCUMENTS,
PHASE_ROLLOVER_MAX_SIZE_STORED,
PHASE_ROLLOVER_MAX_SIZE_STORED_UNITS,
PHASE_ROLLOVER_ENABLED,
MAX_SIZE_TYPE_DOCUMENT
} from '../../../../store/constants';
import { SetPriorityInput } from '../set_priority_input';

Expand All @@ -39,19 +38,6 @@ class HotPhaseUi extends PureComponent {

isShowingErrors: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
phaseData: PropTypes.shape({
[PHASE_ROLLOVER_ALIAS]: PropTypes.string.isRequired,
[PHASE_ROLLOVER_MAX_AGE]: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]).isRequired,
[PHASE_ROLLOVER_MAX_AGE_UNITS]: PropTypes.string.isRequired,
[PHASE_ROLLOVER_MAX_SIZE_STORED]: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]).isRequired,
[PHASE_ROLLOVER_MAX_SIZE_STORED_UNITS]: PropTypes.string.isRequired
}).isRequired
};

render() {
Expand All @@ -63,7 +49,6 @@ class HotPhaseUi extends PureComponent {
intl,
setWarmPhaseOnRollover
} = this.props;

return (
<Fragment>
<EuiDescribedFormGroup
Expand Down Expand Up @@ -150,8 +135,8 @@ class HotPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_HOT}-${PHASE_ROLLOVER_MAX_SIZE_STORED}`}
value={phaseData[PHASE_ROLLOVER_MAX_SIZE_STORED]}
onChange={async e => {
await setPhaseData(
onChange={e => {
setPhaseData(
PHASE_ROLLOVER_MAX_SIZE_STORED,
e.target.value
);
Expand All @@ -174,8 +159,8 @@ class HotPhaseUi extends PureComponent {
defaultMessage: 'Maximum index size units'
})}
value={phaseData[PHASE_ROLLOVER_MAX_SIZE_STORED_UNITS]}
onChange={async e => {
await setPhaseData(
onChange={e => {
setPhaseData(
PHASE_ROLLOVER_MAX_SIZE_STORED_UNITS,
e.target.value
);
Expand All @@ -185,16 +170,43 @@ class HotPhaseUi extends PureComponent {
id: 'xpack.indexLifecycleMgmt.hotPhase.gigabytesLabel',
defaultMessage: 'gigabytes'
}) },
{ value: MAX_SIZE_TYPE_DOCUMENT, text: intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.hotPhase.documentsLabel',
defaultMessage: 'documents'
{ value: 'mb', text: intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.hotPhase.megabytesLabel',
defaultMessage: 'megabytes'
}) }
]}
/>
</ErrableFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EuiFlexGroup>
<EuiFlexItem style={{ maxWidth: 188 }}>
<ErrableFormRow
id={`${PHASE_HOT}-${PHASE_ROLLOVER_MAX_DOCUMENTS}`}
label={intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.hotPhase.maximumDocumentsLabel',
defaultMessage: 'Maximum documents'
})}
errorKey={PHASE_ROLLOVER_MAX_DOCUMENTS}
isShowingErrors={isShowingErrors}
errors={errors}
>
<EuiFieldNumber
id={`${PHASE_HOT}-${PHASE_ROLLOVER_MAX_DOCUMENTS}`}
value={phaseData[PHASE_ROLLOVER_MAX_DOCUMENTS]}
onChange={e => {
setPhaseData(
PHASE_ROLLOVER_MAX_DOCUMENTS,
e.target.value
);
}}
min={1}
/>
</ErrableFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EuiFlexGroup>
<EuiFlexItem style={{ maxWidth: 188 }}>
<ErrableFormRow
Expand All @@ -210,8 +222,8 @@ class HotPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_HOT}-${PHASE_ROLLOVER_MAX_AGE}`}
value={phaseData[PHASE_ROLLOVER_MAX_AGE]}
onChange={async e => {
await setPhaseData(PHASE_ROLLOVER_MAX_AGE, e.target.value);
onChange={e => {
setPhaseData(PHASE_ROLLOVER_MAX_AGE, e.target.value);
}}
min={1}
/>
Expand All @@ -231,8 +243,8 @@ class HotPhaseUi extends PureComponent {
defaultMessage: 'Maximum age units'
})}
value={phaseData[PHASE_ROLLOVER_MAX_AGE_UNITS]}
onChange={async e => {
await setPhaseData(
onChange={e => {
setPhaseData(
PHASE_ROLLOVER_MAX_AGE_UNITS,
e.target.value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class NodeAllocationUi extends Component {
id={`${phase}-${PHASE_NODE_ATTRS}`}
value={phaseData[PHASE_NODE_ATTRS] || ' '}
options={nodeOptions}
onChange={async e => {
await setPhaseData(PHASE_NODE_ATTRS, e.target.value);
onChange={e => {
setPhaseData(PHASE_NODE_ATTRS, e.target.value);
}}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const SetPriorityInput = props => {
<EuiFieldNumber
id={`${phase}-${PHASE_INDEX_PRIORITY}`}
value={phaseData[PHASE_INDEX_PRIORITY]}
onChange={async e => {
await setPhaseData(PHASE_INDEX_PRIORITY, e.target.value);
onChange={e => {
setPhaseData(PHASE_INDEX_PRIORITY, e.target.value);
}}
min={0}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ import {
PHASE_WARM,
PHASE_ENABLED,
WARM_PHASE_ON_ROLLOVER,
PHASE_ROLLOVER_ALIAS,
PHASE_FORCE_MERGE_ENABLED,
PHASE_FORCE_MERGE_SEGMENTS,
PHASE_NODE_ATTRS,
PHASE_PRIMARY_SHARD_COUNT,
PHASE_REPLICA_COUNT,
PHASE_ROLLOVER_MINIMUM_AGE,
PHASE_ROLLOVER_MINIMUM_AGE_UNITS,
PHASE_SHRINK_ENABLED,
} from '../../../../store/constants';
import { SetPriorityInput } from '../set_priority_input';
Expand All @@ -43,21 +39,6 @@ class WarmPhaseUi extends PureComponent {

isShowingErrors: PropTypes.bool.isRequired,
errors: PropTypes.object.isRequired,
phaseData: PropTypes.shape({
[PHASE_ENABLED]: PropTypes.bool.isRequired,
[WARM_PHASE_ON_ROLLOVER]: PropTypes.bool.isRequired,
[PHASE_ROLLOVER_ALIAS]: PropTypes.string.isRequired,
[PHASE_FORCE_MERGE_ENABLED]: PropTypes.bool.isRequired,
[PHASE_FORCE_MERGE_SEGMENTS]: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
.isRequired,
[PHASE_NODE_ATTRS]: PropTypes.string.isRequired,
[PHASE_PRIMARY_SHARD_COUNT]: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
.isRequired,
[PHASE_REPLICA_COUNT]: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE]: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
.isRequired,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: PropTypes.string.isRequired,
}).isRequired,
};
render() {
const {
Expand Down Expand Up @@ -117,8 +98,8 @@ class WarmPhaseUi extends PureComponent {
}
id={`${PHASE_WARM}-${PHASE_ENABLED}`}
checked={phaseData[PHASE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_ENABLED, e.target.checked);
}}
aria-controls="warmPhaseContent"
/>
Expand All @@ -138,8 +119,8 @@ class WarmPhaseUi extends PureComponent {
label={moveToWarmPhaseOnRolloverLabel}
id={`${PHASE_WARM}-${WARM_PHASE_ON_ROLLOVER}`}
checked={phaseData[WARM_PHASE_ON_ROLLOVER]}
onChange={async e => {
await setPhaseData(WARM_PHASE_ON_ROLLOVER, e.target.checked);
onChange={e => {
setPhaseData(WARM_PHASE_ON_ROLLOVER, e.target.checked);
}}
/>
</EuiFormRow>
Expand Down Expand Up @@ -192,8 +173,8 @@ class WarmPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_WARM}-${PHASE_REPLICA_COUNT}`}
value={phaseData[PHASE_REPLICA_COUNT]}
onChange={async e => {
await setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
onChange={e => {
setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
}}
min={0}
/>
Expand Down Expand Up @@ -233,8 +214,8 @@ class WarmPhaseUi extends PureComponent {
<EuiSwitch
data-test-subj="shrinkSwitch"
checked={phaseData[PHASE_SHRINK_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_SHRINK_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_SHRINK_ENABLED, e.target.checked);
}}
label={shrinkLabel}
aria-label={shrinkLabel}
Expand All @@ -259,8 +240,8 @@ class WarmPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_WARM}-${PHASE_PRIMARY_SHARD_COUNT}`}
value={phaseData[PHASE_PRIMARY_SHARD_COUNT]}
onChange={async e => {
await setPhaseData(PHASE_PRIMARY_SHARD_COUNT, e.target.value);
onChange={e => {
setPhaseData(PHASE_PRIMARY_SHARD_COUNT, e.target.value);
}}
min={1}
/>
Expand Down Expand Up @@ -299,8 +280,8 @@ class WarmPhaseUi extends PureComponent {
label={forcemergeLabel}
aria-label={forcemergeLabel}
checked={phaseData[PHASE_FORCE_MERGE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_FORCE_MERGE_ENABLED, e.target.checked);
onChange={e => {
setPhaseData(PHASE_FORCE_MERGE_ENABLED, e.target.checked);
}}
aria-controls="forcemergeContent"
/>
Expand All @@ -321,8 +302,8 @@ class WarmPhaseUi extends PureComponent {
<EuiFieldNumber
id={`${PHASE_WARM}-${PHASE_FORCE_MERGE_SEGMENTS}`}
value={phaseData[PHASE_FORCE_MERGE_SEGMENTS]}
onChange={async e => {
await setPhaseData(PHASE_FORCE_MERGE_SEGMENTS, e.target.value);
onChange={e => {
setPhaseData(PHASE_FORCE_MERGE_SEGMENTS, e.target.value);
}}
min={1}
/>
Expand Down
Loading