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

View file

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