-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
261 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 39 additions & 99 deletions
138
client/src/app/pages/applications/analysis-details/AnalysisDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,56 @@ | ||
import React from "react"; | ||
import { useHistory, useLocation, useParams } from "react-router-dom"; | ||
import { useParams } from "react-router-dom"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { PageSection } from "@patternfly/react-core"; | ||
|
||
import { AnalysisDetailsAttachmentRoute, Paths } from "@app/Paths"; | ||
import { PageHeader } from "@app/components/PageHeader"; | ||
import { formatPath } from "@app/utils/utils"; | ||
import { | ||
DocumentId, | ||
SimpleDocumentViewer, | ||
} from "@app/components/simple-document-viewer"; | ||
import { useFetchApplicationById } from "@app/queries/applications"; | ||
import { useFetchTaskByID } from "@app/queries/tasks"; | ||
|
||
import "@app/components/simple-document-viewer/SimpleDocumentViewer.css"; | ||
import { TaskDetailsBase } from "@app/pages/tasks/TaskDetailsBase"; | ||
import { useFetchApplicationById } from "@app/queries/applications"; | ||
|
||
export const AnalysisDetails: React.FC = () => { | ||
export const AnalysisDetails = () => { | ||
const { t } = useTranslation(); | ||
|
||
const { applicationId, taskId, attachmentId } = | ||
useParams<AnalysisDetailsAttachmentRoute>(); | ||
const { search } = useLocation(); | ||
const hasMergedParam = new URLSearchParams(search).has("merged"); | ||
|
||
const history = useHistory(); | ||
const onDocumentChange = (documentId: DocumentId) => | ||
typeof documentId === "number" | ||
? history.push( | ||
formatPath(Paths.applicationsAnalysisDetailsAttachment, { | ||
applicationId: applicationId, | ||
taskId: taskId, | ||
attachmentId: documentId, | ||
}) | ||
) | ||
: history.push({ | ||
pathname: formatPath(Paths.applicationsAnalysisDetails, { | ||
applicationId: applicationId, | ||
taskId: taskId, | ||
}), | ||
search: documentId === "MERGED_VIEW" ? "?merged=true" : undefined, | ||
}); | ||
const detailsPath = formatPath(Paths.applicationsAnalysisDetails, { | ||
applicationId: applicationId, | ||
taskId: taskId, | ||
}); | ||
|
||
const { application } = useFetchApplicationById(applicationId); | ||
const { task } = useFetchTaskByID(Number(taskId)); | ||
|
||
const taskName = task?.name ?? t("terms.unknown"); | ||
const appName: string = application?.name ?? t("terms.unknown"); | ||
const attachmentName = task?.attached?.find( | ||
({ id }) => String(id) === attachmentId | ||
)?.name; | ||
const resolvedAttachmentId = attachmentName | ||
? Number(attachmentId) | ||
: undefined; | ||
const resolvedLogMode = hasMergedParam ? "MERGED_VIEW" : "LOG_VIEW"; | ||
|
||
return ( | ||
<> | ||
<PageSection variant="light"> | ||
<PageHeader | ||
title={`Analysis details for ${taskName}`} | ||
breadcrumbs={[ | ||
{ | ||
title: t("terms.applications"), | ||
path: Paths.applications, | ||
}, | ||
{ | ||
title: appName, | ||
path: `${Paths.applications}/?activeItem=${applicationId}`, | ||
}, | ||
{ | ||
title: t("actions.analysisDetails"), | ||
path: formatPath(Paths.applicationsAnalysisDetails, { | ||
applicationId: applicationId, | ||
taskId: taskId, | ||
}), | ||
}, | ||
...(attachmentName | ||
? [ | ||
{ | ||
title: t("terms.attachments"), | ||
}, | ||
{ | ||
title: attachmentName, | ||
path: formatPath(Paths.applicationsAnalysisDetails, { | ||
applicationId: applicationId, | ||
taskId: taskId, | ||
attachment: attachmentId, | ||
}), | ||
}, | ||
] | ||
: []), | ||
]} | ||
/> | ||
</PageSection> | ||
<PageSection> | ||
<div | ||
style={{ | ||
backgroundColor: "var(--pf-v5-global--BackgroundColor--100)", | ||
}} | ||
className="simple-task-viewer-container" | ||
> | ||
<SimpleDocumentViewer | ||
// force re-creating viewer via keys | ||
key={`${task?.id}/${task?.attached?.length}`} | ||
taskId={task ? Number(taskId) : undefined} | ||
documentId={resolvedAttachmentId || resolvedLogMode} | ||
attachments={task?.attached ?? []} | ||
onDocumentChange={onDocumentChange} | ||
height="full" | ||
/> | ||
</div> | ||
</PageSection> | ||
</> | ||
<TaskDetailsBase | ||
breadcrumbs={[ | ||
{ | ||
title: t("terms.applications"), | ||
path: Paths.applications, | ||
}, | ||
{ | ||
title: appName, | ||
path: `${Paths.applications}/?activeItem=${applicationId}`, | ||
}, | ||
{ | ||
title: t("actions.analysisDetails"), | ||
path: formatPath(Paths.applicationsAnalysisDetails, { | ||
applicationId, | ||
taskId, | ||
}), | ||
}, | ||
]} | ||
detailsPath={detailsPath} | ||
formatTitle={(taskName) => `Analysis details for ${taskName}`} | ||
formatAttachmentPath={(attachmentId) => | ||
formatPath(Paths.applicationsAnalysisDetailsAttachment, { | ||
applicationId, | ||
taskId, | ||
attachmentId, | ||
}) | ||
} | ||
taskId={Number(taskId)} | ||
attachmentId={attachmentId} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { Paths, TaskDetailsAttachmentRoute } from "@app/Paths"; | ||
import "@app/components/simple-document-viewer/SimpleDocumentViewer.css"; | ||
import { formatPath } from "@app/utils/utils"; | ||
import { TaskDetailsBase } from "./TaskDetailsBase"; | ||
|
||
export const TaskDetails = () => { | ||
const { t } = useTranslation(); | ||
const { taskId, attachmentId } = useParams<TaskDetailsAttachmentRoute>(); | ||
const detailsPath = formatPath(Paths.taskDetails, { taskId }); | ||
return ( | ||
<TaskDetailsBase | ||
breadcrumbs={[ | ||
{ | ||
title: t("terms.tasks"), | ||
path: Paths.tasks, | ||
}, | ||
{ | ||
title: t("titles.taskWithId", { taskId }), | ||
path: detailsPath, | ||
}, | ||
]} | ||
detailsPath={detailsPath} | ||
formatTitle={(taskName) => `Task details for task ${taskId}, ${taskName}`} | ||
formatAttachmentPath={(attachmentId) => | ||
formatPath(Paths.taskDetailsAttachment, { | ||
taskId, | ||
attachmentId, | ||
}) | ||
} | ||
taskId={Number(taskId)} | ||
attachmentId={attachmentId} | ||
/> | ||
); | ||
}; | ||
|
||
export default TaskDetails; |
Oops, something went wrong.