From d9eff3fd84c7eb9da0f3d3e1106d6054b3a4cad7 Mon Sep 17 00:00:00 2001 From: GitStart <1501599+gitstart@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:57:03 +0100 Subject: [PATCH] [Security Solution] Able to add Same Start Time and End Time in Schedule for Snooze Notifications of Rule (#158565) ## What does this PR do? * It doesn't allows the user to pick the same date and time in the schedule component. ## Issue References * Client: https://github.com/elastic/kibana/issues/157865 ## Video/Screenshot Demo ###### FIX: https://www.loom.com/share/fc4a43eba71f485384621ecec457ce1a --- This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time. Co-authored-by: KlingerMatheus Co-authored-by: gitstart_bot --- .../rules_list/components/rule_snooze/scheduler.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx index 917e232e3f0f3..488140660f4ea 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_snooze/scheduler.tsx @@ -200,7 +200,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ ); const selectEndDT = useCallback( (date) => { - setEndDT(date); + setEndDT(date.add(1, 'minutes')); setSelectingEndTime(true); setSelectingEndDate(false); }, @@ -210,8 +210,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ const onSelectFromInline = useCallback( (date) => { const dateAsMoment = moment(date); - const newDateAfterStart = - !startDT || dateAsMoment.isAfter(startDT) || dateAsMoment.isSame(startDT); + const newDateAfterStart = !startDT || dateAsMoment.isSameOrAfter(startDT); const isEndDateTimeChange = dateAsMoment.isSame(endDT, 'day') && !dateAsMoment.isSame(endDT, 'minute'); const isStartDateTimeChange = @@ -309,7 +308,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({ selected={endDT} onChange={setEndDT} minDate={startDT ?? minDate} - isInvalid={startDT?.isAfter(endDT)} + isInvalid={startDT?.isSameOrAfter(endDT)} /> } /> @@ -376,7 +375,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent = ({