changed to use route functions (#1919)

fixes: #1196
This commit is contained in:
Erik Jan de Wit 2022-02-08 23:10:46 +01:00 committed by GitHub
parent b4738bf897
commit d4b1230260
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View file

@ -284,7 +284,7 @@ export default function ClientProfileForm() {
component={(props) => (
<Link
{...props}
to={`/${realm}/realm-settings/clientPolicies`}
to={toClientPolicies({ realm, tab: "profiles" })}
/>
)}
data-testid={"cancelCreateProfile"}
@ -466,7 +466,7 @@ export default function ClientProfileForm() {
component={(props) => (
<Link
{...props}
to={`/${realm}/realm-settings/clientPolicies`}
to={toClientPolicies({ realm, tab: "profiles" })}
/>
)}
variant="primary"

View file

@ -194,9 +194,7 @@ export default function NewClientPolicyCondition() {
policies: updatedPolicies,
});
setPolicies(updatedPolicies);
history.push(
`/${realm}/realm-settings/clientPolicies/${policyName}/edit-policy`
);
history.push(toEditClientPolicy({ realm, policyName }));
addAlert(
conditionName
? t("realm-settings:updateClientConditionSuccess")

View file

@ -36,7 +36,10 @@ import type ClientPolicyRepresentation from "@keycloak/keycloak-admin-client/lib
import { toNewClientPolicyCondition } from "./routes/AddCondition";
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import { toEditClientPolicyCondition } from "./routes/EditCondition";
import type { EditClientPolicyParams } from "./routes/EditClientPolicy";
import {
EditClientPolicyParams,
toEditClientPolicy,
} from "./routes/EditClientPolicy";
import { AddClientProfileModal } from "./AddClientProfileModal";
import type ClientProfileRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientProfileRepresentation";
import { toClientPolicies } from "./routes/ClientPolicies";
@ -245,7 +248,7 @@ export default function NewClientPolicyForm() {
AlertVariant.success
);
history.push(
`/${realm}/realm-settings/clientPolicies/${createdForm.name}/edit-policy`
toEditClientPolicy({ realm, policyName: createdForm.name! })
);
setShowAddConditionsAndProfilesForm(true);
} catch (error) {
@ -299,7 +302,7 @@ export default function NewClientPolicyForm() {
});
addAlert(t("deleteConditionSuccess"), AlertVariant.success);
history.push(
`/${realm}/realm-settings/clientPolicies/${formValues.name}/edit-policy`
toEditClientPolicy({ realm, policyName: formValues.name! })
);
} catch (error) {
addError(t("deleteConditionError"), error);
@ -344,7 +347,7 @@ export default function NewClientPolicyForm() {
});
addAlert(t("deleteClientPolicyProfileSuccess"), AlertVariant.success);
history.push(
`/${realm}/realm-settings/clientPolicies/${formValues.name}/edit-policy`
toEditClientPolicy({ realm, policyName: formValues.name! })
);
} catch (error) {
addError(t("deleteClientPolicyProfileError"), error);
@ -407,9 +410,7 @@ export default function NewClientPolicyForm() {
policies: newPolicies,
});
setPolicies(newPolicies);
history.push(
`/${realm}/realm-settings/clientPolicies/${formValues.name}/edit-policy`
);
history.push(toEditClientPolicy({ realm, policyName: formValues.name! }));
addAlert(
t("realm-settings:addClientProfileSuccess"),
AlertVariant.success