Skip to content

Commit

Permalink
Take/retake flow for assessments
Browse files Browse the repository at this point in the history
Share questions and answers tables

Hide answer key in assessment review screen

Navigate back to assessment actions after assessment

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

Separate out archived questionnaires

Add continue button logic

Add delete assessment mock and functionality

Move shared questionnaire data

Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Sep 7, 2023
1 parent 245b8c8 commit f066ed2
Show file tree
Hide file tree
Showing 26 changed files with 1,770 additions and 672 deletions.
3 changes: 2 additions & 1 deletion client/src/app/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum Paths {
applicationsImportsDetails = "/applications/application-imports/:importId",
applicationsAssessment = "/applications/assessment/:assessmentId",
assessmentActions = "/applications/assessment-actions/:applicationId",
assessmentSummary = "/applications/assessment-summary/:assessmentId",
applicationsReview = "/applications/application/:applicationId/review",
applicationsAnalysis = "/applications/analysis",
archetypes = "/archetypes",
Expand Down Expand Up @@ -50,7 +51,7 @@ export enum Paths {
proxies = "/proxies",
migrationTargets = "/migration-targets",
assessment = "/assessment",
questionnaire = "/questionnaire",
questionnaire = "/questionnaire/:questionnaireId",
jira = "/jira",
}

Expand Down
14 changes: 13 additions & 1 deletion client/src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,23 @@ const AssessmentSettings = lazy(
"./pages/assessment-management/assessment-settings/assessment-settings-page"
)
);

const Questionnaire = lazy(
() => import("./pages/assessment-management/questionnaire/questionnaire-page")
);

const AssessmentActions = lazy(
() =>
import("./pages/applications/assessment-actions/assessment-actions-page")
);
const Archetypes = lazy(() => import("./pages/archetypes/archetypes-page"));

const AssessmentSummary = lazy(
() =>
import(
"./pages/applications/application-assessment/components/assessment-summary/assessment-summary-page"
)
);
export interface IRoute {
path: string;
comp: React.ComponentType<any>;

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

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
Expand Down Expand Up @@ -77,7 +85,11 @@ export const devRoutes: IRoute[] = [
comp: AssessmentActions,
exact: false,
},

{
path: Paths.assessmentSummary,
comp: AssessmentSummary,
exact: false,
},
{
path: Paths.applicationsReview,
comp: Reviews,
Expand Down
1 change: 1 addition & 0 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface Application {
binary?: string;
migrationWave: Ref | null;
assessments?: Ref[];
assessed?: boolean;
}

export interface Review {
Expand Down
8 changes: 8 additions & 0 deletions client/src/app/api/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ export const getAssessments = (filters: {
.then((response) => response.data);
};

export const getAssessmentsByAppId = (
applicationId?: number | string
): Promise<Assessment[]> => {
return axios

Check warning on line 243 in client/src/app/api/rest.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/api/rest.ts#L242-L243

Added lines #L242 - L243 were not covered by tests
.get(`${APPLICATIONS}/${applicationId}/assessments`)
.then((response) => response.data);

Check warning on line 245 in client/src/app/api/rest.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/api/rest.ts#L245

Added line #L245 was not covered by tests
};

export const createAssessment = (
obj: InitialAssessment
): Promise<Assessment> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import { IconedStatus } from "@app/components/IconedStatus";
import { TimesCircleIcon } from "@patternfly/react-icons";
import { WarningTriangleIcon } from "@patternfly/react-icons";

export interface IAnswerTableProps {
answers: Answer[];
hideAnswerKey?: boolean;
}

const AnswerTable: React.FC<IAnswerTableProps> = ({ answers }) => {
const AnswerTable: React.FC<IAnswerTableProps> = ({
answers,
hideAnswerKey,
}) => {
const { t } = useTranslation();

const tableControls = useLocalTableControls({
idProperty: "text",
items: answers,
items: hideAnswerKey
? answers.filter((answer) => answer.selected)
: answers,
columnNames: {
choice: "Answer choice",
weight: "Weight",
Expand Down Expand Up @@ -99,10 +106,10 @@ const AnswerTable: React.FC<IAnswerTableProps> = ({ answers }) => {
>
Tags to be applied:
</Text>
{answer?.autoAnswerFor?.map((tag: any) => {
{answer?.autoAnswerFor?.map((tag, index) => {
return (
<div style={{ flex: "0 0 6em" }}>
<Label color="grey">{tag.tag}</Label>
<div key={index} style={{ flex: "0 0 6em" }}>
<Label color="grey">{tag.tag.name}</Label>
</div>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ import {
} from "@app/components/TableControls";
import { useTranslation } from "react-i18next";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import { Assessment, Question } from "@app/api/models";
import { Assessment, Question, Questionnaire } from "@app/api/models";
import { useLocalTableControls } from "@app/hooks/table-controls";
import { Label } from "@patternfly/react-core";
import AnswerTable from "./answer-table";
import { NoDataEmptyState } from "@app/components/NoDataEmptyState";
import AnswerTable from "@app/components/answer-table/answer-table";

const QuestionsTable: React.FC<{
fetchError?: Error;
questions?: Question[];
isSearching?: boolean;
assessmentData?: Assessment | null;
data?: Assessment | Questionnaire | null;
isAllQuestionsTab?: boolean;
hideAnswerKey?: boolean;
}> = ({
fetchError,
questions,
isSearching = false,
assessmentData,
data,
isAllQuestionsTab = false,
hideAnswerKey,
}) => {
const tableControls = useLocalTableControls({
idProperty: "text",
Expand Down Expand Up @@ -90,7 +92,7 @@ const QuestionsTable: React.FC<{
<Tbody>
{currentPageItems?.map((question, rowIndex) => {
const sectionName =
assessmentData?.sections.find((section) =>
data?.sections.find((section) =>
section.questions.includes(question)
)?.name || "";
return (
Expand Down Expand Up @@ -127,7 +129,10 @@ const QuestionsTable: React.FC<{
>
<ExpandableRowContent>
{question.explanation}
<AnswerTable answers={question.answers} />
<AnswerTable
hideAnswerKey={hideAnswerKey}
answers={question.answers}
/>
</ExpandableRowContent>
</Td>
</Tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
import { useParams } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { AxiosError } from "axios";
Expand All @@ -8,25 +8,21 @@ import {
Bullseye,
} from "@patternfly/react-core";
import BanIcon from "@patternfly/react-icons/dist/esm/icons/ban-icon";
import yaml from "js-yaml";

import { AssessmentRoute } from "@app/Paths";
import { Assessment } from "@app/api/models";
import { getAssessmentById } from "@app/api/rest";
import { getAxiosErrorMessage } from "@app/utils/utils";
import { ApplicationAssessmentPage } from "./components/application-assessment-page";
import { ApplicationAssessmentWizard } from "./components/application-assessment-wizard";
import { SimpleEmptyState } from "@app/components/SimpleEmptyState";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
import { useFetchAssessmentByID } from "@app/queries/assessments";
import { useFetchAssessmentById } from "@app/queries/assessments";

export const ApplicationAssessment: React.FC = () => {
const { t } = useTranslation();

const { assessmentId } = useParams<AssessmentRoute>();
const { assessment, isFetching, fetchError } =
useFetchAssessmentByID(assessmentId);
useFetchAssessmentById(assessmentId);

const [saveError, setSaveError] = useState<AxiosError>();

Expand Down
Loading

0 comments on commit f066ed2

Please sign in to comment.