From 05e1afb10870dbab88d855e2c3a7928a90764263 Mon Sep 17 00:00:00 2001 From: Saurabh Bhagwan Sathe Date: Thu, 15 Feb 2024 14:13:46 +0530 Subject: [PATCH] INFRA-2803 | Saurabh | De-escalation justification message (#128) * INFRA-2803 | Saurabh | Added textarea for justification message * INFRA-2803 | Saurabh | Showing the message in activiy log * INFRA-2803 | Saurabh | Added max character limit and footer updated with tooltip * INFRA-2803 | Saurabh | wrapped using break word * INFRA-2803 | Saurabh | styles in css * INFRA-2803 | Saurabh | custom Footer class created * INFRA-2803 | Saurabh | comments resolved --- .../Incidents/Dropdowns/AllDailogBox.tsx | 94 +++++++++++++++---- .../Incidents/IncidentInfo/UpdateInfo.tsx | 20 +++- src/Pages/Incidents/Incidents.module.scss | 25 +++++ .../StepperAssets/IncidentChange.tsx | 1 + src/Pages/Incidents/constants.ts | 20 ++++ src/Pages/Incidents/types.ts | 1 + src/Pages/TeamRevamp/useTeamApis.tsx | 1 - src/types/index.d.ts | 1 + 8 files changed, 140 insertions(+), 23 deletions(-) diff --git a/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx b/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx index faf6669..5b2997c 100644 --- a/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx +++ b/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx @@ -7,6 +7,7 @@ import { ModalDialog, Typography, Button, + Tooltip, } from '@navi/web-ui/lib/primitives'; import { toast } from '@navi/web-ui/lib/primitives/Toast'; import GoToLinkIcon from '@src/assets/GoToLinkIcon'; @@ -25,6 +26,7 @@ import { initialState, incidentRegrex, RESOLVE_STATUS, + getSeverityValue, } from '../constants'; import useIncidentApis from '../useIncidentApis'; import styles from '../Incidents.module.scss'; @@ -57,6 +59,13 @@ const AllDailogBox: FC = () => { const incidentId = incidentData?.id?.toString() || ''; const reduxDispatch = useDispatch(); + const updateDetailsFrom = getSeverityValue(UpdateData?.from?.trim() || ''); + const updateDetailsTo = ( + UpdateData as { to?: { value: string; label: string } } + )?.to?.value; + const showJustificationBox: boolean = + updateDetailsFrom < (updateDetailsTo || '-1') || false; + const handleopenNotParticipants = (): void => { reduxDispatch(setOpenDialognotParticipants(false)); }; @@ -97,6 +106,15 @@ const AllDailogBox: FC = () => { }); }; + const handleReasonChange = ( + e: React.ChangeEvent, + ): void => { + dispatch({ + type: actionTypes.SET_REASON, + payload: e.target.value, + }); + }; + const validateIncidentID = (value: string): void => { dispatch({ type: actionTypes.SET_ERROR_MSG, @@ -105,6 +123,12 @@ const AllDailogBox: FC = () => { : '', }); }; + + const handleUpdateIncidentClick = (): void => { + reduxDispatch(setOpenDialogUpdate(false)); + handleCloseConfirmationDialog(); + }; + const validate = (value: string): boolean => incidentRegrex.test(value); const isDisabled = (): boolean => { const incidentId = extractIncidentId(state.incidentName); @@ -132,10 +156,23 @@ const AllDailogBox: FC = () => { const value = Array.isArray(selectedOption) ? selectedOption[0].value : selectedOption.value; - updateIncident({ - id: parseInt(incidentId, 10), - severityId: value.toString(), - }); + + if (showJustificationBox) { + updateIncident({ + id: parseInt(incidentId, 10), + severityId: value.toString(), + justification: state.reason, + }); + dispatch({ + type: actionTypes.SET_REASON, + payload: '', + }); + } else { + updateIncident({ + id: parseInt(incidentId, 10), + severityId: value.toString(), + }); + } } }; const handleStatusSelectionChange = ( @@ -321,26 +358,26 @@ const AllDailogBox: FC = () => { ); + const customFooter = (): JSX.Element => ( +
+ {UpdateData.type === 'severity' && + showJustificationBox && + state.reason.length <= 0 ? ( + + + + ) : ( + + )} +
+ ); + const renderUpdateDialog = (): JSX.Element => (
{openUpdate ? ( { - reduxDispatch(setOpenDialogUpdate(false)); - }, - }, - { - label: 'Update incident', - onClick: () => { - reduxDispatch(setOpenDialogUpdate(false)); - handleCloseConfirmationDialog(); - }, - }, - ]} + customFooter={customFooter()} header={`Are you sure you want to update the incident?`} onClose={() => reduxDispatch(setOpenDialogUpdate(false))} > @@ -365,6 +402,25 @@ const AllDailogBox: FC = () => { {getLabelFromOption(UpdateData?.to) || '..'} + {UpdateData.type === 'severity' && showJustificationBox ? ( +
+