Redirect to flow detail after duplicate (#3199)
This commit is contained in:
parent
fd29c77928
commit
5ad85d38da
2 changed files with 18 additions and 5 deletions
|
@ -52,7 +52,7 @@ describe("Authentication test", () => {
|
|||
duplicateFlowModal.fill("Copy of browser");
|
||||
|
||||
masthead.checkNotificationMessage("Flow successfully duplicated");
|
||||
listingPage.itemExist("Copy of browser");
|
||||
detailPage.flowExists("Copy of browser");
|
||||
});
|
||||
|
||||
it("Should fail duplicate with empty flow name", () => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { useNavigate } from "react-router-dom-v5-compat";
|
||||
import {
|
||||
AlertVariant,
|
||||
Button,
|
||||
|
@ -13,6 +14,8 @@ import {
|
|||
import { useAdminClient } from "../context/auth/AdminClient";
|
||||
import { useAlerts } from "../components/alert/Alerts";
|
||||
import { NameDescription } from "./form/NameDescription";
|
||||
import { toFlow } from "./routes/Flow";
|
||||
import { useRealm } from "../context/realm-context/RealmContext";
|
||||
|
||||
type DuplicateFlowModalProps = {
|
||||
name: string;
|
||||
|
@ -34,6 +37,8 @@ export const DuplicateFlowModal = ({
|
|||
const { setValue, trigger, getValues } = form;
|
||||
const { adminClient } = useAdminClient();
|
||||
const { addAlert, addError } = useAlerts();
|
||||
const navigate = useNavigate();
|
||||
const { realm } = useRealm();
|
||||
|
||||
useEffect(() => {
|
||||
setValue("description", description);
|
||||
|
@ -48,11 +53,11 @@ export const DuplicateFlowModal = ({
|
|||
flow: name,
|
||||
newName: form.alias,
|
||||
});
|
||||
if (form.description !== description) {
|
||||
const newFlow = (
|
||||
await adminClient.authenticationManagement.getFlows()
|
||||
).find((flow) => flow.alias === form.alias)!;
|
||||
|
||||
if (form.description !== description) {
|
||||
newFlow.description = form.description;
|
||||
await adminClient.authenticationManagement.updateFlow(
|
||||
{ flowId: newFlow.id! },
|
||||
|
@ -60,6 +65,14 @@ export const DuplicateFlowModal = ({
|
|||
);
|
||||
}
|
||||
addAlert(t("copyFlowSuccess"), AlertVariant.success);
|
||||
navigate(
|
||||
toFlow({
|
||||
realm,
|
||||
id: newFlow.id!,
|
||||
usedBy: "notInUse",
|
||||
builtIn: newFlow.builtIn ? "builtIn" : undefined,
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
addError("authentication:copyFlowError", error);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue