diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index a280166494..727de4991d 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -186,6 +186,8 @@ "insecureTracker": "Insecure mode deactivates certificate verification. Use insecure mode for instances that have self-signed certificates.", "inheritedReviewTooltip_singular": "This application is inheriting a review from an archetype.", "inheritedReviewTooltip_plural": "This application is inheriting reviews from {{count}} archetypes.", + "inheritedAssessmentTooltip_singular": "This application is inheriting an assessment from an archetype.", + "inheritedAssessmentTooltip_plural": "This application is inheriting assessments from {{count}} archetypes.", "jiraInstanceNotConnected": "Jira instance {{name}} is not connected.", "manageDependenciesInstructions": "Add northbound and southbound dependencies for the selected application here. Note that any selections made will be saved automatically. To undo any changes, you must manually delete the applications from the dropdowns.", "noDataAvailableBody": "No data available to be shown here.", diff --git a/client/src/app/components/IconedStatus.tsx b/client/src/app/components/IconedStatus.tsx index 88faac58da..a0ad21774d 100644 --- a/client/src/app/components/IconedStatus.tsx +++ b/client/src/app/components/IconedStatus.tsx @@ -9,7 +9,8 @@ import UnknownIcon from "@patternfly/react-icons/dist/esm/icons/unknown-icon"; import QuestionCircleIcon from "@patternfly/react-icons/dist/esm/icons/question-circle-icon"; export type IconedStatusPreset = - | "Inherited" + | "InheritedReviews" + | "InheritedAssessments" | "Canceled" | "Completed" | "Error" @@ -51,7 +52,7 @@ export const IconedStatus: React.FC = ({ }: IIconedStatusProps) => { const { t } = useTranslation(); const presets: IconedStatusPresetType = { - Inherited: { + InheritedReviews: { icon: , status: "info", label: t("terms.inherited"), @@ -59,6 +60,14 @@ export const IconedStatus: React.FC = ({ count: tooltipCount, }), }, + InheritedAssessments: { + icon: , + status: "info", + label: t("terms.inherited"), + tooltipMessage: t("message.inheritedAssessmentTooltip", { + count: tooltipCount, + }), + }, Canceled: { icon: , status: "info", @@ -102,7 +111,7 @@ export const IconedStatus: React.FC = ({ }, }; const presetProps = preset && presets[preset]; - + console.log("presetProps", presetProps); const IconWithOptionalTooltip: React.FC<{ children: React.ReactElement }> = ({ children, }) => 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 a8b72b646b..96ab5b594d 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -17,8 +17,6 @@ import { MenuToggle, MenuToggleElement, Modal, - Flex, - FlexItem, } from "@patternfly/react-core"; import { PencilAltIcon, TagIcon, EllipsisVIcon } from "@patternfly/react-icons"; import { @@ -30,7 +28,6 @@ import { ActionsColumn, Tbody, } from "@patternfly/react-table"; -import { QuestionCircleIcon } from "@patternfly/react-icons/dist/esm/icons/question-circle-icon"; // @app components and utilities import { AppPlaceholder } from "@app/components/AppPlaceholder"; @@ -107,7 +104,6 @@ import { getTaskById, } from "@app/api/rest"; import { ApplicationDependenciesForm } from "@app/components/ApplicationDependenciesFormContainer/ApplicationDependenciesForm"; -import { useFetchArchetypes } from "@app/queries/archetypes"; import { useState } from "react"; import { ApplicationAnalysisStatus } from "../components/application-analysis-status"; import { ApplicationDetailDrawer } from "../components/application-detail-drawer/application-detail-drawer"; @@ -221,8 +217,6 @@ export const ApplicationsTable: React.FC = () => { refetch: fetchApplications, } = useFetchApplications(); - const { archetypes } = useFetchArchetypes(); - const onDeleteApplicationSuccess = (appIDCount: number) => { pushNotification({ title: t("toastr.success.applicationDeleted", { @@ -870,18 +864,6 @@ export const ApplicationsTable: React.FC = () => { > {currentPageItems?.map((application, rowIndex) => { - const applicationArchetypes = application.archetypes?.map( - (archetypeRef) => { - return archetypes.find( - (archetype) => archetype.id === archetypeRef.id - ); - } - ); - - const hasAssessedArchetype = applicationArchetypes?.some( - (archetype) => !!archetype?.assessments?.length - ); - return ( { modifier="truncate" {...getTdProps({ columnKey: "assessment" })} > - - - - - - {hasAssessedArchetype ? ( - - - - ) : null} - - + { > - - {/* - - - - - {hasReviewedArchetype ? ( - - - - ) : null} - - */} = ({ application, isLoading = false }) => { +> = ({ application }) => { const { t } = useTranslation(); + const { archetypes, isFetching } = useFetchArchetypes(); + + const applicationArchetypes = application.archetypes?.map((archetypeRef) => { + return archetypes?.find((archetype) => archetype.id === archetypeRef.id); + }); + + const hasAssessedArchetype = applicationArchetypes?.some( + (archetype) => !!archetype?.assessments?.length + ); + const { assessments, isFetching: isFetchingAssessmentsById, fetchError, } = useFetchAssessmentsByItemId(false, application.id); - const { questionnaires } = useFetchQuestionnaires(); - const requiredQuestionnaireExists = questionnaires?.some( - (q) => q.required === true - ); - //NOTE: Application.assessed is true if an app is assigned to an archetype and no required questionnaires exist - if (application?.assessed && requiredQuestionnaireExists) { - return ; - } if (fetchError) { return ; } - if (isLoading || isFetchingAssessmentsById) { + if (isFetching || isFetchingAssessmentsById) { return ; } - if ( - assessments?.some((a) => a.status === "started" || a.status === "complete") + let statusPreset: IconedStatusPreset = "NotStarted"; // Default status + let tooltipCount: number = 0; + + if (application?.assessed) { + statusPreset = "Completed"; + } else if (hasAssessedArchetype) { + statusPreset = "InheritedAssessments"; + const assessedArchetypeCount = + applicationArchetypes?.filter((archetype) => !!archetype?.assessments) + .length || 0; + tooltipCount = assessedArchetypeCount; + } else if ( + assessments?.some( + (assessment) => + assessment.status === "started" || assessment.status === "complete" + ) ) { - return ; + statusPreset = "InProgress"; } - - return ; + console.log("tooltipCount", tooltipCount); + return ; }; diff --git a/client/src/app/pages/applications/components/application-review-status/application-review-status.tsx b/client/src/app/pages/applications/components/application-review-status/application-review-status.tsx index 1a8006af65..fccb89c46f 100644 --- a/client/src/app/pages/applications/components/application-review-status/application-review-status.tsx +++ b/client/src/app/pages/applications/components/application-review-status/application-review-status.tsx @@ -1,20 +1,22 @@ import React from "react"; -import { Application, Archetype } from "@app/api/models"; +import { Application } from "@app/api/models"; import { IconedStatus, IconedStatusPreset } from "@app/components/IconedStatus"; import { Spinner } from "@patternfly/react-core"; import { EmptyTextMessage } from "@app/components/EmptyTextMessage"; import { useTranslation } from "react-i18next"; +import { useFetchArchetypes } from "@app/queries/archetypes"; export interface ApplicationReviewStatusProps { application: Application; - archetypes?: Archetype[]; isLoading?: boolean; } export const ApplicationReviewStatus: React.FC< ApplicationReviewStatusProps -> = ({ application, archetypes, isLoading = false }) => { +> = ({ application }) => { const { t } = useTranslation(); + + const { archetypes, isFetching } = useFetchArchetypes(); const isAppReviewed = !!application.review; const applicationArchetypes = application.archetypes?.map((archetypeRef) => { @@ -25,22 +27,22 @@ export const ApplicationReviewStatus: React.FC< applicationArchetypes?.filter((archetype) => !!archetype?.review).length || 0; + if (isFetching) { + return ; + } + let statusPreset: IconedStatusPreset; let tooltipCount = 0; if (isAppReviewed) { statusPreset = "Completed"; } else if (reviewedArchetypeCount > 0) { - statusPreset = "Inherited"; + statusPreset = "InheritedReviews"; tooltipCount = reviewedArchetypeCount; } else { statusPreset = "NotStarted"; } - if (isLoading) { - return ; - } - if (!applicationArchetypes || applicationArchetypes.length === 0) { return ; }