Skip to content

Commit

Permalink
Override review confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Nov 8, 2023
1 parent c66003e commit 24d6d87
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 5 deletions.
5 changes: 3 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -123,6 +127,9 @@ export const ApplicationsTable: React.FC = () => {
Ref[] | null
>(null);

const [archetypeRefsToOverrideReview, setArchetypeRefsToOverrideReview] =
React.useState<Ref[] | null>(null);

const [applicationToAssess, setApplicationToAssess] =
React.useState<Application | null>(null);

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -1133,6 +1169,33 @@ export const ApplicationsTable: React.FC = () => {
setReviewToEdit(null);
}}
/>
<ConfirmDialog
title={t("composed.new", {
what: t("terms.review").toLowerCase(),
})}
alertMessage={t("message.overrideArchetypeReviewDescription", {
what:
archetypeRefsToOverrideReview
?.map((archetypeRef) => 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);
}}
/>
<ConfirmDialog
title={t("composed.new", {
what: t("terms.assessment").toLowerCase(),
Expand Down

0 comments on commit 24d6d87

Please sign in to comment.