From dd5c9cb8cbe986bc1f9be6548c36c2cfa84e01d5 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Mon, 29 Jul 2024 18:16:08 -0400 Subject: [PATCH 1/4] :bug: Add application risk filter of "Unassessed" 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 --- .../applications-table/applications-table.tsx | 1 + hack/import-questionnaire/assign-risk.yaml | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 hack/import-questionnaire/assign-risk.yaml diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index 266bd2792d..d06677e120 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -490,6 +490,7 @@ export const ApplicationsTable: React.FC = () => { { value: "yellow", label: "Medium" }, { value: "red", label: "High" }, { value: "unknown", label: "Unknown" }, + { value: "unassessed", label: "Unassessed" }, ], getItemValue: (item) => item.risk ?? "", }, diff --git a/hack/import-questionnaire/assign-risk.yaml b/hack/import-questionnaire/assign-risk.yaml new file mode 100644 index 0000000000..96d593e7f6 --- /dev/null +++ b/hack/import-questionnaire/assign-risk.yaml @@ -0,0 +1,34 @@ +name: Assign Risk +description: | + Questionnaire that allows the use to select a risk level directly + +sections: + - order: 1 + name: Assign The RISK + questions: + - order: 1 + text: What should be the Risk level of the application? + answers: + - order: 1 + text: Unknown + risk: unknown + - order: 2 + text: Green / Low + risk: green + - order: 3 + text: Yellow / Medium + risk: yellow + - order: 4 + text: Red / High + risk: red + +thresholds: + red: 1 + yellow: 30 + unknown: 15 + +riskMessages: + red: Application requires deep changes in architecture or lifecycle + yellow: Application is Cloud friendly but requires some minor changes + green: Application is Cloud Native + unknown: More information about the application is required From 76c63b0dbaeabee7066fd8d1be58df368db4afdf Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 30 Jul 2024 10:10:46 -0400 Subject: [PATCH 2/4] Add unassessed as a possible option for type Risk Signed-off-by: Scott J Dickerson --- client/src/app/api/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 84fbbf7b1ceafef82556c8e9f4c2f4c35253da66 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 30 Jul 2024 14:40:38 -0400 Subject: [PATCH 3/4] More type Risk work - Add "unassessed" as an office `Risk` type option - Updated `RiskLabel` to handle undefined and arbitrary strings as risk inputs. Consumers of the component don't need to worry about the prop quite as much anymore. - Where a string risk was getting looked at, force to lower case first so all the constants match up. Signed-off-by: Scott J Dickerson --- client/public/locales/en/translation.json | 3 +- client/src/app/Constants.ts | 6 ++++ client/src/app/components/RiskLabel.tsx | 35 +++++++++++++++++-- .../application-assessment-donut-chart.tsx | 6 ++-- .../app/components/tests/RiskLabel.test.tsx | 3 +- .../application-detail-drawer.tsx | 2 +- .../components/archetype-detail-drawer.tsx | 2 +- .../adoption-candidate-table.tsx | 2 +- 8 files changed, 48 insertions(+), 11 deletions(-) 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/components/RiskLabel.tsx b/client/src/app/components/RiskLabel.tsx index a12330e1ed..54154b7358 100644 --- a/client/src/app/components/RiskLabel.tsx +++ b/client/src/app/components/RiskLabel.tsx @@ -7,15 +7,44 @@ import { RISK_LIST } from "@app/Constants"; import { Risk } from "@app/api/models"; export interface IRiskLabelProps { - risk: Risk; + risk?: Risk | string; +} + +function normalizeToRisk(risk?: Risk | string): Risk | undefined { + let normal: Risk | undefined = undefined; + + switch (risk) { + case "green": + normal = "green"; + break; + + case "yellow": + normal = "yellow"; + break; + + case "red": + normal = "red"; + break; + + case "unassessed": + normal = "unassessed"; + break; + + case "unknown": + normal = "unknown"; + break; + } + + return normal; } export const RiskLabel: React.FC = ({ - risk, + risk = "unknown", }: IRiskLabelProps) => { const { t } = useTranslation(); - const data = RISK_LIST[risk]; + const asRisk = normalizeToRisk(risk); + const data = !asRisk ? undefined : RISK_LIST[asRisk]; return (