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

[ILM] Delete phase redesign (rework) #90291

Merged
merged 6 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,27 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
};
};

const createToggleDeletePhaseActions = () => {
const enablePhase = async () => {
await act(async () => {
find('enableDeletePhaseLink').simulate('click');
});
component.update();
};

const disablePhase = async () => {
await act(async () => {
find('disableDeletePhaseButton').simulate('click');
});
component.update();
};

return {
enablePhase,
disablePhase,
};
};

return {
...testBed,
actions: {
Expand Down Expand Up @@ -303,7 +324,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
...createSearchableSnapshotActions('cold'),
},
delete: {
enable: enable('delete'),
...createToggleDeletePhaseActions(),
setMinAgeValue: setMinAgeValue('delete'),
setMinAgeUnits: setMinAgeUnits('delete'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('<EditPolicy />', () => {
// Set max docs to test whether we keep the unknown fields in that object after serializing
await actions.hot.setMaxDocs('1000');
// Remove the delete phase to ensure that we also correctly remove data
await actions.delete.enable(false);
await actions.delete.disablePhase();
await actions.savePolicy();

const latestRequest = server.requests[server.requests.length - 1];
Expand Down Expand Up @@ -839,7 +839,7 @@ describe('<EditPolicy />', () => {
expect(actions.timeline.hasColdPhase()).toBe(true);
expect(actions.timeline.hasDeletePhase()).toBe(false);

await actions.delete.enable(true);
await actions.delete.enablePhase();
expect(actions.timeline.hasHotPhase()).toBe(true);
expect(actions.timeline.hasWarmPhase()).toBe(true);
expect(actions.timeline.hasColdPhase()).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ const activatePhase = async (rendered: ReactWrapper, phase: string) => {
});
rendered.update();
};
const activateDeletePhase = async (rendered: ReactWrapper) => {
const testSubject = `enableDeletePhaseLink`;
await act(async () => {
await findTestSubject(rendered, testSubject).simulate('click');
});
rendered.update();
};
const openNodeAttributesSection = async (rendered: ReactWrapper, phase: string) => {
const getControls = () => findTestSubject(rendered, `${phase}-dataTierAllocationControls`);
await act(async () => {
Expand Down Expand Up @@ -813,7 +820,7 @@ describe('edit policy', () => {
const rendered = mountWithIntl(component);
await noRollover(rendered);
await setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'delete');
await activateDeletePhase(rendered);
await setPhaseAfter(rendered, 'delete', '0');
waitForFormLibValidation(rendered);
expectedErrorMessages(rendered, []);
Expand All @@ -822,7 +829,7 @@ describe('edit policy', () => {
const rendered = mountWithIntl(component);
await noRollover(rendered);
await setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'delete');
await activateDeletePhase(rendered);
await setPhaseAfter(rendered, 'delete', '-1');
waitForFormLibValidation(rendered);
expectedErrorMessages(rendered, [i18nTexts.editPolicy.errors.nonNegativeNumberRequired]);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
* 2.0.
*/

export { ActiveBadge } from './active_badge';
export { LearnMoreLink } from './learn_more_link';
export { OptionalLabel } from './optional_label';
export { PolicyJsonFlyout } from './policy_json_flyout';
export { DescribedFormRow, ToggleFieldWithDescribedFormRow } from './described_form_row';
export { FieldLoadingError } from './field_loading_error';
export { ActiveHighlight } from './active_highlight';
export { Timeline } from './timeline';
export { FormErrorsCallout } from './form_errors_callout';

export { PhaseFooter } from './phase_footer';
export * from './phases';
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* 2.0.
*/

export { ActiveHighlight } from './active_highlight';
export { InfinityIcon } from './infinity_icon';
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
*/

import React, { FunctionComponent } from 'react';
import { EuiIcon, EuiIconProps } from '@elastic/eui';
import { InfinityIconSvg } from './infinity_icon.svg';

import './active_highlight.scss';

interface Props {
phase: 'hot' | 'warm' | 'cold';
enabled: boolean;
}
export const ActiveHighlight: FunctionComponent<Props> = ({ phase, enabled }) => {
return <div className={`ilmActivePhaseHighlight ${phase}Phase ${enabled ? 'active' : ''} `} />;
};
export const InfinityIcon: FunctionComponent<Omit<EuiIconProps, 'type'>> = (props) => (
<EuiIcon type={InfinityIconSvg} {...props} />
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export { PhaseFooter } from './phase_footer';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.euiPanel.ilmPhaseFooter {
padding-top: $euiSizeS;
padding-bottom: $euiSizeS;
border: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* 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 React, { FunctionComponent } from 'react';

import { FormattedMessage } from '@kbn/i18n/react';

import { EuiIcon, EuiText, EuiLink, EuiPanel } from '@elastic/eui';

import { PhasesExceptDelete } from '../../../../../../common/types';

import { usePhaseTimings } from '../../form';

import { InfinityIcon } from '../infinity_icon';
import './phase_footer.scss';

interface Props {
phase: PhasesExceptDelete;
}

export const PhaseFooter: FunctionComponent<Props> = ({ phase }) => {
const phaseTimings = usePhaseTimings();
const phaseConfiguration = phaseTimings[phase];
const setValue = phaseTimings.setDeletePhaseEnabled;

if (phaseConfiguration === 'disabled' || phaseConfiguration === 'enabled') {
return (
<EuiPanel className={'ilmPhaseFooter'} hasShadow={false}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; here and elsewhere. the convention for fixed string-literal props is:

className="ilmPhaseFooter" // without curly braces, with double quotes

I think this is perhaps webstorm specific behaviour as I recall running into it there. If you're using webstorm I managed to disable auto-bracket insertion for JSX by following this issue: https://youtrack.jetbrains.com/issue/WEB-31288?_ga=2.14889842.555971730.1612525382-1881428346.1584373905

<EuiText size={'s'}>&nbsp;</EuiText>
</EuiPanel>
);
}

if (phaseConfiguration === 'forever') {
return (
<EuiPanel color={'subdued'} className={'ilmPhaseFooter'} hasShadow={false}>
<InfinityIcon size={'s'} />{' '}
<EuiText size={'s'} grow={false} className={'eui-displayInlineBlock'}>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.phaseTiming.foreverTimingDescription"
defaultMessage="Data will remain in this phase forever."
/>{' '}
<EuiLink onClick={() => setValue(true)} data-test-subj={'enableDeletePhaseLink'}>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.deletePhase.enablePhaseButtonLabel"
defaultMessage="Set delete age"
/>
</EuiLink>
</EuiText>
</EuiPanel>
);
}

return (
<EuiPanel color={'subdued'} className={'ilmPhaseFooter'} hasShadow={false}>
<EuiIcon type={'storage'} size={'s'} />{' '}
<EuiText size={'s'} grow={false} className={'eui-displayInlineBlock'}>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.phaseTiming.beforeDeleteDescription"
defaultMessage="Data will be deleted after this phase."
/>{' '}
<EuiLink onClick={() => setValue(false)} data-test-subj={'disableDeletePhaseLink'}>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.deletePhase.disablePhaseButtonLabel"
defaultMessage="Keep data"
/>
</EuiLink>
</EuiText>
</EuiPanel>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export { PhaseIcon } from './phase_icon';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.ilmPhaseIcon {
width: 32px;
height: 32px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
width: 32px;
height: 32px;
width: $euiSizeXL;
height: $euiSizeXL;

display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
background-color: $euiColorLightestShade;
&--delete {
background-color: $euiColorLightShade;
}
&__inner--hot {
fill: $euiColorVis9_behindText;
}
&__inner--warm {
fill: $euiColorVis5_behindText;
}
&__inner--cold {
fill: $euiColorVis1_behindText;
}
&__inner--delete {
fill: $euiColorDarkShade;
}

&__inner--disabled {
fill: $euiColorMediumShade;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 React, { FunctionComponent } from 'react';
import { EuiIcon } from '@elastic/eui';
import { Phases } from '../../../../../../common/types';
import './phase_icon.scss';
interface Props {
enabled: boolean;
phase: string & keyof Phases;
}
export const PhaseIcon: FunctionComponent<Props> = ({ enabled, phase }) => {
return (
<div
className={`ilmPhaseIcon ilmPhaseIcon--${phase} ${enabled ? '' : 'ilmPhaseIcon--disabled'}`}
>
{enabled ? (
<EuiIcon
className={`ilmPhaseIcon__inner--${phase}`}
type={phase === 'delete' ? 'trash' : 'checkInCircleFilled'}
size={phase === 'delete' ? 'm' : 'l'}
/>
) : (
<EuiIcon className="ilmPhaseIcon__inner--disabled" type={'dot'} size={'l'} />
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.ilmDeletePhase {
.euiCommentEvent {
&__header {
padding: $euiSize;
background-color: $euiColorEmptyShade;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
background-color: $euiColorEmptyShade;
background-color: $euiColorEmptyShade;

}
&__body {
padding: $euiSize;
background-color: $euiColorLightestShade;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
background-color: $euiColorLightestShade;
background-color: $euiColorLightestShade;

}

}
}
Loading