Fixed route params for policy condition (#3497)

This commit is contained in:
Erik Jan de Wit 2022-10-06 12:29:16 +02:00 committed by GitHub
parent 8a6df5d743
commit c37e8714ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -26,10 +26,7 @@ import type ComponentTypeRepresentation from "@keycloak/keycloak-admin-client/li
import { useRealm } from "../context/realm-context/RealmContext"; import { useRealm } from "../context/realm-context/RealmContext";
import type { ConfigPropertyRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigInfoRepresentation"; import type { ConfigPropertyRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigInfoRepresentation";
import type ClientPolicyConditionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientPolicyConditionRepresentation"; import type ClientPolicyConditionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientPolicyConditionRepresentation";
import { import { toEditClientPolicy } from "./routes/EditClientPolicy";
EditClientPolicyParams,
toEditClientPolicy,
} from "./routes/EditClientPolicy";
import type { EditClientPolicyConditionParams } from "./routes/EditCondition"; import type { EditClientPolicyConditionParams } from "./routes/EditCondition";
import { DynamicComponents } from "../components/dynamic/DynamicComponents"; import { DynamicComponents } from "../components/dynamic/DynamicComponents";
@ -58,8 +55,8 @@ export default function NewClientPolicyCondition() {
ConfigPropertyRepresentation[] ConfigPropertyRepresentation[]
>([]); >([]);
const { policyName } = useParams<EditClientPolicyParams>(); const { policyName, conditionName } =
const { conditionName } = useParams<EditClientPolicyConditionParams>(); useParams<EditClientPolicyConditionParams>();
const serverInfo = useServerInfo(); const serverInfo = useServerInfo();
const form = useForm({ const form = useForm({
@ -163,7 +160,7 @@ export default function NewClientPolicyCondition() {
policies: updatedPolicies, policies: updatedPolicies,
}); });
setPolicies(updatedPolicies); setPolicies(updatedPolicies);
navigate(toEditClientPolicy({ realm, policyName })); navigate(toEditClientPolicy({ realm, policyName: policyName! }));
addAlert( addAlert(
conditionName conditionName
? t("realm-settings:updateClientConditionSuccess") ? t("realm-settings:updateClientConditionSuccess")
@ -268,7 +265,7 @@ export default function NewClientPolicyCondition() {
variant="link" variant="link"
data-testid="addCondition-cancelBtn" data-testid="addCondition-cancelBtn"
onClick={() => onClick={() =>
navigate(toEditClientPolicy({ realm, policyName })) navigate(toEditClientPolicy({ realm, policyName: policyName! }))
} }
> >
{t("common:cancel")} {t("common:cancel")}

View file

@ -6,7 +6,7 @@ import type { RouteDef } from "../../route-config";
export type EditClientPolicyConditionParams = { export type EditClientPolicyConditionParams = {
realm: string; realm: string;
policyName?: string; policyName?: string;
conditionName: string; conditionName?: string;
}; };
export const EditClientPolicyConditionRoute: RouteDef = { export const EditClientPolicyConditionRoute: RouteDef = {