Skip to content

Commit

Permalink
[Security Solution] Able to add Same Start Time and End Time in Sched…
Browse files Browse the repository at this point in the history
…ule for Snooze Notifications of Rule (elastic#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: elastic#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 <[email protected]>
Co-authored-by: gitstart_bot <[email protected]>
(cherry picked from commit d9eff3f)
  • Loading branch information
gitstart committed Jun 8, 2023
1 parent 57149aa commit 90372f3
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent<PanelOpts> = ({
);
const selectEndDT = useCallback(
(date) => {
setEndDT(date);
setEndDT(date.add(1, 'minutes'));
setSelectingEndTime(true);
setSelectingEndDate(false);
},
Expand All @@ -210,8 +210,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent<PanelOpts> = ({
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 =
Expand Down Expand Up @@ -309,7 +308,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent<PanelOpts> = ({
selected={endDT}
onChange={setEndDT}
minDate={startDT ?? minDate}
isInvalid={startDT?.isAfter(endDT)}
isInvalid={startDT?.isSameOrAfter(endDT)}
/>
}
/>
Expand Down Expand Up @@ -376,7 +375,7 @@ const RuleSnoozeSchedulerPanel: React.FunctionComponent<PanelOpts> = ({
<EuiButton
fill
fullWidth
disabled={!startDT || !endDT || startDT.isAfter(endDT) || startDT.isBefore(minDate)}
disabled={!startDT || !endDT || startDT.isSameOrAfter(endDT) || startDT.isBefore(minDate)}
onClick={onClickSaveSchedule}
isLoading={isLoading}
data-test-subj="scheduler-saveSchedule"
Expand Down

0 comments on commit 90372f3

Please sign in to comment.