Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Override review confirmation & drawer updates #1527

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,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 @@ -92,7 +92,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 @@ -127,9 +131,15 @@ export const ApplicationsTable: React.FC = () => {
Ref[] | null
>(null);

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

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

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

/*** Analysis */

const [isAnalyzeModalOpen, setAnalyzeModalOpen] = useState(false);
Expand Down Expand Up @@ -635,8 +645,38 @@ export const ApplicationsTable: React.FC = () => {
handleNavToAssessment(application);
}
};
const reviewSelectedApp = (application: Application) => {
if (application.review) {

const reviewSelectedApp = async (application: Application) => {
setApplicationToReview(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 @@ -1202,6 +1242,34 @@ 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={() => {
applicationToReview &&
history.push(
formatPath(Paths.applicationsReview, {
applicationId: applicationToReview?.id,
})
);
setArchetypeRefsToOverride(null);
}}
/>
<ConfirmDialog
title={t("composed.new", {
what: t("terms.assessment").toLowerCase(),
Expand All @@ -1226,11 +1294,6 @@ export const ApplicationsTable: React.FC = () => {
handleNavToViewArchetypes(applicationToAssess);
}}
onConfirm={() => {
history.push(
formatPath(Paths.applicationAssessmentActions, {
applicationId: activeItem?.id,
})
);
setArchetypeRefsToOverride(null);
applicationToAssess && handleNavToAssessment(applicationToAssess);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const ReviewFields: React.FC<{
.filter(Boolean);

const groupedReviewList: ReviewDrawerLabelItem[] = [
...(archetypeReview
...(archetypeReview && !appReview
? [
{
review: archetypeReview,
Expand All @@ -66,12 +66,11 @@ export const ReviewFields: React.FC<{
isArchetype: false,
},
]
: []),
...matchedArchetypeReviews.map((archetypeReview) => ({
review: archetypeReview,
name: archetypeReview?.archetype?.name,
isArchetype: true,
})),
: matchedArchetypeReviews.map((archetypeReview) => ({
review: archetypeReview,
name: archetypeReview?.archetype?.name,
isArchetype: true,
}))),
].filter((item) => item.review?.proposedAction);

return (
Expand Down
Loading