Skip to content

Commit

Permalink
Add risks link from report
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Nov 29, 2023
1 parent 64c5b56 commit 8a2c498
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,22 @@ export const ApplicationsTable: React.FC = () => {
return matchString;
},
},
{
key: "risk",
title: t("terms.risk"),
type: FilterType.multiselect,
placeholderText:
t("actions.filterBy", {
what: t("terms.risk").toLowerCase(),
}) + "...",
selectOptions: [
{ key: "green", value: "Green" },
{ key: "yellow", value: "Yellow" },
{ key: "red", value: "Red" },
{ key: "unknown", value: "Unknown" },
],
getItemValue: (item) => item.risk || "",
},
],
initialItemsPerPage: 10,
hasActionsColumn: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { ConditionalRender } from "@app/components/ConditionalRender";
import { useFetchAssessmentsWithArchetypeApplications } from "@app/queries/assessments";
import { useFetchApplications } from "@app/queries/applications";
import { Donut } from "../donut/donut";
import { serializeFilterUrlParams } from "@app/hooks/table-controls";
import { Paths } from "@app/Paths";
import { Link } from "react-router-dom";

interface IAggregateRiskData {
green: number;
Expand Down Expand Up @@ -142,7 +145,9 @@ export const ApplicationLandscape: React.FC<IApplicationLandscapeProps> = ({
value={landscapeData.red}
total={landscapeData.applicationsCount}
color={RISK_LIST.red.hexColor}
riskLabel={t("terms.highRisk")}
riskLabel={
<Link to={getRisksUrl(["red"])}>{t("terms.highRisk")}</Link>
}
riskDescription={questionnaire?.riskMessages?.red ?? ""}
/>
</FlexItem>
Expand All @@ -153,7 +158,11 @@ export const ApplicationLandscape: React.FC<IApplicationLandscapeProps> = ({
value={landscapeData.yellow}
total={landscapeData.applicationsCount}
color={RISK_LIST.yellow.hexColor}
riskLabel={t("terms.mediumRisk")}
riskLabel={
<Link to={getRisksUrl(["yellow"])}>
{t("terms.mediumRisk")}
</Link>
}
riskDescription={questionnaire?.riskMessages?.yellow ?? ""}
/>
</FlexItem>
Expand All @@ -164,7 +173,9 @@ export const ApplicationLandscape: React.FC<IApplicationLandscapeProps> = ({
value={landscapeData.green}
total={landscapeData.applicationsCount}
color={RISK_LIST.green.hexColor}
riskLabel={t("terms.lowRisk")}
riskLabel={
<Link to={getRisksUrl(["green"])}>{t("terms.lowRisk")}</Link>
}
riskDescription={questionnaire?.riskMessages?.green ?? ""}
/>
</FlexItem>
Expand All @@ -175,12 +186,28 @@ export const ApplicationLandscape: React.FC<IApplicationLandscapeProps> = ({
value={landscapeData.unassessed}
total={landscapeData.applicationsCount}
color={RISK_LIST.unknown.hexColor}
riskLabel={`${t("terms.unassessed")}/${t("terms.unknown")}`}
riskDescription={questionnaire?.riskMessages?.unknown ?? ""}
riskLabel={
<Link to={getRisksUrl(["unknown"])}>
{`${t("terms.unassessed")}/${t("terms.unknown")}`}
</Link>
}
/>
</FlexItem>
</Flex>
)}
</ConditionalRender>
);
};

const getRisksUrl = (risks: string[]) => {
const filterValues = {
risk: risks,
};

const serializedParams = serializeFilterUrlParams(filterValues);

const queryString = serializedParams.filters
? `filters=${serializedParams.filters}`
: "";
return `${Paths.applications}?${queryString}`;
};
4 changes: 2 additions & 2 deletions client/src/app/pages/reports/components/donut/donut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export interface IDonutProps {
value: number;
total: number;
color: string;
riskLabel: string;
riskDescription?: string;
riskLabel: string | React.ReactElement;
riskDescription?: string | React.ReactElement;
isAssessment: boolean;
}

Expand Down
26 changes: 0 additions & 26 deletions client/src/app/queries/risks.ts

This file was deleted.

0 comments on commit 8a2c498

Please sign in to comment.