From cc13fcec14e7ba6a67be4c4d18b44843b7022988 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Mon, 13 Jun 2022 12:16:44 +0200 Subject: [PATCH] Added way to edit flow name and description (#2775) --- ...itFlowDropdown.tsx => AddFlowDropdown.tsx} | 8 +- src/authentication/components/EditFlow.tsx | 150 ++++++++++++++++++ src/authentication/components/FlowRow.tsx | 16 +- 3 files changed, 164 insertions(+), 10 deletions(-) rename src/authentication/components/{EditFlowDropdown.tsx => AddFlowDropdown.tsx} (95%) create mode 100644 src/authentication/components/EditFlow.tsx diff --git a/src/authentication/components/EditFlowDropdown.tsx b/src/authentication/components/AddFlowDropdown.tsx similarity index 95% rename from src/authentication/components/EditFlowDropdown.tsx rename to src/authentication/components/AddFlowDropdown.tsx index df46429f63..0a4154a8d6 100644 --- a/src/authentication/components/EditFlowDropdown.tsx +++ b/src/authentication/components/AddFlowDropdown.tsx @@ -14,7 +14,7 @@ import { AddStepModal, FlowType } from "./modals/AddStepModal"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { AddSubFlowModal, Flow } from "./modals/AddSubFlowModal"; -type EditFlowDropdownProps = { +type AddFlowDropdownProps = { execution: ExpandableExecution; onAddExecution: ( execution: ExpandableExecution, @@ -23,11 +23,11 @@ type EditFlowDropdownProps = { onAddFlow: (execution: ExpandableExecution, flow: Flow) => void; }; -export const EditFlowDropdown = ({ +export const AddFlowDropdown = ({ execution, onAddExecution, onAddFlow, -}: EditFlowDropdownProps) => { +}: AddFlowDropdownProps) => { const { t } = useTranslation("authentication"); const adminClient = useAdminClient(); @@ -45,7 +45,7 @@ export const EditFlowDropdown = ({ ); return ( - + <> void; +}; + +export const EditFlow = ({ execution, onRowChange }: EditFlowProps) => { + const { t } = useTranslation("authentication"); + const { register, errors, reset, handleSubmit } = useForm(); + + const [show, toggle] = useToggle(); + + const update = (values: ExpandableExecution) => { + onRowChange({ ...execution, ...values }); + toggle(); + }; + + useEffect(() => { + reset(execution); + }, [execution, reset]); + + return ( + <> + + + + {show && ( + + {t("edit")} + , + , + ]} + > +
+ + } + > + + + + } + validated={ + errors.description + ? ValidatedOptions.error + : ValidatedOptions.default + } + helperTextInvalid={errors.description?.message} + > + + +
+
+ )} + + ); +}; diff --git a/src/authentication/components/FlowRow.tsx b/src/authentication/components/FlowRow.tsx index 4937efa38a..da0e997e09 100644 --- a/src/authentication/components/FlowRow.tsx +++ b/src/authentication/components/FlowRow.tsx @@ -21,7 +21,8 @@ import type { Flow } from "./modals/AddSubFlowModal"; import { FlowTitle } from "./FlowTitle"; import { FlowRequirementDropdown } from "./FlowRequirementDropdown"; import { ExecutionConfigModal } from "./ExecutionConfigModal"; -import { EditFlowDropdown } from "./EditFlowDropdown"; +import { AddFlowDropdown } from "./AddFlowDropdown"; +import { EditFlow } from "./EditFlow"; import "./flow-row.css"; @@ -104,11 +105,14 @@ export const FlowRow = ({ )} {execution.authenticationFlow && !builtIn && ( - + <> + + + )} {!builtIn && (