Skip to content

Commit

Permalink
234/wizard nav updates (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
LKCSmith authored Oct 30, 2022
1 parent 0ed1baa commit b879eda
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const AuthenticateAwsForm = () => {
variant="outline"
onClick={!isSubmitting ? handleCancel : onOpen}
>
Cancel
Back
</Button>
<Button
type="submit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Box, Button, Divider, Stack } from "@fidesui/react";
import HorizontalStepper from "common/HorizontalStepper";
import Stepper from "common/Stepper";
import React from "react";

import { useAppDispatch, useAppSelector } from "~/app/hooks";
import { CloseSolidIcon } from "~/features/common/Icon";
Expand Down Expand Up @@ -85,23 +84,20 @@ const ConfigWizardWalkthrough = () => {
{reviewStep === 1 && (
<DescribeSystemStep
system={system}
onCancel={handleCancelSetup}
onSuccess={handleSuccess}
abridged
/>
)}
{reviewStep === 2 && system && (
<PrivacyDeclarationStep
system={system}
onCancel={handleCancelSetup}
onSuccess={handleSuccess}
abridged
/>
)}
{reviewStep === 3 && system && (
<ReviewSystemStep
system={system}
onCancel={handleCancelSetup}
onSuccess={() => dispatch(changeReviewStep())}
abridged
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const ScanResultsForm = () => {

<HStack>
<Button variant="outline" onClick={handleCancel}>
Cancel
Back
</Button>
<Button
type="submit"
Expand Down
17 changes: 11 additions & 6 deletions clients/admin-ui/src/features/system/DescribeSystemStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { Box, Button, Heading, Stack, useToast } from "@fidesui/react";
import { SerializedError } from "@reduxjs/toolkit";
import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query/fetchBaseQuery";
import { Form, Formik } from "formik";
import React, { useMemo, useState } from "react";
import { useMemo, useState } from "react";
import * as Yup from "yup";

import { useAppDispatch } from "~/app/hooks";
import {
CustomCreatableMultiSelect,
CustomMultiSelect,
CustomTextInput,
} from "~/features/common/form/inputs";
import { getErrorMessage, isErrorResult } from "~/features/common/helpers";
import { changeStep } from "~/features/config-wizard/config-wizard.slice";
import DescribeSystemsFormExtension from "~/features/system/DescribeSystemsFormExtension";
import {
defaultInitialValues,
Expand Down Expand Up @@ -44,14 +46,12 @@ const SystemHeading = ({ system }: { system?: System }) => {
};

interface Props {
onCancel: () => void;
onSuccess: (system: System) => void;
abridged?: boolean;
system?: System;
}

const DescribeSystemStep = ({
onCancel,
onSuccess,
abridged,
system: passedInSystem,
Expand All @@ -66,6 +66,7 @@ const DescribeSystemStep = ({
const [createSystem] = useCreateSystemMutation();
const [updateSystem] = useUpdateSystemMutation();
const [isLoading, setIsLoading] = useState(false);
const dispatch = useAppDispatch();
const { data: systems } = useGetAllSystemsQuery();
const systemOptions = systems
? systems.map((s) => ({ label: s.name ?? s.fides_key, value: s.fides_key }))
Expand All @@ -81,6 +82,10 @@ const DescribeSystemStep = ({

const toast = useToast();

const handleBack = () => {
dispatch(changeStep(2));
};

const handleSubmit = async (values: FormValues) => {
const systemBody = transformFormValuesToSystem(values);

Expand Down Expand Up @@ -187,13 +192,13 @@ const DescribeSystemStep = ({
</Stack>
<Box>
<Button
onClick={() => onCancel()}
onClick={handleBack}
mr={2}
size="sm"
variant="outline"
data-testid="cancel-btn"
data-testid="back-btn"
>
Cancel
Back
</Button>
<Button
type="submit"
Expand Down
8 changes: 1 addition & 7 deletions clients/admin-ui/src/features/system/ManualSystemFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,17 @@ const ManualSystemFlow = () => {
</GridItem>
<GridItem w="75%">
{currentStepIndex === 0 ? (
<DescribeSystemStep
onSuccess={handleSuccess}
onCancel={goBack}
system={activeSystem}
/>
<DescribeSystemStep onSuccess={handleSuccess} system={activeSystem} />
) : null}
{currentStepIndex === 1 && activeSystem ? (
<PrivacyDeclarationStep
system={activeSystem}
onSuccess={handleSuccess}
onCancel={goBack}
/>
) : null}
{currentStepIndex === 2 && activeSystem ? (
<ReviewSystemStep
system={activeSystem}
onCancel={goBack}
onSuccess={() => setCurrentStepIndex(currentStepIndex + 1)}
/>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ const PrivacyDeclarationForm = ({
{onCancel && (
<Button
variant="outline"
data-testid="cancel-btn"
data-testid="back-btn"
onClick={onCancel}
>
Cancel
Back
</Button>
)}
<Button
Expand Down
23 changes: 12 additions & 11 deletions clients/admin-ui/src/features/system/PrivacyDeclarationStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Box, Button, Divider, Heading, Stack, useToast } from "@fidesui/react";
import { SerializedError } from "@reduxjs/toolkit";
import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query/fetchBaseQuery";
import { FormikHelpers } from "formik";
import React, { Fragment, useState } from "react";
import { Fragment, useState } from "react";

import { useAppDispatch } from "~/app/hooks";
import { getErrorMessage, isErrorResult } from "~/features/common/helpers";
import { changeReviewStep } from "~/features/config-wizard/config-wizard.slice";
import { PrivacyDeclaration, System } from "~/types/api";

import PrivacyDeclarationAccordion from "./PrivacyDeclarationAccordion";
Expand All @@ -23,23 +25,22 @@ const transformFormValuesToDeclaration = (

interface Props {
system: System;
onCancel: () => void;
onSuccess: (system: System) => void;
abridged?: boolean;
}

const PrivacyDeclarationStep = ({
system,
onCancel,
onSuccess,
abridged,
}: Props) => {
const PrivacyDeclarationStep = ({ system, onSuccess, abridged }: Props) => {
const toast = useToast();
const [formDeclarations, setFormDeclarations] = useState<
PrivacyDeclaration[]
>(system?.privacy_declarations ? [...system.privacy_declarations] : []);
const [updateSystem] = useUpdateSystemMutation();
const [isLoading, setIsLoading] = useState(false);
const dispatch = useAppDispatch();

const handleBack = () => {
dispatch(changeReviewStep(1));
};

const handleSubmit = async () => {
const systemBodyWithDeclaration = {
Expand Down Expand Up @@ -145,13 +146,13 @@ const PrivacyDeclarationStep = ({
<PrivacyDeclarationForm onSubmit={addDeclaration} abridged={abridged} />
<Box>
<Button
onClick={onCancel}
onClick={handleBack}
mr={2}
size="sm"
variant="outline"
data-testid="cancel-btn"
data-testid="back-btn"
>
Cancel
Back
</Button>
<Button
colorScheme="primary"
Expand Down
19 changes: 13 additions & 6 deletions clients/admin-ui/src/features/system/ReviewSystemStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@ import {
Text,
} from "@fidesui/react";
import { Form, Formik } from "formik";
import React, { Fragment } from "react";
import { Fragment } from "react";

import { useAppDispatch } from "~/app/hooks";
import ReviewSystemFormExtension from "~/features/system/ReviewSystemFormExtension";
import { System } from "~/types/api";

import { changeReviewStep } from "../config-wizard/config-wizard.slice";
import TaxonomyEntityTag from "../taxonomy/TaxonomyEntityTag";
import { ReviewItem } from "./form-layout";
import PrivacyDeclarationAccordion from "./PrivacyDeclarationAccordion";

interface Props {
system: System;
onCancel: () => void;
onSuccess: () => void;
abridged?: boolean;
}

const ReviewSystemStep = ({ system, onCancel, onSuccess, abridged }: Props) => {
const ReviewSystemStep = ({ system, onSuccess, abridged }: Props) => {
const dispatch = useAppDispatch();

const handleBack = () => {
dispatch(changeReviewStep(2));
};

const handleSubmit = () => {
onSuccess();
};
Expand Down Expand Up @@ -78,13 +85,13 @@ const ReviewSystemStep = ({ system, onCancel, onSuccess, abridged }: Props) => {
</Stack>
<Box>
<Button
onClick={() => onCancel()}
onClick={handleBack}
mr={2}
size="sm"
variant="outline"
data-testid="cancel-btn"
data-testid="back-btn"
>
Cancel
Back
</Button>
{/* TODO FUTURE: This button doesn't do any registering yet until data maps are added */}
<Button
Expand Down

0 comments on commit b879eda

Please sign in to comment.