[ILM] TS conversion of Edit policy components (#74747)
* [ILM] Convert node allocation component to TS and use hooks * [ILM] Fix jest tests * [ILM] Fix i18n check * [ILM] Implement code review suggestions * [ILM] Fix type check, docs link and button maxWidth in NodeAllocation component * Fix internaliation error * [ILM] Convert node details flyout to TS * [ILM] Fix useState declaration * [ILM] Fix useState declaration * [ILM] Fix jest test * [ILM] Change error message when unable to load node attributes * [ILM] Change error message when unable to load node details * [ILM] Delete a period in error callout * [ILM] Delete a period in error callout * [ILM] Convert node details flyout to TS * [ILM] Fix i18n check * [ILM] Fix useState declaration * [ILM] Fix useState declaration * [ILM] Fix jest test * [ILM] Change error message when unable to load node details * [ILM] Delete a period in error callout * [ILM] edit components * [ILM] Fix review suggestions Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
459e9d603d
commit
64b8b88c64
|
@ -1,22 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { getPhase } from '../../../../store/selectors';
|
||||
import { setPhaseData } from '../../../../store/actions';
|
||||
import { PHASE_COLD, PHASE_HOT, PHASE_ROLLOVER_ENABLED } from '../../../../constants';
|
||||
import { ColdPhase as PresentationComponent } from './cold_phase';
|
||||
|
||||
export const ColdPhase = connect(
|
||||
(state) => ({
|
||||
phaseData: getPhase(state, PHASE_COLD),
|
||||
hotPhaseRolloverEnabled: getPhase(state, PHASE_HOT)[PHASE_ROLLOVER_ENABLED],
|
||||
}),
|
||||
{
|
||||
setPhaseData: (key, value) => setPhaseData(PHASE_COLD, key, value),
|
||||
}
|
||||
)(PresentationComponent);
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { ColdPhase } from './cold_phase.container';
|
|
@ -1,21 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
import { getPhase } from '../../../../store/selectors';
|
||||
import { setPhaseData } from '../../../../store/actions';
|
||||
import { PHASE_DELETE, PHASE_HOT, PHASE_ROLLOVER_ENABLED } from '../../../../constants';
|
||||
import { DeletePhase as PresentationComponent } from './delete_phase';
|
||||
|
||||
export const DeletePhase = connect(
|
||||
(state) => ({
|
||||
phaseData: getPhase(state, PHASE_DELETE),
|
||||
hotPhaseRolloverEnabled: getPhase(state, PHASE_HOT)[PHASE_ROLLOVER_ENABLED],
|
||||
}),
|
||||
{
|
||||
setPhaseData: (key, value) => setPhaseData(PHASE_DELETE, key, value),
|
||||
}
|
||||
)(PresentationComponent);
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { DeletePhase } from './delete_phase.container';
|
|
@ -1,22 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { getPhase } from '../../../../store/selectors';
|
||||
import { setPhaseData } from '../../../../store/actions';
|
||||
import { PHASE_HOT, PHASE_WARM, WARM_PHASE_ON_ROLLOVER } from '../../../../constants';
|
||||
import { HotPhase as PresentationComponent } from './hot_phase';
|
||||
|
||||
export const HotPhase = connect(
|
||||
(state) => ({
|
||||
phaseData: getPhase(state, PHASE_HOT),
|
||||
}),
|
||||
{
|
||||
setPhaseData: (key, value) => setPhaseData(PHASE_HOT, key, value),
|
||||
setWarmPhaseOnRollover: (value) => setPhaseData(PHASE_WARM, WARM_PHASE_ON_ROLLOVER, value),
|
||||
}
|
||||
)(PresentationComponent);
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { HotPhase } from './hot_phase.container';
|
|
@ -5,6 +5,13 @@
|
|||
*/
|
||||
|
||||
export { ActiveBadge } from './active_badge';
|
||||
export { ErrableFormRow } from './form_errors';
|
||||
export { LearnMoreLink } from './learn_more_link';
|
||||
export { PhaseErrorMessage } from './phase_error_message';
|
||||
export { MinAgeInput } from './min_age_input';
|
||||
export { NodeAllocation } from './node_allocation';
|
||||
export { NodeAttrsDetails } from './node_attrs_details';
|
||||
export { OptionalLabel } from './optional_label';
|
||||
export { PhaseErrorMessage } from './phase_error_message';
|
||||
export { PolicyJsonFlyout } from './policy_json_flyout';
|
||||
export { SetPriorityInput } from './set_priority_input';
|
||||
export { SnapshotPolicies } from './snapshot_policies';
|
|
@ -8,7 +8,7 @@ import React, { ReactNode } from 'react';
|
|||
import { EuiLink } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import { createDocLink } from '../../services/documentation';
|
||||
import { createDocLink } from '../../../services/documentation';
|
||||
|
||||
interface Props {
|
||||
docPath: string;
|
|
@ -16,10 +16,10 @@ import {
|
|||
PHASE_COLD,
|
||||
PHASE_DELETE,
|
||||
} from '../../../constants';
|
||||
import { LearnMoreLink } from '../../components';
|
||||
import { ErrableFormRow } from '../form_errors';
|
||||
import { LearnMoreLink } from './learn_more_link';
|
||||
import { ErrableFormRow } from './form_errors';
|
||||
|
||||
function getTimingLabelForPhase(phase) {
|
||||
function getTimingLabelForPhase(phase: string) {
|
||||
// NOTE: Hot phase isn't necessary, because indices begin in the hot phase.
|
||||
switch (phase) {
|
||||
case PHASE_WARM:
|
||||
|
@ -39,7 +39,7 @@ function getTimingLabelForPhase(phase) {
|
|||
}
|
||||
}
|
||||
|
||||
function getUnitsAriaLabelForPhase(phase) {
|
||||
function getUnitsAriaLabelForPhase(phase: string) {
|
||||
// NOTE: Hot phase isn't necessary, because indices begin in the hot phase.
|
||||
switch (phase) {
|
||||
case PHASE_WARM:
|
||||
|
@ -68,9 +68,24 @@ function getUnitsAriaLabelForPhase(phase) {
|
|||
}
|
||||
}
|
||||
|
||||
export const MinAgeInput = (props) => {
|
||||
const { rolloverEnabled, errors, phaseData, phase, setPhaseData, isShowingErrors } = props;
|
||||
interface Props {
|
||||
rolloverEnabled: boolean;
|
||||
errors: Record<string, string[]>;
|
||||
phase: string;
|
||||
// TODO add types for phaseData and setPhaseData after policy is typed
|
||||
phaseData: any;
|
||||
setPhaseData: (dataKey: string, value: any) => void;
|
||||
isShowingErrors: boolean;
|
||||
}
|
||||
|
||||
export const MinAgeInput: React.FunctionComponent<Props> = ({
|
||||
rolloverEnabled,
|
||||
errors,
|
||||
phaseData,
|
||||
phase,
|
||||
setPhaseData,
|
||||
isShowingErrors,
|
||||
}) => {
|
||||
let daysOptionLabel;
|
||||
let hoursOptionLabel;
|
||||
let minutesOptionLabel;
|
|
@ -16,17 +16,18 @@ import {
|
|||
EuiButton,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { PHASE_NODE_ATTRS } from '../../../../constants';
|
||||
import { LearnMoreLink } from '../../../components/learn_more_link';
|
||||
import { ErrableFormRow } from '../../form_errors';
|
||||
import { useLoadNodes } from '../../../../services/api';
|
||||
import { NodeAttrsDetails } from '../node_attrs_details';
|
||||
import { PHASE_NODE_ATTRS } from '../../../constants';
|
||||
import { LearnMoreLink } from './learn_more_link';
|
||||
import { ErrableFormRow } from './form_errors';
|
||||
import { useLoadNodes } from '../../../services/api';
|
||||
import { NodeAttrsDetails } from './node_attrs_details';
|
||||
|
||||
interface Props {
|
||||
phase: string;
|
||||
setPhaseData: (dataKey: string, value: any) => void;
|
||||
errors: any;
|
||||
errors: Record<string, string[]>;
|
||||
// TODO add types for phaseData and setPhaseData after policy is typed
|
||||
phaseData: any;
|
||||
setPhaseData: (dataKey: string, value: any) => void;
|
||||
isShowingErrors: boolean;
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ import {
|
|||
EuiButton,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { useLoadNodeDetails } from '../../../../services/api';
|
||||
import { useLoadNodeDetails } from '../../../services/api';
|
||||
|
||||
interface Props {
|
||||
close: () => void;
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { NodeAttrsDetails } from './node_attrs_details';
|
|
@ -7,7 +7,7 @@ import React from 'react';
|
|||
import { EuiBadge } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
export const PhaseErrorMessage = ({ isShowingErrors }) => {
|
||||
export const PhaseErrorMessage = ({ isShowingErrors }: { isShowingErrors: boolean }) => {
|
||||
return isShowingErrors ? (
|
||||
<EuiBadge className="eui-alignMiddle" color="danger">
|
||||
<FormattedMessage
|
|
@ -1,95 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import React, { PureComponent } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiCodeBlock,
|
||||
EuiFlyout,
|
||||
EuiFlyoutBody,
|
||||
EuiFlyoutFooter,
|
||||
EuiFlyoutHeader,
|
||||
EuiSpacer,
|
||||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
|
||||
export class PolicyJsonFlyout extends PureComponent {
|
||||
static propTypes = {
|
||||
close: PropTypes.func.isRequired,
|
||||
lifecycle: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
getEsJson({ phases }) {
|
||||
return JSON.stringify(
|
||||
{
|
||||
policy: {
|
||||
phases,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { lifecycle, close, policyName } = this.props;
|
||||
const endpoint = `PUT _ilm/policy/${policyName || '<policyName>'}`;
|
||||
const request = `${endpoint}\n${this.getEsJson(lifecycle)}`;
|
||||
|
||||
return (
|
||||
<EuiFlyout maxWidth={480} onClose={close}>
|
||||
<EuiFlyoutHeader>
|
||||
<EuiTitle>
|
||||
<h2>
|
||||
{policyName ? (
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.namedTitle"
|
||||
defaultMessage="Request for '{policyName}'"
|
||||
values={{ policyName }}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.unnamedTitle"
|
||||
defaultMessage="Request"
|
||||
/>
|
||||
)}
|
||||
</h2>
|
||||
</EuiTitle>
|
||||
</EuiFlyoutHeader>
|
||||
|
||||
<EuiFlyoutBody>
|
||||
<EuiText>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.descriptionText"
|
||||
defaultMessage="This Elasticsearch request will create or update this index lifecycle policy."
|
||||
/>
|
||||
</p>
|
||||
</EuiText>
|
||||
|
||||
<EuiSpacer />
|
||||
|
||||
<EuiCodeBlock language="json" isCopyable>
|
||||
{request}
|
||||
</EuiCodeBlock>
|
||||
</EuiFlyoutBody>
|
||||
|
||||
<EuiFlyoutFooter>
|
||||
<EuiButtonEmpty iconType="cross" onClick={close} flush="left">
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.closeButtonLabel"
|
||||
defaultMessage="Close"
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlyoutFooter>
|
||||
</EuiFlyout>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiCodeBlock,
|
||||
EuiFlyout,
|
||||
EuiFlyoutBody,
|
||||
EuiFlyoutFooter,
|
||||
EuiFlyoutHeader,
|
||||
EuiSpacer,
|
||||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
|
||||
interface Props {
|
||||
close: () => void;
|
||||
// TODO add types for lifecycle after policy is typed
|
||||
lifecycle: any;
|
||||
policyName: string;
|
||||
}
|
||||
|
||||
export const PolicyJsonFlyout: React.FunctionComponent<Props> = ({
|
||||
close,
|
||||
lifecycle,
|
||||
policyName,
|
||||
}) => {
|
||||
// @ts-ignore until store is typed
|
||||
const getEsJson = ({ phases }) => {
|
||||
return JSON.stringify(
|
||||
{
|
||||
policy: {
|
||||
phases,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
};
|
||||
|
||||
const endpoint = `PUT _ilm/policy/${policyName || '<policyName>'}`;
|
||||
const request = `${endpoint}\n${getEsJson(lifecycle)}`;
|
||||
|
||||
return (
|
||||
<EuiFlyout maxWidth={480} onClose={close}>
|
||||
<EuiFlyoutHeader>
|
||||
<EuiTitle>
|
||||
<h2>
|
||||
{policyName ? (
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.namedTitle"
|
||||
defaultMessage="Request for '{policyName}'"
|
||||
values={{ policyName }}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.unnamedTitle"
|
||||
defaultMessage="Request"
|
||||
/>
|
||||
)}
|
||||
</h2>
|
||||
</EuiTitle>
|
||||
</EuiFlyoutHeader>
|
||||
|
||||
<EuiFlyoutBody>
|
||||
<EuiText>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.descriptionText"
|
||||
defaultMessage="This Elasticsearch request will create or update this index lifecycle policy."
|
||||
/>
|
||||
</p>
|
||||
</EuiText>
|
||||
|
||||
<EuiSpacer />
|
||||
|
||||
<EuiCodeBlock language="json" isCopyable>
|
||||
{request}
|
||||
</EuiCodeBlock>
|
||||
</EuiFlyoutBody>
|
||||
|
||||
<EuiFlyoutFooter>
|
||||
<EuiButtonEmpty iconType="cross" onClick={close} flush="left">
|
||||
<FormattedMessage
|
||||
id="xpack.indexLifecycleMgmt.policyJsonFlyout.closeButtonLabel"
|
||||
defaultMessage="Close"
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
</EuiFlyoutFooter>
|
||||
</EuiFlyout>
|
||||
);
|
||||
};
|
|
@ -8,12 +8,26 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import { EuiFieldNumber, EuiTextColor, EuiDescribedFormGroup } from '@elastic/eui';
|
||||
|
||||
import { PHASE_INDEX_PRIORITY } from '../../../constants';
|
||||
import { LearnMoreLink, OptionalLabel } from '../../components';
|
||||
import { ErrableFormRow } from '../form_errors';
|
||||
|
||||
export const SetPriorityInput = (props) => {
|
||||
const { errors, phaseData, phase, setPhaseData, isShowingErrors } = props;
|
||||
import { LearnMoreLink } from './';
|
||||
import { OptionalLabel } from './';
|
||||
import { ErrableFormRow } from './';
|
||||
|
||||
interface Props {
|
||||
errors: Record<string, string[]>;
|
||||
// TODO add types for phaseData and setPhaseData after policy is typed
|
||||
phase: string;
|
||||
phaseData: any;
|
||||
setPhaseData: (dataKey: string, value: any) => void;
|
||||
isShowingErrors: boolean;
|
||||
}
|
||||
export const SetPriorityInput: React.FunctionComponent<Props> = ({
|
||||
errors,
|
||||
phaseData,
|
||||
phase,
|
||||
setPhaseData,
|
||||
isShowingErrors,
|
||||
}) => {
|
||||
return (
|
||||
<EuiDescribedFormGroup
|
||||
title={
|
|
@ -19,7 +19,7 @@ import {
|
|||
EuiSpacer,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { useLoadSnapshotPolicies } from '../../../../services/api';
|
||||
import { useLoadSnapshotPolicies } from '../../../services/api';
|
||||
|
||||
interface Props {
|
||||
value: string;
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { SnapshotPolicies } from './snapshot_policies';
|
|
@ -1,7 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { WarmPhase } from './warm_phase.container';
|
|
@ -1,22 +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;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
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) => ({
|
||||
phaseData: getPhase(state, PHASE_WARM),
|
||||
hotPhaseRolloverEnabled: getPhase(state, PHASE_HOT)[PHASE_ROLLOVER_ENABLED],
|
||||
}),
|
||||
{
|
||||
setPhaseData: (key, value) => setPhaseData(PHASE_WARM, key, value),
|
||||
}
|
||||
)(PresentationComponent);
|
|
@ -15,6 +15,7 @@ import {
|
|||
isPolicyListLoaded,
|
||||
getIsNewPolicy,
|
||||
getSelectedOriginalPolicyName,
|
||||
getPhases,
|
||||
} from '../../store/selectors';
|
||||
|
||||
import {
|
||||
|
@ -23,6 +24,7 @@ import {
|
|||
setSaveAsNewPolicy,
|
||||
saveLifecyclePolicy,
|
||||
fetchPolicies,
|
||||
setPhaseData,
|
||||
} from '../../store/actions';
|
||||
|
||||
import { findFirstError } from '../../services/find_errors';
|
||||
|
@ -42,6 +44,7 @@ export const EditPolicy = connect(
|
|||
isPolicyListLoaded: isPolicyListLoaded(state),
|
||||
isNewPolicy: getIsNewPolicy(state),
|
||||
originalPolicyName: getSelectedOriginalPolicyName(state),
|
||||
phases: getPhases(state),
|
||||
};
|
||||
},
|
||||
{
|
||||
|
@ -50,5 +53,6 @@ export const EditPolicy = connect(
|
|||
setSaveAsNewPolicy,
|
||||
saveLifecyclePolicy,
|
||||
fetchPolicies,
|
||||
setPhaseData,
|
||||
}
|
||||
)(PresentationComponent);
|
||||
|
|
|
@ -33,17 +33,15 @@ import {
|
|||
PHASE_DELETE,
|
||||
PHASE_WARM,
|
||||
STRUCTURE_POLICY_NAME,
|
||||
WARM_PHASE_ON_ROLLOVER,
|
||||
PHASE_ROLLOVER_ENABLED,
|
||||
} from '../../constants';
|
||||
|
||||
import { toasts } from '../../services/notification';
|
||||
import { findFirstError } from '../../services/find_errors';
|
||||
import { LearnMoreLink } from '../components';
|
||||
import { PolicyJsonFlyout } from './components/policy_json_flyout';
|
||||
import { ErrableFormRow } from './form_errors';
|
||||
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 { LearnMoreLink, PolicyJsonFlyout, ErrableFormRow } from './components';
|
||||
|
||||
import { HotPhase, WarmPhase, ColdPhase, DeletePhase } from './phases';
|
||||
|
||||
export class EditPolicy extends Component {
|
||||
static propTypes = {
|
||||
|
@ -137,6 +135,8 @@ export class EditPolicy extends Component {
|
|||
isNewPolicy,
|
||||
lifecycle,
|
||||
originalPolicyName,
|
||||
phases,
|
||||
setPhaseData,
|
||||
} = this.props;
|
||||
const selectedPolicyName = selectedPolicy.name;
|
||||
const { isShowingErrors, isShowingPolicyJsonFlyout } = this.state;
|
||||
|
@ -275,9 +275,13 @@ export class EditPolicy extends Component {
|
|||
<EuiSpacer />
|
||||
|
||||
<HotPhase
|
||||
selectedPolicy={selectedPolicy}
|
||||
errors={errors[PHASE_HOT]}
|
||||
isShowingErrors={isShowingErrors && !!findFirstError(errors[PHASE_HOT], false)}
|
||||
setPhaseData={(key, value) => setPhaseData(PHASE_HOT, key, value)}
|
||||
phaseData={phases[PHASE_HOT]}
|
||||
setWarmPhaseOnRollover={(value) =>
|
||||
setPhaseData(PHASE_WARM, WARM_PHASE_ON_ROLLOVER, value)
|
||||
}
|
||||
/>
|
||||
|
||||
<EuiHorizontalRule />
|
||||
|
@ -285,6 +289,9 @@ export class EditPolicy extends Component {
|
|||
<WarmPhase
|
||||
errors={errors[PHASE_WARM]}
|
||||
isShowingErrors={isShowingErrors && !!findFirstError(errors[PHASE_WARM], false)}
|
||||
setPhaseData={(key, value) => setPhaseData(PHASE_WARM, key, value)}
|
||||
phaseData={phases[PHASE_WARM]}
|
||||
hotPhaseRolloverEnabled={phases[PHASE_HOT][PHASE_ROLLOVER_ENABLED]}
|
||||
/>
|
||||
|
||||
<EuiHorizontalRule />
|
||||
|
@ -292,6 +299,9 @@ export class EditPolicy extends Component {
|
|||
<ColdPhase
|
||||
errors={errors[PHASE_COLD]}
|
||||
isShowingErrors={isShowingErrors && !!findFirstError(errors[PHASE_COLD], false)}
|
||||
setPhaseData={(key, value) => setPhaseData(PHASE_COLD, key, value)}
|
||||
phaseData={phases[PHASE_COLD]}
|
||||
hotPhaseRolloverEnabled={phases[PHASE_HOT][PHASE_ROLLOVER_ENABLED]}
|
||||
/>
|
||||
|
||||
<EuiHorizontalRule />
|
||||
|
@ -300,6 +310,9 @@ export class EditPolicy extends Component {
|
|||
errors={errors[PHASE_DELETE]}
|
||||
isShowingErrors={isShowingErrors && !!findFirstError(errors[PHASE_DELETE], false)}
|
||||
getUrlForApp={this.props.getUrlForApp}
|
||||
setPhaseData={(key, value) => setPhaseData(PHASE_DELETE, key, value)}
|
||||
phaseData={phases[PHASE_DELETE]}
|
||||
hotPhaseRolloverEnabled={phases[PHASE_HOT][PHASE_ROLLOVER_ENABLED]}
|
||||
/>
|
||||
|
||||
<EuiHorizontalRule />
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import React, { PureComponent, Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
|
@ -24,20 +23,27 @@ import {
|
|||
PHASE_ENABLED,
|
||||
PHASE_REPLICA_COUNT,
|
||||
PHASE_FREEZE_ENABLED,
|
||||
} from '../../../../constants';
|
||||
import { LearnMoreLink, ActiveBadge, PhaseErrorMessage, OptionalLabel } from '../../../components';
|
||||
import { ErrableFormRow } from '../../form_errors';
|
||||
import { MinAgeInput } from '../min_age_input';
|
||||
import { NodeAllocation } from '../node_allocation';
|
||||
import { SetPriorityInput } from '../set_priority_input';
|
||||
} from '../../../constants';
|
||||
import {
|
||||
LearnMoreLink,
|
||||
ActiveBadge,
|
||||
PhaseErrorMessage,
|
||||
OptionalLabel,
|
||||
ErrableFormRow,
|
||||
MinAgeInput,
|
||||
NodeAllocation,
|
||||
SetPriorityInput,
|
||||
} from '../components';
|
||||
|
||||
export class ColdPhase extends PureComponent {
|
||||
static propTypes = {
|
||||
setPhaseData: PropTypes.func.isRequired,
|
||||
interface Props {
|
||||
setPhaseData: (key: string, value: any) => void;
|
||||
phaseData: any;
|
||||
isShowingErrors: boolean;
|
||||
errors: Record<string, string[]>;
|
||||
hotPhaseRolloverEnabled: boolean;
|
||||
}
|
||||
|
||||
isShowingErrors: PropTypes.bool.isRequired,
|
||||
errors: PropTypes.object.isRequired,
|
||||
};
|
||||
export class ColdPhase extends PureComponent<Props> {
|
||||
render() {
|
||||
const {
|
||||
setPhaseData,
|
|
@ -5,22 +5,35 @@
|
|||
*/
|
||||
|
||||
import React, { PureComponent, Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiDescribedFormGroup, EuiSwitch, EuiTextColor, EuiFormRow } from '@elastic/eui';
|
||||
|
||||
import { PHASE_DELETE, PHASE_ENABLED, PHASE_WAIT_FOR_SNAPSHOT_POLICY } from '../../../../constants';
|
||||
import { ActiveBadge, LearnMoreLink, OptionalLabel, PhaseErrorMessage } from '../../../components';
|
||||
import { MinAgeInput } from '../min_age_input';
|
||||
import { SnapshotPolicies } from '../snapshot_policies';
|
||||
import { PHASE_DELETE, PHASE_ENABLED, PHASE_WAIT_FOR_SNAPSHOT_POLICY } from '../../../constants';
|
||||
import {
|
||||
ActiveBadge,
|
||||
LearnMoreLink,
|
||||
OptionalLabel,
|
||||
PhaseErrorMessage,
|
||||
MinAgeInput,
|
||||
SnapshotPolicies,
|
||||
} from '../components';
|
||||
|
||||
export class DeletePhase extends PureComponent {
|
||||
static propTypes = {
|
||||
setPhaseData: PropTypes.func.isRequired,
|
||||
isShowingErrors: PropTypes.bool.isRequired,
|
||||
errors: PropTypes.object.isRequired,
|
||||
};
|
||||
interface Props {
|
||||
setPhaseData: (key: string, value: any) => void;
|
||||
phaseData: any;
|
||||
isShowingErrors: boolean;
|
||||
errors: Record<string, string[]>;
|
||||
hotPhaseRolloverEnabled: boolean;
|
||||
getUrlForApp: (
|
||||
appId: string,
|
||||
options?: {
|
||||
path?: string;
|
||||
absolute?: boolean;
|
||||
}
|
||||
) => string;
|
||||
}
|
||||
|
||||
export class DeletePhase extends PureComponent<Props> {
|
||||
render() {
|
||||
const {
|
||||
setPhaseData,
|
||||
|
@ -28,6 +41,7 @@ export class DeletePhase extends PureComponent {
|
|||
errors,
|
||||
isShowingErrors,
|
||||
hotPhaseRolloverEnabled,
|
||||
getUrlForApp,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
|
@ -123,7 +137,7 @@ export class DeletePhase extends PureComponent {
|
|||
<SnapshotPolicies
|
||||
value={phaseData[PHASE_WAIT_FOR_SNAPSHOT_POLICY]}
|
||||
onChange={(value) => setPhaseData(PHASE_WAIT_FOR_SNAPSHOT_POLICY, value)}
|
||||
getUrlForApp={this.props.getUrlForApp}
|
||||
getUrlForApp={getUrlForApp}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import React, { Fragment, PureComponent } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
|
@ -28,18 +27,24 @@ import {
|
|||
PHASE_ROLLOVER_MAX_SIZE_STORED,
|
||||
PHASE_ROLLOVER_MAX_SIZE_STORED_UNITS,
|
||||
PHASE_ROLLOVER_ENABLED,
|
||||
} from '../../../../constants';
|
||||
import { LearnMoreLink, ActiveBadge, PhaseErrorMessage } from '../../../components';
|
||||
import { ErrableFormRow } from '../../form_errors';
|
||||
import { SetPriorityInput } from '../set_priority_input';
|
||||
} from '../../../constants';
|
||||
import {
|
||||
LearnMoreLink,
|
||||
ActiveBadge,
|
||||
PhaseErrorMessage,
|
||||
ErrableFormRow,
|
||||
SetPriorityInput,
|
||||
} from '../components';
|
||||
|
||||
export class HotPhase extends PureComponent {
|
||||
static propTypes = {
|
||||
setPhaseData: PropTypes.func.isRequired,
|
||||
isShowingErrors: PropTypes.bool.isRequired,
|
||||
errors: PropTypes.object.isRequired,
|
||||
};
|
||||
interface Props {
|
||||
errors: Record<string, string[]>;
|
||||
isShowingErrors: boolean;
|
||||
phaseData: any;
|
||||
setPhaseData: (key: string, value: any) => void;
|
||||
setWarmPhaseOnRollover: (value: boolean) => void;
|
||||
}
|
||||
|
||||
export class HotPhase extends PureComponent<Props> {
|
||||
render() {
|
||||
const { setPhaseData, phaseData, isShowingErrors, errors, setWarmPhaseOnRollover } = this.props;
|
||||
|
|
@ -4,4 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { NodeAllocation } from './node_allocation';
|
||||
export { HotPhase } from './hot_phase';
|
||||
export { WarmPhase } from './warm_phase';
|
||||
export { ColdPhase } from './cold_phase';
|
||||
export { DeletePhase } from './delete_phase';
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
import React, { Fragment, PureComponent } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
|
@ -28,21 +27,26 @@ import {
|
|||
PHASE_PRIMARY_SHARD_COUNT,
|
||||
PHASE_REPLICA_COUNT,
|
||||
PHASE_SHRINK_ENABLED,
|
||||
} from '../../../../constants';
|
||||
import { LearnMoreLink, ActiveBadge, PhaseErrorMessage, OptionalLabel } from '../../../components';
|
||||
import { ErrableFormRow } from '../../form_errors';
|
||||
import { SetPriorityInput } from '../set_priority_input';
|
||||
import { NodeAllocation } from '../node_allocation';
|
||||
import { MinAgeInput } from '../min_age_input';
|
||||
|
||||
export class WarmPhase extends PureComponent {
|
||||
static propTypes = {
|
||||
setPhaseData: PropTypes.func.isRequired,
|
||||
|
||||
isShowingErrors: PropTypes.bool.isRequired,
|
||||
errors: PropTypes.object.isRequired,
|
||||
};
|
||||
} from '../../../constants';
|
||||
import {
|
||||
LearnMoreLink,
|
||||
ActiveBadge,
|
||||
PhaseErrorMessage,
|
||||
OptionalLabel,
|
||||
ErrableFormRow,
|
||||
SetPriorityInput,
|
||||
NodeAllocation,
|
||||
MinAgeInput,
|
||||
} from '../components';
|
||||
|
||||
interface Props {
|
||||
setPhaseData: (key: string, value: any) => void;
|
||||
phaseData: any;
|
||||
isShowingErrors: boolean;
|
||||
errors: Record<string, string[]>;
|
||||
hotPhaseRolloverEnabled: boolean;
|
||||
}
|
||||
export class WarmPhase extends PureComponent<Props> {
|
||||
render() {
|
||||
const {
|
||||
setPhaseData,
|
|
@ -23,7 +23,7 @@ import {
|
|||
import { toasts } from '../../../../services/notification';
|
||||
import { addLifecyclePolicyToTemplate, loadIndexTemplates } from '../../../../services/api';
|
||||
import { showApiError } from '../../../../services/api_errors';
|
||||
import { LearnMoreLink } from '../../../components/learn_more_link';
|
||||
import { LearnMoreLink } from '../../../edit_policy/components';
|
||||
|
||||
export class AddPolicyToTemplateConfirmModal extends Component {
|
||||
state = {
|
||||
|
|
|
@ -4,8 +4,5 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { createAction } from 'redux-actions';
|
||||
import { SET_SELECTED_NODE_ATTRS } from '../../constants';
|
||||
|
||||
export const setSelectedNodeAttrs = createAction(SET_SELECTED_NODE_ATTRS);
|
||||
export const setSelectedPrimaryShardCount = createAction('SET_SELECTED_PRIMARY_SHARED_COUNT');
|
||||
export const setSelectedReplicaCount = createAction('SET_SELECTED_REPLICA_COUNT');
|
||||
|
|
Loading…
Reference in a new issue