Use route functions for navigation in client scopes (#1472)
This commit is contained in:
parent
d2b11312d8
commit
25d2e426b6
2 changed files with 12 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { useHistory, useParams } from "react-router-dom";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||
import {
|
||||
|
@ -28,6 +28,7 @@ import { useLoginProviders } from "../../context/server-info/ServerInfoProvider"
|
|||
import { convertToFormValues } from "../../util";
|
||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||
import { getProtocolName } from "../../clients/utils";
|
||||
import { toClientScopes } from "../routes/ClientScopes";
|
||||
|
||||
type ScopeFormProps = {
|
||||
clientScope: ClientScopeRepresentation;
|
||||
|
@ -41,7 +42,6 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
|||
useForm<ClientScopeRepresentation>({
|
||||
defaultValues: { attributes: { "display-on-consent-screen": "true" } },
|
||||
});
|
||||
const history = useHistory();
|
||||
const { realm } = useRealm();
|
||||
|
||||
const providers = useLoginProviders();
|
||||
|
@ -316,7 +316,9 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
|||
</Button>
|
||||
<Button
|
||||
variant="link"
|
||||
onClick={() => history.push(`/${realm}/client-scopes`)}
|
||||
component={(props) => (
|
||||
<Link {...props} to={toClientScopes({ realm })}></Link>
|
||||
)}
|
||||
>
|
||||
{t("common:cancel")}
|
||||
</Button>
|
||||
|
|
|
@ -34,6 +34,7 @@ import {
|
|||
} from "../../components/client-scope/ClientScopeTypes";
|
||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||
import { toMapper } from "../routes/Mapper";
|
||||
import { toClientScope } from "../routes/ClientScope";
|
||||
|
||||
export default function ClientScopeForm() {
|
||||
const { t } = useTranslation("client-scopes");
|
||||
|
@ -130,9 +131,12 @@ export default function ClientScopeForm() {
|
|||
clientScopes.type
|
||||
);
|
||||
history.push(
|
||||
`/${realm}/client-scopes/${scope.id}/${
|
||||
clientScopes.type || "none"
|
||||
}/settings`
|
||||
toClientScope({
|
||||
realm,
|
||||
id: scope.id!,
|
||||
type: clientScopes.type || "none",
|
||||
tab: "settings",
|
||||
})
|
||||
);
|
||||
}
|
||||
addAlert(t((id ? "update" : "create") + "Success"), AlertVariant.success);
|
||||
|
|
Loading…
Reference in a new issue