Skip to content

Commit

Permalink
[ILM] Adjust alignment of field errors + timeline icon (#104084)
Browse files Browse the repository at this point in the history
* adjust alignment of field errors + timeline icon

* Use options popover instead of two continuous inputs

* Set max row size

* Reduce error callout size to s

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
sabarasaba and kibanamachine committed Jul 30, 2021
1 parent 0ae2134 commit f079775
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,65 @@ const createSetPrimaryShardSizeAction = (testBed: TestBed) => async (
units?: string
) => {
const { find, component } = testBed;

await act(async () => {
find('hot-selectedMaxPrimaryShardSize').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxPrimaryShardSize.select').simulate('change', {
target: { value: units },
});
}
});
component.update();

if (units) {
act(() => {
find('hot-selectedMaxPrimaryShardSize.show-filters-button').simulate('click');
});
component.update();

act(() => {
find(`hot-selectedMaxPrimaryShardSize.filter-option-${units}`).simulate('click');
});
component.update();
}
};

const createSetMaxAgeAction = (testBed: TestBed) => async (value: string, units?: string) => {
const { find, component } = testBed;

await act(async () => {
find('hot-selectedMaxAge').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxAgeUnits.select').simulate('change', { target: { value: units } });
}
});
component.update();

if (units) {
act(() => {
find('hot-selectedMaxAgeUnits.show-filters-button').simulate('click');
});
component.update();

act(() => {
find(`hot-selectedMaxAgeUnits.filter-option-${units}`).simulate('click');
});
component.update();
}
};

const createSetMaxSizeAction = (testBed: TestBed) => async (value: string, units?: string) => {
const { find, component } = testBed;

await act(async () => {
find('hot-selectedMaxSizeStored').simulate('change', { target: { value } });
if (units) {
find('hot-selectedMaxSizeStoredUnits.select').simulate('change', {
target: { value: units },
});
}
});
component.update();

if (units) {
act(() => {
find('hot-selectedMaxSizeStoredUnits.show-filters-button').simulate('click');
});
component.update();

act(() => {
find(`hot-selectedMaxSizeStoredUnits.filter-option-${units}`).simulate('click');
});
component.update();
}
};

export const createRolloverActions = (testBed: TestBed) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,39 @@ import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

import { NumericField, SelectField } from '../../../../../../../shared_imports';
import { NumericField } from '../../../../../../../shared_imports';
import { UseField } from '../../../../form';
import { ROLLOVER_FORM_PATHS } from '../../../../constants';
import { UnitField } from './unit_field';

import { maxAgeUnits } from '../constants';

export const MaxAgeField: FunctionComponent = () => {
return (
<EuiFlexGroup alignItems="flexEnd" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 188 }}>
<EuiFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 400 }}>
<UseField
path={ROLLOVER_FORM_PATHS.maxAge}
component={NumericField}
componentProps={{
euiFieldProps: {
'data-test-subj': `hot-selectedMaxAge`,
min: 1,
},
}}
/>
</EuiFlexItem>
<EuiFlexItem style={{ maxWidth: 188 }}>
<UseField
key="_meta.hot.customRollover.maxAgeUnit"
path="_meta.hot.customRollover.maxAgeUnit"
component={SelectField}
componentProps={{
'data-test-subj': `hot-selectedMaxAgeUnits`,
hasEmptyLabelSpace: true,
euiFieldProps: {
'aria-label': i18n.translate(
'xpack.indexLifecycleMgmt.hotPhase.maximumAgeUnitsAriaLabel',
{
defaultMessage: 'Maximum age units',
}
append: (
<UnitField
path="_meta.hot.customRollover.maxAgeUnit"
options={maxAgeUnits}
euiFieldProps={{
'data-test-subj': 'hot-selectedMaxAgeUnits',
'aria-label': i18n.translate(
'xpack.indexLifecycleMgmt.hotPhase.maximumAgeUnitsAriaLabel',
{
defaultMessage: 'Maximum age units',
}
),
}}
/>
),
options: maxAgeUnits,
},
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { ROLLOVER_FORM_PATHS } from '../../../../constants';

export const MaxDocumentCountField: FunctionComponent = () => {
return (
<EuiFlexGroup alignItems="flexEnd" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 188 }}>
<EuiFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 400 }}>
<UseField
path={ROLLOVER_FORM_PATHS.maxDocs}
component={NumericField}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiIconTip } from '@elastic/eui';

import { NumericField, SelectField } from '../../../../../../../shared_imports';
import { NumericField } from '../../../../../../../shared_imports';
import { UseField } from '../../../../form';
import { ROLLOVER_FORM_PATHS } from '../../../../constants';
import { UnitField } from './unit_field';

import { maxSizeStoredUnits } from '../constants';

