Skip to content

Commit

Permalink
Merge branch 'main' into taskIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
rszwajko authored Jun 26, 2024
2 parents b9224f0 + 91400ed commit 1ee8aab
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 119 deletions.
5 changes: 4 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"selectNone": "Select none",
"selectPage": "Select page",
"submitReview": "Submit review",
"taskDetails": "Task details",
"unlink": "Unlink",
"view": "View",
"viewErrorReport": "View error report",
Expand Down Expand Up @@ -463,6 +464,7 @@
"tagCategory": "Tag category",
"tagCategoryDeleted": "Tag category deleted",
"tagCategories": "Tag categories",
"tasks": "Tasks",
"teamMember": "team member",
"terminated": "Terminated",
"ticket": "Ticket",
Expand All @@ -483,7 +485,8 @@
"titles": {
"archetypeDrawer": "Archetype details",
"taskManager": "Task Manager",
"task": "Task"
"task": "Task",
"taskWithId": "Task {{taskId}}"
},
"toastr": {
"success": {
Expand Down
7 changes: 7 additions & 0 deletions client/src/app/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const DevPaths = {

dependencies: "/dependencies",
tasks: "/tasks",
taskDetails: "/tasks/:taskId",
taskDetailsAttachment: "/tasks/:taskId/attachments/:attachmentId",
} as const;

export type DevPathValues = (typeof DevPaths)[keyof typeof DevPaths];
Expand Down Expand Up @@ -102,3 +104,8 @@ export interface AnalysisDetailsAttachmentRoute {
taskId: string;
attachmentId: string;
}

export interface TaskDetailsAttachmentRoute {
taskId: string;
attachmentId: string;
}
11 changes: 11 additions & 0 deletions client/src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const AssessmentSummary = lazy(
);

const TaskManager = lazy(() => import("./pages/tasks/tasks-page"));
const TaskDetails = lazy(() => import("./pages/tasks/TaskDetails"));

export interface IRoute<T> {
path: T;
Expand Down Expand Up @@ -195,6 +196,16 @@ export const devRoutes: IRoute<DevPathValues>[] = [
{
path: Paths.tasks,
comp: TaskManager,
exact: true,
},
{
path: Paths.taskDetails,
comp: TaskDetails,
exact: true,
},
{
path: Paths.taskDetailsAttachment,
comp: TaskDetails,
exact: false,
},
];
Expand Down
138 changes: 39 additions & 99 deletions client/src/app/pages/applications/analysis-details/AnalysisDetails.tsx
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}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,12 @@ export const ApplicationsTable: React.FC = () => {
isSortEnabled: true,
isPaginationEnabled: true,
isActiveItemEnabled: true,
persistTo: { activeItem: "urlParams" },
persistTo: {
activeItem: "urlParams",
filter: "sessionStorage",
pagination: "sessionStorage",
sort: "sessionStorage",
},
isLoading: isFetchingApplications,
sortableColumns: ["name", "businessService", "tags", "effort"],
initialSort: { columnKey: "name", direction: "asc" },
Expand All @@ -342,7 +347,7 @@ export const ApplicationsTable: React.FC = () => {
t("actions.filterBy", {
what: t("terms.name").toLowerCase(),
}) + "...",
getItemValue: (item) => item?.name || "",
matcher: (filter: string, item: Application) => item.name === filter,
selectOptions: [
...new Set(
applications.map((application) => application.name).filter(Boolean)
Expand Down
18 changes: 14 additions & 4 deletions client/src/app/pages/dependencies/dependency-apps-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,21 @@ const DependencyVersionColumn = ({
}: {
appDependency: AnalysisAppDependency;
}) => {
const isJavaDependency = name && version && sha && provider === "java";
let mavenCentralLink;

const mavenCentralLink = isJavaDependency
? `https://search.maven.org/search?q=1:${extractFirstSha(sha)}`
: undefined;
if (name && version && provider === "java") {
if (sha) {
mavenCentralLink = `https://search.maven.org/#search|1:${extractFirstSha(
sha
)}`;
} else {
const group = name.substring(0, name.lastIndexOf("."));
const artifact = name.substring(name.lastIndexOf(".") + 1);
mavenCentralLink = encodeURI(
`https://search.maven.org/#search|g:${group} a:${artifact} v:${version}`
);
}
}

return (
<TextContent>
Expand Down
40 changes: 40 additions & 0 deletions client/src/app/pages/tasks/TaskDetails.tsx
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;
Loading

0 comments on commit 1ee8aab

Please sign in to comment.