Skip to content

Commit

Permalink
✨ Override review confirmation & drawer updates (#1527)
Browse files Browse the repository at this point in the history
- Adds review override as discussed in the Tuesday UXD call
- Shows either the app level review if it exists or the matched
archetype reviews in the app drawer review tab - not both.
<img width="769" alt="Screenshot 2023-11-08 at 4 12 41 PM"
src="https://github.com/konveyor/tackle2-ui/assets/11218376/d47f7851-1623-4f5e-8c6a-2f7f715f2b1d">

---------

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Nov 10, 2023
1 parent 7185f58 commit 35eb2f1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 17 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 @@ -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

0 comments on commit 35eb2f1

Please sign in to comment.