Expand All @@ -32,37 +33,32 @@ const i18nTexts = {

export const MaxIndexSizeField: FunctionComponent = () => {
return (
<EuiFlexGroup alignItems="flexEnd" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 188 }}>
<EuiFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 400 }}>
<UseField
path={ROLLOVER_FORM_PATHS.maxSize}
component={NumericField}
componentProps={{
euiFieldProps: {
'data-test-subj': 'hot-selectedMaxSizeStored',
min: 1,
prepend: (
<EuiIconTip
type="alert"
aria-label={i18nTexts.deprecationMessage}
content={i18nTexts.deprecationMessage}
/>
),
min: 1,
},
}}
/>
</EuiFlexItem>
<EuiFlexItem style={{ maxWidth: 188 }}>
<UseField
key="_meta.hot.customRollover.maxStorageSizeUnit"
path="_meta.hot.customRollover.maxStorageSizeUnit"
component={SelectField}
componentProps={{
'data-test-subj': `hot-selectedMaxSizeStoredUnits`,
hasEmptyLabelSpace: true,
euiFieldProps: {
options: maxSizeStoredUnits,
'aria-label': i18nTexts.maxSizeUnit.ariaLabel,
append: (
<UnitField
path="_meta.hot.customRollover.maxStorageSizeUnit"
options={maxSizeStoredUnits}
euiFieldProps={{
'data-test-subj': 'hot-selectedMaxSizeStoredUnits',
'aria-label': i18nTexts.maxSizeUnit.ariaLabel,
}}
/>
),
},
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,38 @@ import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';

import { NumericField, SelectField } from '../../../../../../../shared_imports';
import { NumericField } from '../../../../../../../shared_imports';
import { UseField } from '../../../../form';
import { ROLLOVER_FORM_PATHS } from '../../../../constants';
import { UnitField } from './unit_field';

import { maxSizeStoredUnits } from '../constants';

export const MaxPrimaryShardSizeField: FunctionComponent = () => {
return (
<EuiFlexGroup alignItems="flexEnd" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 188 }}>
<EuiFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem style={{ maxWidth: 400 }}>
<UseField
path={ROLLOVER_FORM_PATHS.maxPrimaryShardSize}
component={NumericField}
componentProps={{
euiFieldProps: {
'data-test-subj': 'hot-selectedMaxPrimaryShardSize',
min: 1,
},
}}
/>
</EuiFlexItem>
<EuiFlexItem style={{ maxWidth: 188 }}>
<UseField
key="_meta.hot.customRollover.maxPrimaryShardSizeUnit"
path="_meta.hot.customRollover.maxPrimaryShardSizeUnit"
component={SelectField}
componentProps={{
'data-test-subj': `hot-selectedMaxPrimaryShardSizeUnits`,
hasEmptyLabelSpace: true,
euiFieldProps: {
options: maxSizeStoredUnits,
'aria-label': i18n.translate(
'xpack.indexLifecycleMgmt.hotPhase.maximumPrimaryShardSizeAriaLabel',
{
defaultMessage: 'Maximum primary shard size units',
}
append: (
<UnitField
path="_meta.hot.customRollover.maxPrimaryShardSizeUnit"
options={maxSizeStoredUnits}
euiFieldProps={{
'data-test-subj': 'hot-selectedMaxPrimaryShardSizeUnits',
'aria-label': i18n.translate(
'xpack.indexLifecycleMgmt.hotPhase.maximumPrimaryShardSizeAriaLabel',
{
defaultMessage: 'Maximum primary shard size units',
}
),
}}
/>
),
},
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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, useState } from 'react';
import { EuiFilterSelectItem, EuiPopover, EuiButtonEmpty } from '@elastic/eui';

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

interface Props {
path: string;
euiFieldProps?: Record<string, any>;
options: Array<{
value: string;
text: string;
}>;
}

export const UnitField: FunctionComponent<Props> = ({ path, options, euiFieldProps }) => {
const [open, setOpen] = useState(false);

return (
<UseField key={path} path={path}>
{(field) => {
const onSelect = (option: string) => {
field.setValue(option);
setOpen(false);
};

return (
<EuiPopover
button={
<EuiButtonEmpty
size="xs"
color="text"
iconSide="right"
iconType="arrowDown"
onClick={() => setOpen((x) => !x)}
data-test-subj="show-filters-button"
>
{options.find((x) => x.value === field.value)?.text}
</EuiButtonEmpty>
}
ownFocus
panelPaddingSize="none"
isOpen={open}
closePopover={() => setOpen(false)}
{...euiFieldProps}
>
{options.map((item) => (
<EuiFilterSelectItem
key={item.value}
checked={field.value === item.value ? 'on' : undefined}
onClick={() => onSelect(item.value)}
data-test-subj={`filter-option-${item.value}`}
>
{item.text}
</EuiFilterSelectItem>
))}
</EuiPopover>
);
}}
</UseField>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const HotPhase: FunctionComponent = () => {
{showEmptyRolloverFieldsError && (
<>
<EuiCallOut
size="s"
title={i18nTexts.editPolicy.errors.rollOverConfigurationCallout.title}
data-test-subj="rolloverSettingsRequired"
color="danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $ilmTimelineBarHeight: $euiSizeS;
*/
display: inline-block;
width: 100%;
margin-top: $euiSizeS;

&__phase:first-child {
padding-left: 0;
Expand Down

0 comments on commit f079775

Please sign in to comment.