Skip to content

Commit

Permalink
Fix missing archetype flow pieces
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <ibolton@redhat.com>

Drive isArchetype off of location in case of hard nav

Signed-off-by: ibolton336 <ibolton@redhat.com>

Remove redundant query

Signed-off-by: ibolton336 <ibolton@redhat.com>

Modify confirm dialog to include archetype assessment override alert

Only show matching assessments for each entity type

Update assessment override to use fetchassessment by archetype id approach

wire up create assessment on confirm

Use hook for isArchetype

update test file

Update logic for take assessment

Wire discard assessment/review back in

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Sep 19, 2023
1 parent a93733f commit 8632697
Show file tree
Hide file tree
Showing 20 changed files with 279 additions and 116 deletions.
4 changes: 2 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
"noDataAvailableTitle": "No data available",
"noResultsFoundBody": "No results match the filter criteria. Remove all filters or clear all filters to show results.",
"noResultsFoundTitle": "No results found",
"overrideAssessmentConfirmation": "This application has already been assessed. Do you want to continue?",
"overrideArchetypeConfirmation": "The archetype for this application already has an assessment. Do you want to create a dedicated assessment for this application?",
"overrideAssessmentDescription": "The archetype for {{what}} already has an assessment.",
"overrideAssessmentConfirmation": "Do you want to create a dedicated assessment for this application?",
"overrideReviewConfirmation": "This application 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.",
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export enum Paths {
applicationsAssessment = "/applications/assessment/:assessmentId",
applicationAssessmentActions = "/applications/assessment-actions/:applicationId",
archetypeAssessmentActions = "/archetypes/assessment-actions/:archetypeId",
assessmentSummary = "/applications/assessment-summary/:assessmentId",
applicationAssessmentSummary = "/applications/assessment-summary/:assessmentId",
archetypeAssessmentSummary = "/archetypes/assessment-summary/:assessmentId",
applicationsReview = "/applications/:applicationId/review",
applicationsAnalysis = "/applications/analysis",
archetypes = "/archetypes",
Expand Down
7 changes: 6 additions & 1 deletion client/src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ export const devRoutes: IRoute[] = [
exact: false,
},
{
path: Paths.assessmentSummary,
path: Paths.applicationAssessmentSummary,
comp: AssessmentSummary,
exact: false,
},
{
path: Paths.archetypeAssessmentSummary,
comp: AssessmentSummary,
exact: false,
},
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface Application {
migrationWave: Ref | null;
assessments?: Ref[];
assessed?: boolean;
archetypes?: Ref[];
}

export interface Review {
Expand Down Expand Up @@ -749,6 +750,6 @@ export interface Archetype {
assessmentTags?: Tag[];
stakeholders?: Ref[];
stakeholderGroups?: Ref[];
applications?: Application[];
applications?: Ref[];
assessments?: Ref[];
}
7 changes: 7 additions & 0 deletions client/src/app/components/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Modal,
ButtonVariant,
ModalVariant,
Alert,
} from "@patternfly/react-core";

export interface ConfirmDialogProps {
Expand All @@ -24,6 +25,8 @@ export interface ConfirmDialogProps {
inProgress?: boolean;
confirmBtnVariant: ButtonVariant;

alertMessage?: string;

onClose: () => void;
onConfirm: () => void;
onCancel?: () => void;
Expand All @@ -41,6 +44,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
onClose,
onConfirm,
onCancel,
alertMessage,
}) => {
const confirmBtn = (
<Button
Expand Down Expand Up @@ -79,6 +83,9 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
aria-label="Confirm dialog"
actions={onCancel ? [confirmBtn, cancelBtn] : [confirmBtn]}
>
{alertMessage ? (
<Alert variant="warning" isInline title={alertMessage} />

Check warning on line 87 in client/src/app/components/ConfirmDialog.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/components/ConfirmDialog.tsx#L87

Added line #L87 was not covered by tests
) : null}
{message}
</Modal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "@patternfly/react-core";
import AngleLeftIcon from "@patternfly/react-icons/dist/esm/icons/angle-left-icon";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Paths } from "@app/Paths";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
Expand All @@ -25,6 +24,7 @@ import { Assessment, Questionnaire } from "@app/api/models";
import QuestionnaireSectionTabTitle from "./components/questionnaire-section-tab-title";
import { AxiosError } from "axios";
import { formatPath } from "@app/utils/utils";
import useIsArchetype from "@app/hooks/useIsArchetype";

export enum SummaryType {
Assessment = "Assessment",
Expand All @@ -36,17 +36,15 @@ interface QuestionnaireSummaryProps {
fetchError?: AxiosError | null;
summaryData: Assessment | Questionnaire | undefined;
summaryType: SummaryType;
isArchetype?: boolean;
}

const QuestionnaireSummary: React.FC<QuestionnaireSummaryProps> = ({
summaryData,
summaryType,
isFetching = false,
fetchError = null,
isArchetype,
}) => {
const { t } = useTranslation();
const isArchetype = useIsArchetype();

const [activeSectionIndex, setActiveSectionIndex] = useState<"all" | number>(
"all"
Expand Down Expand Up @@ -86,17 +84,20 @@ const QuestionnaireSummary: React.FC<QuestionnaireSummaryProps> = ({
if (!summaryData) {
return <div>No data available.</div>;
}

const dynamicPath = isArchetype
? formatPath(Paths.archetypeAssessmentActions, {
archetypeId: (summaryData as Assessment)?.archetype?.id,
})
: formatPath(Paths.applicationAssessmentActions, {
applicationId: (summaryData as Assessment)?.application?.id,
});

const BreadcrumbPath =
summaryType === SummaryType.Assessment ? (
<Breadcrumb>
<BreadcrumbItem>
<Link
to={formatPath(Paths.applicationAssessmentActions, {
applicationId: (summaryData as Assessment)?.application?.id,
})}
>
Assessment
</Link>
<Link to={dynamicPath}>Assessment</Link>
</BreadcrumbItem>
<BreadcrumbItem to="#" isActive>
{summaryData?.name}
Expand Down
17 changes: 17 additions & 0 deletions client/src/app/hooks/useIsArchetype.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";

const useIsArchetype = () => {
const location = useLocation();
const [isArchetype, setIsArchetype] = useState(
location.pathname.includes("/archetypes/")
);

useEffect(() => {
setIsArchetype(location.pathname.includes("/archetypes/"));
}, [location.pathname]);

return isArchetype;
};

export default useIsArchetype;
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ export const ApplicationsTable: React.FC = () => {
title: t("actions.review"),
onClick: () => reviewSelectedApp(application),
},
...(application?.review
? [
{
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentOrReviewToDiscard(application),
},
]
: []),
{
title: t("actions.delete"),
onClick: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const ApplicationAssessmentStatus: React.FC<
> = ({ assessments, isLoading = false, fetchError = null }) => {
const { t } = useTranslation();
//TODO: remove this once we have a proper assessment status
const { assessment } = useFetchAssessmentById(assessments?.[0]?.id || 0);
const { assessment } = useFetchAssessmentById(assessments?.[0]?.id);

if (fetchError) {
return <EmptyTextMessage message={t("terms.notAvailable")} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Test questionnaire
description: This is a sample questionnaire in YAML format
revision: 1
required: true
sections:
- order: 1
Expand All @@ -22,7 +21,6 @@ sections:
applyTags: []
autoAnswerFor: [{ category: Category1, tag: Tag1 }]
selected: false
autoAnswered: false
- order: 2
text: Blue
risk: green
Expand All @@ -31,14 +29,12 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
- order: 2
text: What is your favorite sport?
explanation: Please select your favorite sport.
includeFor:
excludeFor:
- category: Category1
tag: Tag1
excludeFor: []
answers:
- order: 1
text: Soccer
Expand All @@ -48,7 +44,6 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
- order: 2
text: Cycling
risk: red
Expand All @@ -57,7 +52,6 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
- order: 3
text: Climbing
risk: yellow
Expand All @@ -66,7 +60,6 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
- order: 4
text: Swimming
risk: yellow
Expand All @@ -75,7 +68,6 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
- order: 5
text: Running
risk: red
Expand All @@ -84,7 +76,6 @@ sections:
applyTags: []
autoAnswerFor: []
selected: false
autoAnswered: false
thresholds:
red: 5
yellow: 10
Expand Down
1 change: 1 addition & 0 deletions client/src/app/pages/assessment/assessment-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AssessmentPage: React.FC = () => {
const { t } = useTranslation();

const { assessmentId } = useParams<AssessmentRoute>();

const { assessment, isFetching, fetchError } =
useFetchAssessmentById(assessmentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import { Link, useParams } from "react-router-dom";
import { AssessmentActionsRoute, Paths } from "@app/Paths";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
import { useFetchApplicationByID } from "@app/queries/applications";
import AssessmentActionsTable from "./components/assessment-actions-table";
import { useFetchArchetypeById } from "@app/queries/archetypes";
import { useFetchApplicationById } from "@app/queries/applications";
import useIsArchetype from "@app/hooks/useIsArchetype";

const AssessmentActions: React.FC = () => {
const { applicationId, archetypeId } = useParams<AssessmentActionsRoute>();
const isArchetype = location.pathname.includes("/archetypes/");
console.log("isArchetype", isArchetype);
const isArchetype = useIsArchetype();

const { application } = useFetchApplicationByID(applicationId || "");
const { archetype } = useFetchArchetypeById(archetypeId || "");
const { archetype } = useFetchArchetypeById(archetypeId);
const { application } = useFetchApplicationById(applicationId);

console.log("archetype", archetype);
return (
<>
<PageSection variant={PageSectionVariants.light}>
Expand Down
Loading

0 comments on commit 8632697

Please sign in to comment.