Skip to content

Commit

Permalink
[8.8] [Security Solution] Able to add Same Start Time and End Time in…
Browse files Browse the repository at this point in the history
… Schedule for Snooze Notifications of Rule (#158565) (#159331)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Security Solution] Able to add Same Start Time and End Time in
Schedule for Snooze Notifications of Rule
(#158565)](#158565)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"GitStart","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-08T15:57:03Z","message":"[Security
Solution] Able to add Same Start Time and End Time in Schedule for
Snooze Notifications of Rule (#158565)\n\n## What does this PR do?\r\n*
It doesn't allows the user to pick the same date and time in
the\r\nschedule component.\r\n\r\n## Issue References\r\n* Client:
https://github.com/elastic/kibana/issues/157865\r\n\r\n##
Video/Screenshot Demo \r\n\r\n######
FIX:\r\nhttps://www.loom.com/share/fc4a43eba71f485384621ecec457ce1a\r\n\r\n---\r\nThis
code was written and reviewed by GitStart Community. Growing
great\r\nengineers, one PR at a time.\r\n\r\nCo-authored-by:
KlingerMatheus <[email protected]>\r\nCo-authored-by:
gitstart_bot
<[email protected]>","sha":"d9eff3fd84c7eb9da0f3d3e1106d6054b3a4cad7","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","💝community","v8.9.0","v8.8.2"],"number":158565,"url":"https://github.com/elastic/kibana/pull/158565","mergeCommit":{"message":"[Security
Solution] Able to add Same Start Time and End Time in Schedule for
Snooze Notifications of Rule (#158565)\n\n## What does this PR do?\r\n*
It doesn't allows the user to pick the same date and time in
the\r\nschedule component.\r\n\r\n## Issue References\r\n* Client:
https://github.com/elastic/kibana/issues/157865\r\n\r\n##
Video/Screenshot Demo \r\n\r\n######
FIX:\r\nhttps://www.loom.com/share/fc4a43eba71f485384621ecec457ce1a\r\n\r\n---\r\nThis
code was written and reviewed by GitStart Community. Growing
great\r\nengineers, one PR at a time.\r\n\r\nCo-authored-by:
KlingerMatheus <[email protected]>\r\nCo-authored-by:
gitstart_bot
<[email protected]>","sha":"d9eff3fd84c7eb9da0f3d3e1106d6054b3a4cad7"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158565","number":158565,"mergeCommit":{"message":"[Security
Solution] Able to add Same Start Time and End Time in Schedule for
Snooze Notifications of Rule (#158565)\n\n## What does this PR do?\r\n*
It doesn't allows the user to pick the same date and time in
the\r\nschedule component.\r\n\r\n## Issue References\r\n* Client:
https://github.com/elastic/kibana/issues/157865\r\n\r\n##
Video/Screenshot Demo \r\n\r\n######
FIX:\r\nhttps://www.loom.com/share/fc4a43eba71f485384621ecec457ce1a\r\n\r\n---\r\nThis
code was written and reviewed by GitStart Community. Growing
great\r\nengineers, one PR at a time.\r\n\r\nCo-authored-by:
KlingerMatheus <[email protected]>\r\nCo-authored-by:
gitstart_bot
<[email protected]>","sha":"d9eff3fd84c7eb9da0f3d3e1106d6054b3a4cad7"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: GitStart <[email protected]>
  • Loading branch information
kibanamachine and gitstart authored Jun 8, 2023
1 parent 16e8c8f commit 97bb42c
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 97bb42c

Please sign in to comment.