(latestAction);
const [isActionLoading, setIsActionLoading] = useState(false);
@@ -212,11 +276,12 @@ export const TaskTab = ({
assignee.type === 'team' ? checkIfUserPartOfTeam(assignee.id) : false
);
- const isTaskDescription = isDescriptionTask(taskDetails?.type as TaskType);
-
- const isTaskTags = isTagsTask(taskDetails?.type as TaskType);
-
- const isTaskGlossaryApproval = taskDetails?.type === TaskType.RequestApproval;
+ const getFormattedMenuOptions = (options: TaskAction[]) => {
+ return options.map((item) => ({
+ ...item,
+ icon: ,
+ }));
+ };
const handleTaskLinkClick = () => {
history.push({
@@ -341,16 +406,22 @@ export const TaskTab = ({
(!hasGlossaryReviewer && isOwner) ||
(Boolean(isPartOfAssigneeTeam) && !isCreator);
- const onSave = (message: string) => {
- postFeed(message, taskThread?.id ?? '').catch(() => {
- // ignore since error is displayed in toast in the parent promise.
- // Added block for sonar code smell
- });
+ const onSave = () => {
+ postFeed(comment, taskThread?.id ?? '')
+ .catch(() => {
+ // ignore since error is displayed in toast in the parent promise.
+ // Added block for sonar code smell
+ })
+ .finally(() => {
+ editorRef.current?.clearEditorValue();
+ });
};
const handleMenuItemClick: MenuProps['onClick'] = (info) => {
if (info.key === TaskActionMode.EDIT) {
setShowEditTaskModel(true);
+ } else if (info.key === TaskActionMode.CLOSE) {
+ onTaskReject();
} else {
onTaskResolve();
}
@@ -458,7 +529,7 @@ export const TaskTab = ({
}
};
- const onTaskDropdownClick = () => {
+ const onTestCaseTaskDropdownClick = () => {
if (taskAction.key === TaskActionMode.RESOLVE) {
setShowEditTaskModel(true);
} else {
@@ -466,13 +537,54 @@ export const TaskTab = ({
}
};
+ const handleGlossaryTaskMenuClick = (info: MenuInfo) => {
+ setTaskAction(
+ GLOSSARY_TASK_ACTION_LIST.find((action) => action.key === info.key) ??
+ GLOSSARY_TASK_ACTION_LIST[0]
+ );
+ switch (info.key) {
+ case TaskActionMode.RESOLVE:
+ onTaskResolve();
+
+ break;
+
+ case TaskActionMode.CLOSE:
+ onTaskReject();
+
+ break;
+ }
+ };
+
+ const onTaskDropdownClick = () => {
+ if (
+ taskAction.key === TaskActionMode.RESOLVE ||
+ taskAction.key === TaskActionMode.EDIT
+ ) {
+ handleMenuItemClick({ key: taskAction.key } as MenuInfo);
+ } else {
+ onTaskReject();
+ }
+ };
+
+ const renderCommentButton = useMemo(() => {
+ return (
+
+ );
+ }, [comment, onSave]);
+
const approvalWorkflowActions = useMemo(() => {
const hasApprovalAccess =
isAssignee || (Boolean(isPartOfAssigneeTeam) && !isCreator);
return (
-
+ icon={}
+ menu={{
+ items: getFormattedMenuOptions(GLOSSARY_TASK_ACTION_LIST),
+ selectable: true,
+ selectedKeys: [taskAction.key],
+ onClick: handleGlossaryTaskMenuClick,
+ }}
+ overlayClassName="task-action-dropdown"
+ onClick={onTaskDropdownClick}>
+ {taskAction.label}
+
-
-
-
+ {renderCommentButton}
);
- }, [taskDetails, onTaskResolve, isAssignee, isPartOfAssigneeTeam]);
+ }, [
+ taskAction,
+ isAssignee,
+ isCreator,
+ isPartOfAssigneeTeam,
+ renderCommentButton,
+ handleGlossaryTaskMenuClick,
+ onTaskDropdownClick,
+ ]);
const testCaseResultFlow = useMemo(() => {
const editPermission = checkPermission(
@@ -516,32 +632,34 @@ export const TaskTab = ({
const hasApprovalAccess = isAssignee || isCreator || editPermission;
return (
- }
- loading={isActionLoading}
- menu={{
- items: INCIDENT_TASK_ACTION_LIST,
- selectable: true,
- selectedKeys: [taskAction.key],
- onClick: handleTaskMenuClick,
- disabled: !hasApprovalAccess,
- }}
- type="primary"
- onClick={onTaskDropdownClick}>
- {taskAction.label}
-
+
+ }
+ loading={isActionLoading}
+ menu={{
+ items: INCIDENT_TASK_ACTION_LIST,
+ selectable: true,
+ selectedKeys: [taskAction.key],
+ onClick: handleTaskMenuClick,
+ disabled: !hasApprovalAccess,
+ }}
+ onClick={onTestCaseTaskDropdownClick}>
+ {taskAction.label}
+
+ {renderCommentButton}
+
);
- }, [taskDetails, isAssignee, isPartOfAssigneeTeam, taskAction]);
+ }, [
+ taskDetails,
+ isAssignee,
+ isPartOfAssigneeTeam,
+ taskAction,
+ renderCommentButton,
+ ]);
const actionButtons = useMemo(() => {
- if (isTaskClosed) {
- return null;
- }
-
- const taskType = taskDetails?.type ?? '';
-
if (isTaskGlossaryApproval) {
return approvalWorkflowActions;
}
@@ -550,49 +668,47 @@ export const TaskTab = ({
return testCaseResultFlow;
}
- const parsedSuggestion = [
- 'RequestDescription',
- 'UpdateDescription',
- ].includes(taskType)
- ? taskDetails?.suggestion
- : JSON.parse(taskDetails?.suggestion || '[]');
-
return (
- {(isCreator || hasEditAccess) && (
-
+ {isCreator && !hasEditAccess && (
+
)}
- {hasEditAccess ? (
+ {hasEditAccess && (
<>
- {['RequestDescription', 'RequestTag'].includes(taskType) &&
- isEmpty(parsedSuggestion) ? (
-
+ {showAddSuggestionButton ? (
+
+ }
+ menu={{
+ items: getFormattedMenuOptions(noSuggestionTaskMenuOptions),
+ selectable: true,
+ selectedKeys: [taskAction.key],
+ onClick: handleMenuItemClick,
+ }}
+ overlayClassName="task-action-dropdown"
+ onClick={onTaskDropdownClick}>
+ {taskAction.label}
+
+
) : (
}
menu={{
- items: TASK_ACTION_LIST,
+ items: getFormattedMenuOptions(TASK_ACTION_LIST),
selectable: true,
selectedKeys: [taskAction.key],
onClick: handleMenuItemClick,
}}
- type="primary"
+ overlayClassName="task-action-dropdown"
onClick={() =>
taskAction.key === TaskActionMode.EDIT
? handleMenuItemClick({ key: taskAction.key } as MenuInfo)
@@ -602,22 +718,24 @@ export const TaskTab = ({
)}
>
- ) : (
- <>>
)}
+ {renderCommentButton}
);
}, [
+ onTaskReject,
taskDetails,
onTaskResolve,
handleMenuItemClick,
taskAction,
isTaskClosed,
isTaskGlossaryApproval,
+ showAddSuggestionButton,
isCreator,
approvalWorkflowActions,
testCaseResultFlow,
isTaskTestCaseResult,
+ renderCommentButton,
]);
const initialFormValue = useMemo(() => {
@@ -806,10 +924,13 @@ export const TaskTab = ({
{taskDetails?.status === ThreadTaskStatus.Open && (
-
+
)}
-
- {actionButtons}
{isTaskTestCaseResult ? (