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

✨ Fix missing archetype flow pieces #1368

Merged
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
8 changes: 5 additions & 3 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"manageDependencies": "Manage dependencies",
"manageImports": "Manage imports",
"next": "Next",
"override": "Override",
"review": "Review",
"save": "Save",
"saveAndReview": "Save and review",
Expand All @@ -51,7 +52,8 @@
"selectPage": "Select page",
"submitReview": "Submit review",
"view": "View",
"viewErrorReport": "View error report"
"viewErrorReport": "View error report",
"viewArchetypes": "View archetypes"
},
"colors": {
"black": "Black",
Expand Down Expand Up @@ -168,8 +170,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 @@ -60,7 +60,7 @@
);
export interface IRoute {
path: string;
comp: React.ComponentType<any>;

Check warning on line 63 in client/src/app/Routes.tsx

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
exact?: boolean;
routes?: undefined;
}
Expand Down Expand Up @@ -102,7 +102,12 @@
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 @@
migrationWave: Ref | null;
assessments?: Ref[];
assessed?: boolean;
archetypes?: Ref[];
}

export interface Review {
Expand Down Expand Up @@ -203,7 +204,7 @@
identity?: Ref;
createTime?: string;
createUser?: string;
id: any;

Check warning on line 207 in client/src/app/api/models.ts

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
enabled: boolean;
}

Expand Down Expand Up @@ -360,7 +361,7 @@

export interface TaskgroupTask {
name: string;
data: any;

Check warning on line 364 in client/src/app/api/models.ts

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
application: Ref;
}

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

export interface ConfirmDialogProps {
Expand All @@ -20,13 +21,17 @@

confirmBtnLabel: string;
cancelBtnLabel: string;
customActionLabel?: string;

inProgress?: boolean;
confirmBtnVariant: ButtonVariant;

alertMessage?: string;

onClose: () => void;
onConfirm: () => void;
onCancel?: () => void;
onCustomAction?: () => void;
}

export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
Expand All @@ -36,11 +41,14 @@
message,
confirmBtnLabel,
cancelBtnLabel,
customActionLabel,
inProgress,
confirmBtnVariant,
onClose,
onConfirm,
onCancel,
onCustomAction,
alertMessage,
}) => {
const confirmBtn = (
<Button
Expand Down Expand Up @@ -68,6 +76,21 @@
</Button>
) : undefined;

const customActionBtn = onCustomAction ? (
<Button

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L80 was not covered by tests
key="custom-action"
id="custom-action-button"
aria-label={customActionLabel}
variant={ButtonVariant.secondary}
isDisabled={inProgress}
onClick={onCustomAction}
>
{customActionLabel}
</Button>
) : undefined;

const actions = [confirmBtn, customActionBtn, cancelBtn].filter(Boolean);

return (
<Modal
id="confirm-dialog"
Expand All @@ -77,8 +100,11 @@
isOpen={isOpen}
onClose={onClose}
aria-label="Confirm dialog"
actions={onCancel ? [confirmBtn, cancelBtn] : [confirmBtn]}
actions={actions}
>
{alertMessage ? (
<Alert variant="warning" isInline title={alertMessage} />

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L106 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
5 changes: 5 additions & 0 deletions client/src/app/hooks/useIsArchetype.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useLocation } from "react-router-dom";

const useIsArchetype = () => useLocation().pathname.includes("/archetypes/");

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 All @@ -41,7 +40,7 @@ const AssessmentActions: React.FC = () => {
</BreadcrumbItem>
)}
<BreadcrumbItem to="#" isActive>
Assessment
{isArchetype ? archetype?.name : application?.name}
</BreadcrumbItem>
</Breadcrumb>
</PageSection>
Expand Down
Loading
Loading