Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -29,12 +29,12 @@ export const Default: Story = {
data_retention: '30d',
downsample: [
{
after: '30d',
after: '5d',
fixed_interval: '1h',
},
{
after: '40d',
fixed_interval: '5d',
after: '10d',
fixed_interval: '2h',
},
],
},
Expand Down Expand Up @@ -111,10 +111,10 @@ export const StepSyncing: Story = {
const [isOpen, setIsOpen] = useState(false);
const [steps, setSteps] = useState<IngestStreamLifecycleDSL>({
dsl: {
data_retention: '30d',
data_retention: '90d',
downsample: [
{ after: '30d', fixed_interval: '1h' },
{ after: '40d', fixed_interval: '5d' },
{ after: '1h', fixed_interval: '1h' },
{ after: '2h', fixed_interval: '2h' },
],
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ export const AfterField = ({
return (
<EuiFormRow
label={i18n.translate('xpack.streams.editDslStepsFlyout.afterLabel', {
defaultMessage: 'Downsample after data stored',
defaultMessage: 'Downsample data after',
})}
helpText={isInvalid ? undefined : helpText}
helpText={helpText}
isInvalid={isInvalid}
error={isInvalid ? errorMessage : null}
>
Expand All @@ -206,7 +206,7 @@ export const AfterField = ({
aria-label={i18n.translate(
'xpack.streams.editDslStepsFlyout.afterAriaLabel',
{
defaultMessage: 'Downsample after value',
defaultMessage: 'Downsample data after value',
}
)}
value={currentValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,37 @@ export const FixedIntervalField = ({
unit: currentUnit,
});

const helpText =
upperBoundMs === undefined
? i18n.translate('xpack.streams.editDslStepsFlyout.fixedIntervalHelpLowerBound', {
defaultMessage: 'Must be larger than {min} based on current configuration.',
values: { min },
})
const showMultipleOfPreviousStep = stepIndex > 0 && lowerBoundMs > 0;
const helpText = (() => {
if (upperBoundMs === undefined) {
return showMultipleOfPreviousStep
? i18n.translate(
'xpack.streams.editDslStepsFlyout.fixedIntervalHelpLowerBoundMultiple',
{
defaultMessage:
'Must be larger than {min} and a multiple of {multipleOf} based on current configuration.',
values: { min, multipleOf: min },
}
)
: i18n.translate('xpack.streams.editDslStepsFlyout.fixedIntervalHelpLowerBound', {
defaultMessage: 'Must be larger than {min} based on current configuration.',
values: { min },
});
}

return showMultipleOfPreviousStep
? i18n.translate(
'xpack.streams.editDslStepsFlyout.fixedIntervalHelpRangeMultiple',
{
defaultMessage:
'Must be larger than {min}, smaller than {max}, and a multiple of {multipleOf} based on current configuration.',
values: {
min,
max,
multipleOf: min,
},
}
)
: i18n.translate('xpack.streams.editDslStepsFlyout.fixedIntervalHelpRange', {
defaultMessage:
'Must be larger than {min} and smaller than {max} based on current configuration.',
Expand All @@ -154,13 +179,14 @@ export const FixedIntervalField = ({
max,
},
});
})();

return (
<EuiFormRow
label={i18n.translate('xpack.streams.editDslStepsFlyout.fixedIntervalLabel', {
defaultMessage: 'Downsample interval',
})}
helpText={isInvalid ? undefined : helpText}
helpText={helpText}
isInvalid={isInvalid}
error={isInvalid ? errorMessage : null}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('streams DSL steps flyout validations', () => {
);

expect(result).toEqual({
message: 'Must be smaller than the data retention period (30d).',
message: 'Must not exceed the data retention period (30d).',
});
});

Expand All @@ -221,7 +221,7 @@ describe('streams DSL steps flyout validations', () => {
);

expect(result).toEqual({
message: 'Must be smaller than the data retention period (30d).',
message: 'Must not exceed the data retention period (30d).',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const afterSmallerThanDataRetention = ({
if (ms >= 0 && ms >= retentionMs) {
return {
message: i18n.translate('xpack.streams.editDslStepsFlyout.afterGreaterThanRetentionError', {
defaultMessage: 'Must be smaller than the data retention period ({retention}).',
defaultMessage: 'Must not exceed the data retention period ({retention}).',
values: { retention: retentionEsFormat },
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ export const StepPanel = ({
onClick={() => onRemoveStep(stepIndex)}
>
{i18n.translate('xpack.streams.editDslStepsFlyout.removeStep', {
defaultMessage: 'Remove step {stepNumber}',
values: { stepNumber },
defaultMessage: 'Remove this step',
})}
</EuiButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useMemo } from 'react';
import React, { useMemo, useRef } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiButtonIcon,
Expand Down Expand Up @@ -42,8 +42,9 @@ export const StepTabsRow = ({
tabHasErrors,
dataTestSubj,
}: StepTabsRowProps) => {
const tabsScrollCss = useEuiOverflowScroll('x', true);
const tabsScrollCss = useEuiOverflowScroll('x');
const { tabsContainerStyles, tabsErrorSelectedUnderlineStyles } = useStyles();
const tabRefs = useRef<Array<HTMLSpanElement | null>>([]);

const tabs = useMemo(() => {
return items.map((item, index) => {
Expand All @@ -54,31 +55,44 @@ export const StepTabsRow = ({
});

return (
<EuiTab
<span
key={item.id}
onClick={() => setSelectedStepIndex(index)}
isSelected={index === selectedStepIndex}
className={hasErrors ? 'streamsDslStepsTab--hasErrors' : undefined}
data-test-subj={`${dataTestSubj}Tab-step-${index + 1}`}
prepend={
hasErrors ? (
<EuiIcon
type="warning"
color="danger"
size="m"
aria-label={i18n.translate(
'xpack.streams.editDslStepsFlyout.stepTabHasErrorsIconAriaLabel',
{
defaultMessage: 'Step {stepNumber} has errors',
values: { stepNumber: index + 1 },
}
)}
/>
) : undefined
}
ref={(node) => {
tabRefs.current[index] = node;
if (node && selectedStepIndex === index) {
node.scrollIntoView?.({
behavior: 'smooth',
block: 'nearest',
inline: 'nearest',
});
}
}}
>
{hasErrors ? <EuiTextColor color="danger">{label}</EuiTextColor> : label}
</EuiTab>
<EuiTab
onClick={() => setSelectedStepIndex(index)}
isSelected={index === selectedStepIndex}
className={hasErrors ? 'streamsDslStepsTab--hasErrors' : undefined}
data-test-subj={`${dataTestSubj}Tab-step-${index + 1}`}
prepend={
hasErrors ? (
<EuiIcon
type="warning"
color="danger"
size="m"
aria-label={i18n.translate(
'xpack.streams.editDslStepsFlyout.stepTabHasErrorsIconAriaLabel',
{
defaultMessage: 'Step {stepNumber} has errors',
values: { stepNumber: index + 1 },
}
)}
/>
) : undefined
}
>
{hasErrors ? <EuiTextColor color="danger">{label}</EuiTextColor> : label}
</EuiTab>
</span>
);
});
}, [dataTestSubj, items, selectedStepIndex, setSelectedStepIndex, tabHasErrors]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,36 @@ export const DownsampleIntervalField = ({
unit: currentUnit,
});

const showMultipleOfPreviousPhase = lowerBoundMs > 0;
const helpText =
upperBoundMs === undefined
? showMultipleOfPreviousPhase
? i18n.translate(
'xpack.streams.editIlmPhasesFlyout.downsamplingIntervalHelpLowerBoundMultiple',
{
defaultMessage:
'Must be larger than {min} and a multiple of {multipleOf} based on current configuration.',
values: { min, multipleOf: min },
}
)
: i18n.translate(
'xpack.streams.editIlmPhasesFlyout.downsamplingIntervalHelpLowerBound',
{
defaultMessage: 'Must be larger than {min} based on current configuration.',
values: { min },
}
)
: showMultipleOfPreviousPhase
? i18n.translate(
'xpack.streams.editIlmPhasesFlyout.downsamplingIntervalHelpLowerBound',
'xpack.streams.editIlmPhasesFlyout.downsamplingIntervalHelpRangeMultiple',
{
defaultMessage: 'Must be larger than {min} based on current configuration.',
values: { min },
defaultMessage:
'Must be larger than {min}, smaller than {max}, and a multiple of {multipleOf} based on current configuration.',
values: {
min,
max,
multipleOf: min,
},
}
)
: i18n.translate(
Expand All @@ -120,7 +143,7 @@ export const DownsampleIntervalField = ({
defaultMessage: 'Interval',
}
)}
helpText={showInvalid ? undefined : helpText}
helpText={helpText}
isInvalid={showInvalid}
error={showError}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ export const MinAgeField = ({ phaseName, dataTestSubj, timeUnitOptions }: MinAge
defaultMessage: 'Delete after data stored',
})
: i18n.translate('xpack.streams.editIlmPhasesFlyout.moveAfterLabel', {
defaultMessage: 'Move after data stored',
defaultMessage: 'Move data after',
});

const fieldAriaLabel = isDeletePhase
? i18n.translate('xpack.streams.editIlmPhasesFlyout.deleteAfterAriaLabel', {
defaultMessage: 'Delete after value',
})
: i18n.translate('xpack.streams.editIlmPhasesFlyout.moveAfterAriaLabel', {
defaultMessage: 'Move after value',
defaultMessage: 'Move data after value',
});

return (
Expand Down Expand Up @@ -131,7 +131,7 @@ export const MinAgeField = ({ phaseName, dataTestSubj, timeUnitOptions }: MinAge
return (
<EuiFormRow
label={fieldLabel}
helpText={isInvalid ? undefined : helpText}
helpText={helpText}
isInvalid={isInvalid}
error={errorMessage}
>
Expand Down Expand Up @@ -162,7 +162,7 @@ export const MinAgeField = ({ phaseName, dataTestSubj, timeUnitOptions }: MinAge
aria-label={i18n.translate(
'xpack.streams.editIlmPhasesFlyout.moveAfterUnitAriaLabel',
{
defaultMessage: 'Move after unit',
defaultMessage: 'Move data after unit',
}
)}
options={unitOptions}
Expand Down
Loading
Loading