From fe111952183e3e43cb1a5fdad0087c522872b097 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Thu, 26 Oct 2023 22:01:13 +0000 Subject: [PATCH] :bug: Add application risk to assessment drawer (#1488) https://issues.redhat.com/browse/MTA-1504 --------- Signed-off-by: ibolton336 Signed-off-by: Ian Bolton --- client/src/app/api/models.ts | 2 + .../application-detail-drawer-assessment.tsx | 7 ++-- .../application-risk.tsx | 40 ------------------- 3 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 client/src/app/pages/applications/components/application-detail-drawer/application-risk.tsx diff --git a/client/src/app/api/models.ts b/client/src/app/api/models.ts index b9fc7750be..ce7b348ae8 100644 --- a/client/src/app/api/models.ts +++ b/client/src/app/api/models.ts @@ -130,6 +130,8 @@ export interface Application { assessments?: Ref[]; assessed?: boolean; archetypes?: Ref[]; + risk?: Risk; + confidence?: number; } export interface Review { diff --git a/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-assessment.tsx b/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-assessment.tsx index 9d7ed5c496..5188bfd400 100644 --- a/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-assessment.tsx +++ b/client/src/app/pages/applications/components/application-detail-drawer/application-detail-drawer-assessment.tsx @@ -22,6 +22,7 @@ import { } from "./application-detail-drawer"; import { useFetchReviewById } from "@app/queries/reviews"; import { ReviewedArchetypeItem } from "./reviewed-archetype-item"; +import { RiskLabel } from "@app/components/RiskLabel"; export interface IApplicationDetailDrawerAssessmentProps extends Pick { @@ -136,12 +137,12 @@ export const ApplicationDetailDrawerAssessment: React.FC< {appReview?.workPriority || notYetReviewed} - {/* + {t("terms.risk")} - {application && } + - */} + diff --git a/client/src/app/pages/applications/components/application-detail-drawer/application-risk.tsx b/client/src/app/pages/applications/components/application-detail-drawer/application-risk.tsx deleted file mode 100644 index ac75cc7560..0000000000 --- a/client/src/app/pages/applications/components/application-detail-drawer/application-risk.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from "react"; - -import { RiskLabel } from "@app/components/RiskLabel"; -import { Application } from "@app/api/models"; -import { useFetchAssessmentsByItemId } from "@app/queries/assessments"; -import { Alert, Spinner } from "@patternfly/react-core"; - -export interface IApplicationRiskProps { - application: Application; -} - -export const ApplicationRisk: React.FC<IApplicationRiskProps> = ({ - application, -}) => { - const { - assessments, - isFetching: isFetchingAssessmentsById, - fetchError, - } = useFetchAssessmentsByItemId(false, application.id); - - if (isFetchingAssessmentsById || fetchError) { - return ( - <> - {isFetchingAssessmentsById && <Spinner />}{" "} - {fetchError && <Alert variant="warning" isInline title="Error" />} - </> - ); - } - - if (!assessments || assessments.length === 0) { - return ( - <> - <RiskLabel risk={"unknown"} /> - {isFetchingAssessmentsById && <Spinner />} - </> - ); - } - - return <RiskLabel risk={assessments[0].risk || "unknown"} />; -};