Skip to content

Commit

Permalink
[RAM] Conditional actions feedback on pr review (#155804)
Browse files Browse the repository at this point in the history
## Summary

- Fixes:
#155384 (comment)
- Fixes language around conditional filter to not confuse our user like
it was before

<img width="756" alt="image"
src="https://user-images.githubusercontent.com/189600/234410455-a577d5a7-afc7-489d-b37d-96a6487c2e31.png">


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
XavierM and kibanamachine authored Apr 26, 2023
1 parent c640c25 commit 57f3b38
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('validateActions', () => {
false
)
).rejects.toThrowErrorMatchingInlineSnapshot(
'"Failed to validate actions due to the following error: Action throttle cannot be shorter than the schedule interval of 1m: default (1s)"'
'"Failed to validate actions due to the following error: Action frequency cannot be shorter than the schedule interval of 1m: default (1s)"'
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function validateActions(
errors.push(
i18n.translate('xpack.alerting.rulesClient.validateActions.actionsWithInvalidThrottles', {
defaultMessage:
'Action throttle cannot be shorter than the schedule interval of {scheduleIntervalText}: {groups}',
'Action frequency cannot be shorter than the schedule interval of {scheduleIntervalText}: {groups}',
values: {
scheduleIntervalText: data.schedule.interval,
groups: actionsWithInvalidThrottles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,7 @@ describe('create()', () => {
],
});
await expect(rulesClient.create({ data })).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to validate actions due to the following error: Action throttle cannot be shorter than the schedule interval of 3h: default (1h), group2 (3m)"`
`"Failed to validate actions due to the following error: Action frequency cannot be shorter than the schedule interval of 3h: default (1h), group2 (3m)"`
);
expect(unsecuredSavedObjectsClient.create).not.toHaveBeenCalled();
expect(taskManager.schedule).not.toHaveBeenCalled();
Expand Down Expand Up @@ -3122,7 +3122,7 @@ describe('create()', () => {
await expect(rulesClient.create({ data })).rejects.toThrowErrorMatchingInlineSnapshot(`
"Failed to validate actions due to the following 2 errors:
- Actions missing frequency parameters: group3
- Action throttle cannot be shorter than the schedule interval of 3h: default (1h), group2 (3m)"
- Action frequency cannot be shorter than the schedule interval of 3h: default (1h), group2 (3m)"
`);
expect(unsecuredSavedObjectsClient.create).not.toHaveBeenCalled();
expect(taskManager.schedule).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ActionAlertsFilterQuery: React.FC<ActionAlertsFilterQueryProps> = (
label={i18n.translate(
'xpack.triggersActionsUI.sections.actionTypeForm.ActionAlertsFilterQueryToggleLabel',
{
defaultMessage: 'Send alert notification only if alert fields match a query',
defaultMessage: 'if alert matches a query',
}
)}
checked={queryEnabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const useDefaultTimezone = () => {
const useTimeframe = (initialTimeframe?: AlertsFilterTimeframe) => {
const timezone = useDefaultTimezone();
const DEFAULT_TIMEFRAME = {
days: [],
days: ISO_WEEKDAYS,
timezone,
hours: {
start: '00:00',
Expand Down Expand Up @@ -114,7 +114,9 @@ export const ActionAlertsFilterTimeframe: React.FC<ActionAlertsFilterTimeframePr
const newDays = previouslyHasDay
? timeframe.days.filter((d) => d !== day)
: [...timeframe.days, day];
updateTimeframe({ days: newDays });
if (newDays.length !== 0) {
updateTimeframe({ days: newDays });
}
},
[timeframe, updateTimeframe]
);
Expand Down Expand Up @@ -144,7 +146,7 @@ export const ActionAlertsFilterTimeframe: React.FC<ActionAlertsFilterTimeframePr
label={i18n.translate(
'xpack.triggersActionsUI.sections.actionTypeForm.ActionAlertsFilterTimeframeToggleLabel',
{
defaultMessage: 'Send alert notification within the selected time frame only',
defaultMessage: 'if alert is generated during timeframe',
}
)}
checked={timeframeEnabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ export const ActionNotifyWhen = ({
name="throttle"
data-test-subj="throttleInput"
prepend={i18n.translate(
'xpack.triggersActionsUI.sections.ruleForm.ruleNotifyWhen.label',
'xpack.triggersActionsUI.sections.ruleForm.frequencyNotifyWhen.label',
{
defaultMessage: 'Every',
defaultMessage: 'Run action every',
}
)}
onChange={(e) => {
Expand Down

0 comments on commit 57f3b38

Please sign in to comment.