fixed default value and link to settings on create (#657)

This commit is contained in:
Erik Jan de Wit 2021-06-09 09:09:59 +02:00 committed by GitHub
parent d77d9a2a63
commit fbe3986a57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View file

@ -33,7 +33,9 @@ type ScopeFormProps = {
export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
const { t } = useTranslation("client-scopes");
const { register, control, handleSubmit, errors, setValue } = useForm();
const { register, control, handleSubmit, errors, setValue } = useForm<
ClientScopeRepresentation
>({ defaultValues: { attributes: { "display-on-consent-screen": "true" } } });
const history = useHistory();
const { realm } = useRealm();
@ -202,7 +204,7 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
<Controller
name="attributes.display-on-consent-screen"
control={control}
defaultValue="false"
defaultValue="true"
render={({ onChange, value }) => (
<Switch
id="kc-display.on.consent.screen"
@ -249,7 +251,7 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
<Controller
name="attributes.include-in-token-scope"
control={control}
defaultValue="false"
defaultValue="true"
render={({ onChange, value }) => (
<Switch
id="includeInTokenScope"

View file

@ -1,5 +1,5 @@
import React, { useState } from "react";
import { useParams } from "react-router-dom";
import { useHistory, useParams } from "react-router-dom";
import { useTranslation } from "react-i18next";
import {
AlertVariant,
@ -26,12 +26,15 @@ import {
changeScope,
ClientScopeDefaultOptionalType,
} from "../../components/client-scope/ClientScopeTypes";
import { useRealm } from "../../context/realm-context/RealmContext";
export const ClientScopeForm = () => {
const { t } = useTranslation("client-scopes");
const [clientScope, setClientScope] = useState<
ClientScopeDefaultOptionalType
>();
const history = useHistory();
const { realm } = useRealm();
const [hide, setHide] = useState(false);
const adminClient = useAdminClient();
@ -118,6 +121,11 @@ export const ClientScopeForm = () => {
{ ...clientScopes, id: scope.id },
clientScopes.type
);
history.push(
`/${realm}/client-scopes/${scope.id}/${
clientScopes.type || "none"
}/settings`
);
}
addAlert(t((id ? "update" : "create") + "Success"), AlertVariant.success);
} catch (error) {