Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Added a summary of issues indicating that the analysis was successful #2139

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@
"medium": "Medium",
"small": "Small"
},
"issues": {
"noIssues": "Congratulations! No issues were found",
"issuesFound": "{{minor}} minor, {{critical}} critical"
},
"message": {
"archetypeApplicationCount": "{{count}} application",
"archetypeApplicationCount_plural": "{{count}} applications",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import { useFetchArchetypes } from "@app/queries/archetypes";
import { useFetchAssessments } from "@app/queries/assessments";
import { DecoratedApplication } from "../../applications-table/useDecoratedApplications";
import { TaskStates } from "@app/queries/tasks";
import { useFetchIssueReports } from "@app/queries/issues";
import { fork } from "radash";

export interface IApplicationDetailDrawerProps
extends Pick<IPageDrawerContentProps, "onCloseClick"> {
Expand Down Expand Up @@ -182,6 +184,18 @@ const TabDetailsContent: React.FC<{
.filter((fullArchetype) => fullArchetype?.review)
.filter(Boolean);

const issueReportsQuery = useFetchIssueReports(application.id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query returns a lot just to grab a count. Future improvements here to get a better counting endpoint from the hub backend services.

const {
result: { data, total: totalReportCount },
} = issueReportsQuery;
const currentPageReports = data;
const [minor, critical] = fork(currentPageReports, (u) => u.effort <= 1).map(
(a) => a.length
);

const taskState = application.tasks.currentAnalyzer?.state ?? "";
const taskSucceeded = TaskStates.Success.includes(taskState);

return (
<>
<TextContent className={`${spacing.mtMd} ${spacing.mbMd}`}>
Expand All @@ -194,6 +208,16 @@ const TabDetailsContent: React.FC<{
<Link to={getIssuesSingleAppSelectedLocation(application.id)}>
Issues
</Link>
<Text component="small">
{!taskSucceeded
? t("terms.unassigned")
: currentPageReports.length === 0
? t("issues.noIssues")
: t("issues.issuesFound", {
minor: minor,
critical: critical,
})}
</Text>
</ListItem>
<ListItem>
<Link
Expand Down
Loading