[RAM] Conditional actions feedback on pr review (#155804)

## Summary

- Fixes:
https://github.com/elastic/kibana/pull/155384#discussion_r1175847253
- 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 <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Xavier Mouligneau 2023-04-26 07:53:49 -04:00 committed by GitHub
parent c640c25c74
commit 57f3b38324
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 10 deletions

View file

@ -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)"'
);
});

View file

@ -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

View file

@ -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();
@ -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();

View file

@ -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}

View file

@ -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',
@ -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]
);
@ -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}

View file

@ -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) => {