From 89041c0b273b460c2e2455bc52aa4ed8db0bc9ee Mon Sep 17 00:00:00 2001 From: AyushRanjan Date: Tue, 23 Jan 2024 23:11:59 +0530 Subject: [PATCH] TP-52973 | minor refinement --- src/Pages/Incidents/ActivityLog/index.tsx | 13 +- .../Incidents/DescriptionContent/index.tsx | 61 +-- .../Incidents/Dropdowns/AllDailogBox.tsx | 49 +- src/Pages/Incidents/Dropdowns/index.tsx | 430 +++++++----------- src/Pages/Incidents/Header/index.tsx | 9 +- .../Incidents/JiraLinks/JiraLinks.module.scss | 0 src/Pages/Incidents/JiraLinks/index.tsx | 66 +-- .../UpdateIncidentBox.module.scss | 0 .../Incidents/UpdateIncidentBox/index.tsx | 26 +- src/Pages/Incidents/index.tsx | 15 +- src/Pages/Incidents/useIncidentApis.tsx | 2 +- src/Pages/Incidents/utils.ts | 8 +- 12 files changed, 227 insertions(+), 452 deletions(-) delete mode 100644 src/Pages/Incidents/JiraLinks/JiraLinks.module.scss delete mode 100644 src/Pages/Incidents/UpdateIncidentBox/UpdateIncidentBox.module.scss diff --git a/src/Pages/Incidents/ActivityLog/index.tsx b/src/Pages/Incidents/ActivityLog/index.tsx index 9a2ae39..af51e21 100644 --- a/src/Pages/Incidents/ActivityLog/index.tsx +++ b/src/Pages/Incidents/ActivityLog/index.tsx @@ -1,15 +1,24 @@ import { FC } from 'react'; +import { useSelector } from 'react-redux'; import Typography from '@navi/web-ui/lib/primitives/Typography'; import IncidentCreated from '../StepperAssets/IncidentCreated'; import IncidentChange from '../StepperAssets/IncidentChange'; import styles from './ActivityLog.module.scss'; -import { useDispatch, useSelector } from 'react-redux'; const ActivityLog: FC = () => { + //To do: add type here const incidentLog = useSelector( (state: any) => state.incidentLog.incidentLogData, ); - const totalLog = incidentLog?.data?.logs?.length; + const lastChangeIndex = (incidentLog?.data?.logs || []) + .slice() + .reverse() + .findIndex(log => + log.changes.some(change => + ['Status', 'SeverityId', 'TeamId'].includes(change.attribute), + ), + ); + const totalLog = incidentLog?.data?.logs?.length - lastChangeIndex; return (
diff --git a/src/Pages/Incidents/DescriptionContent/index.tsx b/src/Pages/Incidents/DescriptionContent/index.tsx index e19c4be..b17038f 100644 --- a/src/Pages/Incidents/DescriptionContent/index.tsx +++ b/src/Pages/Incidents/DescriptionContent/index.tsx @@ -1,70 +1,25 @@ -import React, { FC, useState, useReducer, useEffect } from 'react'; -import { useSelector, useDispatch } from 'react-redux'; -import { - setIncidentData, - setIncidentLogData, - setHeaderData, - setParticipantsData, -} from '@src/slices/IncidentSlice'; -import { - Typography, - Avatar, - BorderLessInput, -} from '@navi/web-ui/lib/primitives'; -import { - CloseIcon, - DeleteIconOutlined, - ArrowUpSolidIcon, - ArrowDownSolidIcon, -} from '@navi/web-ui/lib/icons'; -import { toast } from '@navi/web-ui/lib/primitives/Toast'; +import React from 'react'; +import { useSelector } from 'react-redux'; +import { Typography, Avatar } from '@navi/web-ui/lib/primitives'; import SlackIcon from '@src/assets/SlackIcon'; -import LoadingIcon from '@src/assets/LoadingIcon'; import ConfluenceIcon from '@src/assets/ConfluenceIcon'; import GoToLinkIcon from '@src/assets/GoToLinkIcon'; -import { ApiService } from '@src/services/api'; -import { - ActionType, - initialState, - reducer, - JIRA_VALIDATION, -} from './DescriptionContentProps'; -import styles from './DescriptionContent.module.scss'; -import { - LINK_JIRA_INCIDENT, - UNLINK_JIRA_INCIDENT, - FETCH_INCIDENT_DATA, -} from '../constants'; -import { truncateText, linkSanitization } from '../utils'; import JiraLinks from '../JiraLinks'; +import styles from './DescriptionContent.module.scss'; const DescriptionContent: React.FC = () => { - const [state, dispatch] = useReducer(reducer, initialState); - - const { id, description, jiraIds, slackChannel, incidentName, rcaLink } = - useSelector((state: any) => state.incidentLog.incidentData); - + const { description, slackChannel, incidentName, rcaLink } = useSelector( + (state: any) => state.incidentLog.incidentData, + ); const incidentParticipants = useSelector( (state: any) => state.incidentLog.participantsData, ); - // console.log('incident participants desc', incidentParticipants); - const reduxDispatch = useDispatch(); - //move to hooks - const storedEmail = localStorage.getItem('email-id'); - //import scss - const goToLinkBlueColor = '#0276FE'; - - //use from hooks below three functions - - //move to utils - // console.log('incident participants', incidentParticipants); const renderParticipantList = (type: string): JSX.Element => { const list = type === 'participants' ? incidentParticipants?.participants : incidentParticipants?.others; - return list?.length ? ( list.map(participant => (
@@ -127,7 +82,7 @@ const DescriptionContent: React.FC = () => { rel="noreferrer" className={styles['rca-text']} > - + Go to document diff --git a/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx b/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx index 458ab68..43bd972 100644 --- a/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx +++ b/src/Pages/Incidents/Dropdowns/AllDailogBox.tsx @@ -1,8 +1,6 @@ -import { FC, useEffect, useReducer } from 'react'; -import { useMatch } from 'react-router-dom'; +import { FC, useReducer } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { Tabs } from 'antd'; -import { ArrowDownIcon, AlertOutlineIcon } from '@navi/web-ui/lib/icons'; +import { AlertOutlineIcon } from '@navi/web-ui/lib/icons'; import { SelectPickerOptionProps } from '@navi/web-ui/lib/components/SelectPicker/types'; import { BorderedInput, @@ -11,9 +9,7 @@ import { Button, } from '@navi/web-ui/lib/primitives'; import { toast } from '@navi/web-ui/lib/primitives/Toast'; - import GoToLinkIcon from '@src/assets/GoToLinkIcon'; -import styles from '../Incidents.module.scss'; import LoadingIcon from '@src/assets/LoadingIcon'; import { setOpenDialognotParticipants, @@ -22,7 +18,6 @@ import { setOpenDialogUpdate, } from '@src/slices/IncidentSlice'; import { ApiService } from '@src/services/api'; - import { actionTypes, SLACK_BASE_URL, @@ -32,17 +27,13 @@ import { ResponseType, DUPLICATE_STATUS, UPDATE_INCIDENT, - SeverityType, - StatusType, - TeamType, RESOLVE_STATUS, } from '../constants'; - import useIncidentApis from '../useIncidentApis'; +import styles from '../Incidents.module.scss'; const AllDailogBox: FC = () => { const [state, dispatch] = useReducer(reducer, initialState); - const openNotParticipants = useSelector( (state: any) => state.incidentLog.openDialognotParticipants, ); @@ -61,32 +52,13 @@ const AllDailogBox: FC = () => { const selectedOption = useSelector( (state: any) => state.incidentLog.selectedOptions, ); - //console.log('updatedata', UpdateData); - const incidentData = useSelector( (state: any) => state.incidentLog.incidentData, ); const headerData = useSelector((state: any) => state.incidentLog.headerData); - const severityMap = headerData?.severities?.reduce((map, severity) => { - map[severity.value] = severity.label; - return map; - }, {}); - const statusMap = headerData?.incidentStatuses?.reduce((map, status) => { - map[status.value] = status.label; - return map; - }, {}); - const teamsMap = headerData?.teams?.reduce((map, Incidentteam) => { - map[Incidentteam.value] = Incidentteam.label; - return map; - }, {}); - - const { updateIncident, fetchIncidentLog, startIncidentSearch } = - useIncidentApis(); - 0; - + const { updateIncident, startIncidentSearch } = useIncidentApis(); const incidentId = incidentData?.id?.toString(); - console.log('incidentId', incidentId); const reduxDispatch = useDispatch(); const incidentName = incidentData?.incidentName; @@ -94,7 +66,7 @@ const AllDailogBox: FC = () => { reduxDispatch(setOpenDialognotParticipants(false)); }; - const handleGoToSlackChannel = () => { + const handleGoToSlackChannel = (): void => { const slackChannelURL = `${SLACK_BASE_URL}/archives/${incidentData?.slackChannel}`; window.open(slackChannelURL, '_blank'); handleopenNotParticipants(); @@ -231,7 +203,6 @@ const AllDailogBox: FC = () => { const handleTeamSelectionChange = ( selectedOption: SelectPickerOptionProps | SelectPickerOptionProps[], ): void => { - console.log('selectedOption', selectedOption); if (selectedOption) { dispatch({ type: actionTypes.SET_IS_TEAM_PICKER_OPEN, payload: false }); toast('Updating ticket. Please wait a moment.', { @@ -248,10 +219,10 @@ const AllDailogBox: FC = () => { }; const handleCloseConfirmationDialog = () => { - if (UpdateData?.type === SeverityType) { + if (UpdateData?.type == 'severity') { handleSeveritySelectionChange(selectedOption); } else { - if (UpdateData?.type === StatusType) { + if (UpdateData?.type == 'status') { handleStatusSelectionChange(selectedOption); } else { handleTeamSelectionChange(selectedOption); @@ -263,7 +234,6 @@ const AllDailogBox: FC = () => {
{openNotParticipants && ( { Icon={} />
-