From 0e579db57d4fb3037b5693d671e096b7be62dbe1 Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Thu, 1 Aug 2024 17:40:08 -0400 Subject: [PATCH] :bug: [backport release-0.5] Add application risk filter of "Unassessed" (#2032) (#2035) Backport-of: #2032 Resolves: https://issues.redhat.com/browse/MTA-2816 Application risk options are one of: - High (red) - Medium (yellow) - Low (green) - Unknown (unknown) - Unassessed (unassessed) Added the __Unassessed__ option to the risk filter list on the application table to have a complete set of risk filters. Note: To help test risk levels, the questionnaire `hack/import-questionnaire/assign-risk.yaml` has been added. The single question has a 1 to 1 mapping between answer and risk level. As long as that questionnaire is the only one active on the system, it works well to quickly assign risks to applications. Signed-off-by: Scott J Dickerson --- client/public/locales/en/translation.json | 3 +- client/src/app/Constants.ts | 6 +++ client/src/app/api/models.ts | 2 +- client/src/app/components/RiskLabel.tsx | 6 ++- .../application-assessment-donut-chart.tsx | 6 +-- .../app/components/tests/RiskLabel.test.tsx | 3 +- .../applications-table/applications-table.tsx | 20 ++++++---- .../application-detail-drawer.tsx | 2 +- .../components/archetype-detail-drawer.tsx | 2 +- .../adoption-candidate-table.tsx | 2 +- client/src/app/utils/type-utils.ts | 37 +++++++++++++++++++ hack/import-questionnaire/assign-risk.yaml | 34 +++++++++++++++++ 12 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 hack/import-questionnaire/assign-risk.yaml diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index 284b900851..51f852fea0 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -246,7 +246,8 @@ "high": "High", "low": "Low", "medium": "Medium", - "unknown": "Unknown" + "unknown": "Unknown", + "unassessed": "Unassessed" }, "sidebar": { "administrator": "Administration", diff --git a/client/src/app/Constants.ts b/client/src/app/Constants.ts index 80a622ee9f..3a1171c7c6 100644 --- a/client/src/app/Constants.ts +++ b/client/src/app/Constants.ts @@ -118,6 +118,12 @@ export const RISK_LIST: RiskListType = { labelColor: "grey", sortFactor: 4, }, + unassessed: { + i18Key: "risks.unassessed", + hexColor: black.value, + labelColor: "grey", + sortFactor: 5, + }, }; // Proposed action diff --git a/client/src/app/api/models.ts b/client/src/app/api/models.ts index 98ffa8fdfc..e3047d8abd 100644 --- a/client/src/app/api/models.ts +++ b/client/src/app/api/models.ts @@ -781,7 +781,7 @@ export interface Thresholds { } export type AssessmentStatus = "empty" | "started" | "complete"; -export type Risk = "green" | "yellow" | "red" | "unknown"; +export type Risk = "green" | "yellow" | "red" | "unknown" | "unassessed"; export interface InitialAssessment { application?: Ref; diff --git a/client/src/app/components/RiskLabel.tsx b/client/src/app/components/RiskLabel.tsx index a12330e1ed..220d5a4f3f 100644 --- a/client/src/app/components/RiskLabel.tsx +++ b/client/src/app/components/RiskLabel.tsx @@ -5,9 +5,10 @@ import { Label } from "@patternfly/react-core"; import { RISK_LIST } from "@app/Constants"; import { Risk } from "@app/api/models"; +import { normalizeRisk } from "@app/utils/type-utils"; export interface IRiskLabelProps { - risk: Risk; + risk?: Risk | string; } export const RiskLabel: React.FC = ({ @@ -15,7 +16,8 @@ export const RiskLabel: React.FC = ({ }: IRiskLabelProps) => { const { t } = useTranslation(); - const data = RISK_LIST[risk]; + const asRisk = normalizeRisk(risk); + const data = !asRisk ? undefined : RISK_LIST[asRisk]; return (