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 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 { useTranslation } from "react-i18next";
|
||||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
import { Controller, useForm, useWatch } from "react-hook-form";
|
||||||
import {
|
import {
|
||||||
|
@ -28,6 +28,7 @@ import { useLoginProviders } from "../../context/server-info/ServerInfoProvider"
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { getProtocolName } from "../../clients/utils";
|
import { getProtocolName } from "../../clients/utils";
|
||||||
|
import { toClientScopes } from "../routes/ClientScopes";
|
||||||
|
|
||||||
type ScopeFormProps = {
|
type ScopeFormProps = {
|
||||||
clientScope: ClientScopeRepresentation;
|
clientScope: ClientScopeRepresentation;
|
||||||
|
@ -41,7 +42,6 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
useForm<ClientScopeRepresentation>({
|
useForm<ClientScopeRepresentation>({
|
||||||
defaultValues: { attributes: { "display-on-consent-screen": "true" } },
|
defaultValues: { attributes: { "display-on-consent-screen": "true" } },
|
||||||
});
|
});
|
||||||
const history = useHistory();
|
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
const providers = useLoginProviders();
|
const providers = useLoginProviders();
|
||||||
|
@ -316,7 +316,9 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
onClick={() => history.push(`/${realm}/client-scopes`)}
|
component={(props) => (
|
||||||
|
<Link {...props} to={toClientScopes({ realm })}></Link>
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{t("common:cancel")}
|
{t("common:cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -34,6 +34,7 @@ import {
|
||||||
} from "../../components/client-scope/ClientScopeTypes";
|
} from "../../components/client-scope/ClientScopeTypes";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { toMapper } from "../routes/Mapper";
|
import { toMapper } from "../routes/Mapper";
|
||||||
|
import { toClientScope } from "../routes/ClientScope";
|
||||||
|
|
||||||
export default function ClientScopeForm() {
|
export default function ClientScopeForm() {
|
||||||
const { t } = useTranslation("client-scopes");
|
const { t } = useTranslation("client-scopes");
|
||||||
|
@ -130,9 +131,12 @@ export default function ClientScopeForm() {
|
||||||
clientScopes.type
|
clientScopes.type
|
||||||
);
|
);
|
||||||
history.push(
|
history.push(
|
||||||
`/${realm}/client-scopes/${scope.id}/${
|
toClientScope({
|
||||||
clientScopes.type || "none"
|
realm,
|
||||||
}/settings`
|
id: scope.id!,
|
||||||
|
type: clientScopes.type || "none",
|
||||||
|
tab: "settings",
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
addAlert(t((id ? "update" : "create") + "Success"), AlertVariant.success);
|
addAlert(t((id ? "update" : "create") + "Success"), AlertVariant.success);
|
||||||
|
|
Loading…
Reference in a new issue