From 71c376a49079998cf5c19055405df14ff739bae8 Mon Sep 17 00:00:00 2001 From: Sebastian Sangervasi Date: Thu, 8 Sep 2022 11:58:34 -0700 Subject: [PATCH 1/5] ui/dataset: Spacing improvements for generate form --- .../features/dataset/DatabaseConnectForm.tsx | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx b/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx index 2153ea5928..c5d3f6d01e 100644 --- a/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx +++ b/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Spinner, Text, useToast } from "@fidesui/react"; +import { Box, Button, Text, useToast, VStack } from "@fidesui/react"; import { SerializedError } from "@reduxjs/toolkit"; import { FetchBaseQueryError } from "@reduxjs/toolkit/dist/query"; import { Form, Formik, FormikHelpers } from "formik"; @@ -34,6 +34,8 @@ const DatabaseConnectForm = () => { const organizationKey = "default_organization"; const [generate, { isLoading: isGenerating }] = useGenerateDatasetMutation(); const [createDataset, { isLoading: isCreating }] = useCreateDatasetMutation(); + const isLoading = isGenerating || isCreating; + const toast = useToast(); const router = useRouter(); @@ -91,27 +93,28 @@ const DatabaseConnectForm = () => { > {({ isSubmitting }) => (
- - Connect to one of your databases using a connection URL. You may - have received this URL from a colleague or your Ethyca developer - support engineer. - - - - - - - {isGenerating || isCreating ? : null} - + + + Connect to one of your databases using a connection URL. You may + have received this URL from a colleague or your Ethyca developer + support engineer. + + + + + + + +
)} From 5569dd8a00f7afd6fe2d7f9f7a1ef45e6d87ce66 Mon Sep 17 00:00:00 2001 From: Sebastian Sangervasi Date: Thu, 8 Sep 2022 15:57:28 -0700 Subject: [PATCH 2/5] ui/inputs: CustomSwitch component for switches --- .../src/features/common/form/inputs.tsx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/clients/ctl/admin-ui/src/features/common/form/inputs.tsx b/clients/ctl/admin-ui/src/features/common/form/inputs.tsx index 3e3a4fd533..480ea9361d 100644 --- a/clients/ctl/admin-ui/src/features/common/form/inputs.tsx +++ b/clients/ctl/admin-ui/src/features/common/form/inputs.tsx @@ -11,6 +11,7 @@ import { Radio, RadioGroup, Stack, + Switch, Textarea, TextareaProps, } from "@fidesui/react"; @@ -465,3 +466,38 @@ export const CustomRadioGroup = ({ ); }; + +interface CustomSwitchProps { + label: string; + tooltip?: string; +} +export const CustomSwitch = ({ + label, + tooltip, + ...props +}: CustomSwitchProps & FieldHookConfig) => { + const [field, meta] = useField({ ...props, type: "checkbox" }); + const isInvalid = !!(meta.touched && meta.error); + + return ( + + + + {label} + + + + {tooltip ? : null} + + + + ); +}; From 2b49e5837fa298fadc1daa7dd925b3172e6d4c8e Mon Sep 17 00:00:00 2001 From: Sebastian Sangervasi Date: Thu, 8 Sep 2022 15:58:04 -0700 Subject: [PATCH 3/5] ui/dataset: "Classify" toggle for fidesctl-plus --- .../features/dataset/DatabaseConnectForm.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx b/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx index c5d3f6d01e..4f9465c7f5 100644 --- a/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx +++ b/clients/ctl/admin-ui/src/features/dataset/DatabaseConnectForm.tsx @@ -5,6 +5,8 @@ import { Form, Formik, FormikHelpers } from "formik"; import { useRouter } from "next/router"; import * as Yup from "yup"; +import { useFeatures } from "~/features/common/features.slice"; +import { DEFAULT_ORGANIZATION_FIDES_KEY } from "~/features/organization"; import { Dataset, GenerateResponse, @@ -12,7 +14,7 @@ import { ValidTargets, } from "~/types/api"; -import { CustomTextInput } from "../common/form/inputs"; +import { CustomSwitch, CustomTextInput } from "../common/form/inputs"; import { getErrorMessage } from "../common/helpers"; import { successToastParams } from "../common/toast"; import { @@ -21,7 +23,7 @@ import { useGenerateDatasetMutation, } from "./dataset.slice"; -const initialValues = { url: "" }; +const initialValues = { url: "", classify: false }; type FormValues = typeof initialValues; @@ -30,14 +32,13 @@ const ValidationSchema = Yup.object().shape({ }); const DatabaseConnectForm = () => { - // TODO: where should this come from? - const organizationKey = "default_organization"; const [generate, { isLoading: isGenerating }] = useGenerateDatasetMutation(); const [createDataset, { isLoading: isCreating }] = useCreateDatasetMutation(); const isLoading = isGenerating || isCreating; const toast = useToast(); const router = useRouter(); + const features = useFeatures(); const handleSubmit = async ( values: FormValues, @@ -67,7 +68,7 @@ const DatabaseConnectForm = () => { }; const response = await generate({ - organization_key: organizationKey, + organization_key: DEFAULT_ORGANIZATION_FIDES_KEY, generate: { config: { connection_string: values.url }, target: ValidTargets.DB, @@ -85,7 +86,7 @@ const DatabaseConnectForm = () => { return ( { + + {features.plus ? ( + + ) : null} +