diff --git a/client/public/locales/en/translation.json b/client/public/locales/en/translation.json index 3e66f825c1..952ef47fbc 100644 --- a/client/public/locales/en/translation.json +++ b/client/public/locales/en/translation.json @@ -182,8 +182,9 @@ "noResultsFoundTitle": "No results found", "overrideAssessmentDescription": "The application {{name}} already is associated with archetypes: {{what}}.", "overrideAssessmentConfirmation": "Do you want to create a dedicated assessment for this application and override the inherited archetype assessment(s)?", - "overrideReviewConfirmation": "This application has already been reviewed. Do you want to continue?", - "overrideArchetypeReviewConfirmation": "This archetype has already been reviewed. Do you want to continue?", + "overrideArchetypeReviewDescription": "The application {{name}} already is associated with archetypes: {{what}}.", + "overrideArchetypeReviewConfirmation": "Do you want to create a dedicated review for this application and override the inherited archetype review?", + "overrideReviewConfirmation": "This archetype has already been reviewed. Do you want to continue?", "reasonForError": "The reported reason for the error:", "reviewInstructions": "Use this section to provide your assessment of the possible migration/modernization plan and effort estimation.", "savingSelection": "Saving selection", 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 71eac890f8..d7e745b596 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -88,7 +88,11 @@ import { ImportApplicationsForm } from "../components/import-applications-form"; import { ConditionalRender } from "@app/components/ConditionalRender"; import { NoDataEmptyState } from "@app/components/NoDataEmptyState"; import { ConditionalTooltip } from "@app/components/ConditionalTooltip"; -import { getAssessmentsByItemId, getTaskById } from "@app/api/rest"; +import { + getArchetypeById, + getAssessmentsByItemId, + getTaskById, +} from "@app/api/rest"; import { ApplicationDependenciesForm } from "@app/components/ApplicationDependenciesFormContainer/ApplicationDependenciesForm"; import { useFetchArchetypes } from "@app/queries/archetypes"; import { useState } from "react"; @@ -123,6 +127,9 @@ export const ApplicationsTable: React.FC = () => { Ref[] | null >(null); + const [archetypeRefsToOverrideReview, setArchetypeRefsToOverrideReview] = + React.useState(null); + const [applicationToAssess, setApplicationToAssess] = React.useState(null); @@ -617,8 +624,37 @@ export const ApplicationsTable: React.FC = () => { handleNavToAssessment(application); } }; - const reviewSelectedApp = (application: Application) => { - if (application.review) { + + const reviewSelectedApp = async (application: Application) => { + if (application?.archetypes?.length) { + for (const archetypeRef of application.archetypes) { + try { + const archetype = await getArchetypeById(archetypeRef.id); + + if (archetype?.review) { + setArchetypeRefsToOverrideReview(application.archetypes); + break; + } else if (application.review) { + setReviewToEdit(application.id); + } else { + history.push( + formatPath(Paths.applicationsReview, { + applicationId: application.id, + }) + ); + } + } catch (error) { + console.error( + `Error fetching archetype with ID ${archetypeRef.id}:`, + error + ); + pushNotification({ + title: t("terms.error"), + variant: "danger", + }); + } + } + } else if (application.review) { setReviewToEdit(application.id); } else { history.push( @@ -1133,6 +1169,33 @@ export const ApplicationsTable: React.FC = () => { setReviewToEdit(null); }} /> + archetypeRef.name) + .join(", ") || "Archetype name", + })} + message={t("message.overrideArchetypeReviewConfirmation")} + titleIconVariant={"warning"} + isOpen={archetypeRefsToOverrideReview !== null} + confirmBtnVariant={ButtonVariant.primary} + confirmBtnLabel={t("actions.override")} + cancelBtnLabel={t("actions.cancel")} + onCancel={() => setArchetypeRefsToOverrideReview(null)} + onClose={() => setArchetypeRefsToOverrideReview(null)} + onConfirm={() => { + history.push( + formatPath(Paths.applicationsReview, { + applicationId: activeItem?.id, + }) + ); + setArchetypeRefsToOverride(null); + }} + />