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 (#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: #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]>
  • Loading branch information
3 people authored Jun 8, 2023
1 parent 5bb0a05 commit d9eff3f
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 d9eff3f

Please sign in to comment.