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