TP-52973 | pr comments resolve

This commit is contained in:
AyushRanjan
2024-01-30 17:04:10 +05:30
parent 868444c581
commit 4d6652bfed
9 changed files with 75 additions and 30 deletions

View File

@@ -10,13 +10,13 @@ import styles from './DescriptionContent.module.scss';
const DescriptionContent: React.FC = () => {
const { description, slackChannel, incidentName, rcaLink } = useSelector(
(state: IncidentPageState) => state.incidentLog.incidentData,
(state: IncidentPageState) => state.incidentLog.incidentData || {},
);
const incidentParticipants = useSelector(
(state: IncidentPageState) => state.incidentLog.participantsData,
);
const renderParticipantList = (type: string): JSX.Element => {
const renderParticipantList = (type: string): JSX.Element | JSX.Element[] => {
const list =
type === 'participants'
? incidentParticipants?.participants

View File

@@ -58,7 +58,7 @@ const AllDailogBox: FC = () => {
(state: IncidentPageState) => state.incidentLog.incidentData,
);
const { updateIncident, startIncidentSearch } = useIncidentApis();
const incidentId = incidentData?.id?.toString();
const incidentId = incidentData?.id?.toString() || '';
const reduxDispatch = useDispatch();
const incidentName = incidentData?.incidentName;
@@ -80,7 +80,7 @@ const AllDailogBox: FC = () => {
return !incidentName || !validate(incidentName);
};
const extractIncidentId = (incidentName: string): number | null => {
const extractIncidentId = (incidentName: string | null): number | null => {
if (!incidentName) {
return null;
}
@@ -231,6 +231,16 @@ const AllDailogBox: FC = () => {
}
};
const getLabelFromOption = (
option: SelectPickerOptionProps | SelectPickerOptionProps[],
): string | undefined => {
if (Array.isArray(option)) {
return option[0]?.label;
} else {
return option.label;
}
};
return (
<div>
{openNotParticipants && (
@@ -372,7 +382,7 @@ const AllDailogBox: FC = () => {
color="var(--navi-color-gray-c2)"
className={styles['popup-style']}
>
{UpdateData?.to?.label || '..'}
{getLabelFromOption(UpdateData?.to) || '..'}
</Typography>
</Typography>
</div>

View File

@@ -37,9 +37,11 @@ const Dropdowns: FC = () => {
(state: IncidentPageState) => state.incidentLog.incidentData,
);
const incidentParticipants = useSelector(
(state: IncidentPageState) => state.incidentLog?.participantsData,
(state: IncidentPageState) => state.incidentLog.participantsData,
);
const headerData = useSelector(
(state: IncidentPageState) => state.incidentLog.headerData,
);
const headerData = useSelector((state: any) => state.incidentLog.headerData);
const [state, dispatch] = useReducer(reducer, initialState);
const updatedSeverities = generateOptions(headerData?.severities);
@@ -109,7 +111,7 @@ const Dropdowns: FC = () => {
},
);
const handleDropdownClick = (changeType: string) => {
const handleDropdownClick = (changeType: string): (() => void) => {
if (isUserParticipantList) {
switch (changeType) {
case 'severity':
@@ -118,6 +120,8 @@ const Dropdowns: FC = () => {
return () => handleStatusDropdownClick();
case 'team':
return () => handleTeamDropdownClick();
default:
throw new Error('Invalid change type');
}
} else {
return handleDisabledDropdownClick;
@@ -156,7 +160,7 @@ const Dropdowns: FC = () => {
: updateType === StatusType
? initialStatus?.value
: initialTeam?.value;
const currentState = currentValue.toString();
const currentState = currentValue?.toString();
const selectedvalue = Array.isArray(selectedOption)
? selectedOption[0].value
: selectedOption.value;

View File

@@ -43,7 +43,7 @@ const Header: FC = () => {
<div className={styles['incident-info']}>
<div className={styles['incident-info-text']}>
<Typography variant="h3">
{incidentData?.incidentName} : {incidentData?.title}
{incidentData?.incidentName || '-'} : {incidentData?.title || '-'}
</Typography>
</div>
<div className={styles['incident-info-icon']}>

View File

@@ -151,7 +151,7 @@ const JiraLinks: FC = () => {
return (
<div>
<div className={styles['description-content-jira']}>
<section className={styles['description-content-jira']}>
<div className={styles['flex-row']}>
<JiraLogo />
&nbsp;
@@ -259,7 +259,7 @@ const JiraLinks: FC = () => {
</div>
)}
</div>
</div>
</section>
</div>
);
};

View File

@@ -70,7 +70,7 @@ export interface ResponseType {
status: number;
}
export interface JiraLinkPayload {
incident_id: number;
incident_id: number | null;
jira_link: string;
user: string;
}

View File

@@ -1,5 +1,4 @@
import { SeverityType, StatusType, TeamType } from './constants';
import { useMatch } from 'react-router-dom';
export const getUpdateTypeText = (updateType: number): string => {
switch (updateType) {
case SeverityType:
@@ -30,7 +29,7 @@ export const generateOptions = (data: DataItem[]): DataItemModified[] => {
}));
};
export const truncateText = (text): string => {
export const truncateText = (text: string): string => {
const jiraTicketMatch = text.match(/\/browse\/([^/]+)/);
if (jiraTicketMatch && jiraTicketMatch[1]) {
return jiraTicketMatch[1];
@@ -38,7 +37,7 @@ export const truncateText = (text): string => {
return text;
};
export const linkSanitization = link => {
export const linkSanitization = (link: string): string => {
const sanitizedLinkMatch = link.match(
/(https:\/\/navihq.atlassian.net\/browse\/[^/]+)/,
);
@@ -48,6 +47,10 @@ export const linkSanitization = link => {
return link;
};
export const getCurrentData = (data, dataMap, key) => {
export const getCurrentData = (
data: { [key: string]: any },
dataMap: { [key: string]: string },
key: string,
): string => {
return dataMap && data[key] ? dataMap[data[key]] : '-';
};

View File

@@ -6,9 +6,10 @@ import {
ParticipantsDatatype,
UpdateDetailsType,
IncidentLogDataType,
IncidentLogPageState,
} from '@src/types';
const initialState = {
const initialState: IncidentLogPageState = {
incidentLogData: {} as IncidentLogDataType,
incidentData: {} as IncidentDatatype,
headerData: {} as HeaderDatatype,
@@ -25,34 +26,43 @@ const incidentLogSlice = createSlice({
name: 'incidentLog',
initialState,
reducers: {
setIncidentLogData: (state, action: PayloadAction<IncidentLogDataType>) => {
setIncidentLogData: (
state,
action: PayloadAction<IncidentLogDataType>,
): void => {
state.incidentLogData = action.payload;
},
setIncidentData: (state, action: PayloadAction<IncidentDatatype>) => {
setIncidentData: (state, action: PayloadAction<IncidentDatatype>): void => {
state.incidentData = action.payload;
},
setHeaderData: (state, action: PayloadAction<HeaderDatatype>) => {
setHeaderData: (state, action: PayloadAction<HeaderDatatype>): void => {
state.headerData = action.payload;
},
setParticipantsData: (
state,
action: PayloadAction<ParticipantsDatatype>,
) => {
): void => {
state.participantsData = action.payload;
},
setOpenDialogUpdate: (state, action: PayloadAction<boolean>) => {
setOpenDialogUpdate: (state, action: PayloadAction<boolean>): void => {
state.openDialogUpdate = action.payload;
},
setOpenDialogDuplicate: (state, action: PayloadAction<boolean>) => {
setOpenDialogDuplicate: (state, action: PayloadAction<boolean>): void => {
state.openDialogDuplicate = action.payload;
},
setOpenDialogResolve: (state, action: PayloadAction<boolean>) => {
setOpenDialogResolve: (state, action: PayloadAction<boolean>): void => {
state.openDialogResolve = action.payload;
},
setOpenDialognotParticipants: (state, action: PayloadAction<boolean>) => {
setOpenDialognotParticipants: (
state,
action: PayloadAction<boolean>,
): void => {
state.openDialognotParticipants = action.payload;
},
setUpdateDetails: (state, action: PayloadAction<UpdateDetailsType>) => {
setUpdateDetails: (
state,
action: PayloadAction<UpdateDetailsType>,
): void => {
state.updateDetails = { ...state.updateDetails, ...action.payload };
},
setSelectedOptions: (
@@ -60,9 +70,23 @@ const incidentLogSlice = createSlice({
action: PayloadAction<
SelectPickerOptionProps | SelectPickerOptionProps[]
>,
) => {
): void => {
state.selectedOptions = action.payload;
},
resetIncidentLogState: (state): void => {
state.incidentLogData = {} as IncidentLogDataType;
state.incidentData = {} as IncidentDatatype;
state.headerData = {} as HeaderDatatype;
state.participantsData = {} as ParticipantsDatatype;
state.updateDetails = {} as UpdateDetailsType;
state.openDialogUpdate = false;
state.openDialogDuplicate = false;
state.openDialogResolve = false;
state.openDialognotParticipants = false;
state.selectedOptions = {} as
| SelectPickerOptionProps
| SelectPickerOptionProps[];
},
},
});

View File

@@ -153,8 +153,8 @@ interface ChangeType {
attribute: string;
}
export interface IncidentPageState {
incidentLog: IncidentLogData;
export interface IncidentLogPageState {
incidentLogData: IncidentLogDatatype;
incidentData: IncidentDatatype;
headerData: HeaderDatatype;
participantsData: ParticipantsDatatype;
@@ -165,3 +165,7 @@ export interface IncidentPageState {
openDialognotParticipants: boolean;
selectedOptions: SelectPickerOptionProps | SelectPickerOptionProps[];
}
export interface IncidentPageState {
incidentLog: IncidentLogPageState;
}