Skip to content

Commit 63af805

Browse files
committed
Refine wording, remove duplicated TaskDetailsBase
Signed-off-by: Radoslaw Szwajkowski <[email protected]>
1 parent 470b51c commit 63af805

File tree

3 files changed

+6
-96
lines changed

3 files changed

+6
-96
lines changed

client/public/locales/en/translation.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"selectNone": "Select none",
5656
"selectPage": "Select page",
5757
"submitReview": "Submit review",
58-
"taskDetails": "Task details",
58+
"taskDetails": "Task {{taskId}}",
5959
"unlink": "Unlink",
6060
"view": "View",
6161
"viewErrorReport": "View error report",

client/src/app/pages/applications/analysis-details/AnalysisDetails.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AnalysisDetailsAttachmentRoute, Paths } from "@app/Paths";
66
import { formatPath } from "@app/utils/utils";
77

88
import "@app/components/simple-document-viewer/SimpleDocumentViewer.css";
9-
import { TaskDetailsBase } from "@app/pages/tasks/TaskDetails";
9+
import { TaskDetailsBase } from "@app/pages/tasks/TaskDetailsBase";
1010
import { useFetchApplicationById } from "@app/queries/applications";
1111

1212
export const AnalysisDetails = () => {

client/src/app/pages/tasks/TaskDetails.tsx

+4-94
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,11 @@
11
import React from "react";
2-
import { useHistory, useLocation, useParams } from "react-router-dom";
2+
import { useParams } from "react-router-dom";
33
import { useTranslation } from "react-i18next";
44

5-
import { PageSection } from "@patternfly/react-core";
6-
75
import { Paths, TaskDetailsAttachmentRoute } from "@app/Paths";
8-
import { PageHeader, PageHeaderProps } from "@app/components/PageHeader";
9-
import {
10-
DocumentId,
11-
SimpleDocumentViewer,
12-
} from "@app/components/simple-document-viewer";
13-
import { useFetchTaskByID } from "@app/queries/tasks";
146
import "@app/components/simple-document-viewer/SimpleDocumentViewer.css";
157
import { formatPath } from "@app/utils/utils";
16-
17-
export const TaskDetailsBase: React.FC<{
18-
breadcrumbs: PageHeaderProps["breadcrumbs"];
19-
formatTitle: (taskName: string) => string;
20-
detailsPath: string;
21-
formatAttachmentPath: (attachmentId: number | string) => string;
22-
taskId: number;
23-
attachmentId?: string;
24-
}> = ({
25-
breadcrumbs,
26-
formatTitle,
27-
detailsPath,
28-
formatAttachmentPath,
29-
taskId,
30-
attachmentId,
31-
}) => {
32-
const { t } = useTranslation();
33-
34-
const { search } = useLocation();
35-
const hasMergedParam = new URLSearchParams(search).has("merged");
36-
37-
const history = useHistory();
38-
const onDocumentChange = (documentId: DocumentId) =>
39-
typeof documentId === "number"
40-
? history.push(formatAttachmentPath(documentId))
41-
: history.push({
42-
pathname: detailsPath,
43-
search: documentId === "MERGED_VIEW" ? "?merged=true" : undefined,
44-
});
45-
46-
const { task } = useFetchTaskByID(taskId);
47-
48-
const taskName: string = task?.name ?? t("terms.unknown");
49-
const attachmentName = task?.attached?.find(
50-
({ id }) => String(id) === attachmentId
51-
)?.name;
52-
const resolvedAttachmentId = attachmentName
53-
? Number(attachmentId)
54-
: undefined;
55-
const resolvedLogMode = hasMergedParam ? "MERGED_VIEW" : "LOG_VIEW";
56-
57-
return (
58-
<>
59-
<PageSection variant="light">
60-
<PageHeader
61-
title={formatTitle(taskName)}
62-
breadcrumbs={[
63-
...breadcrumbs,
64-
...(attachmentName && attachmentId
65-
? [
66-
{
67-
title: t("terms.attachments"),
68-
},
69-
{
70-
title: attachmentName,
71-
path: formatAttachmentPath(attachmentId),
72-
},
73-
]
74-
: []),
75-
]}
76-
/>
77-
</PageSection>
78-
<PageSection>
79-
<div
80-
style={{
81-
backgroundColor: "var(--pf-v5-global--BackgroundColor--100)",
82-
}}
83-
className="simple-task-viewer-container"
84-
>
85-
<SimpleDocumentViewer
86-
// force re-creating viewer via keys
87-
key={`${task?.id}/${task?.attached?.length}`}
88-
taskId={task ? taskId : undefined}
89-
documentId={resolvedAttachmentId || resolvedLogMode}
90-
attachments={task?.attached ?? []}
91-
onDocumentChange={onDocumentChange}
92-
height="full"
93-
/>
94-
</div>
95-
</PageSection>
96-
</>
97-
);
98-
};
8+
import { TaskDetailsBase } from "./TaskDetailsBase";
999

10010
export const TaskDetails = () => {
10111
const { t } = useTranslation();
@@ -109,12 +19,12 @@ export const TaskDetails = () => {
10919
path: Paths.tasks,
11020
},
11121
{
112-
title: t("actions.taskDetails"),
22+
title: t("actions.taskDetails", { taskId }),
11323
path: detailsPath,
11424
},
11525
]}
11626
detailsPath={detailsPath}
117-
formatTitle={(taskName) => `Details for ${taskName}`}
27+
formatTitle={(taskName) => `Task details for task ${taskId}, ${taskName}`}
11828
formatAttachmentPath={(attachmentId) =>
11929
formatPath(Paths.taskDetailsAttachment, {
12030
taskId,

0 commit comments

Comments
 (0)