update realm when changing bind (#31133)
* update realm when changing bind Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * also update used by label Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
88725cd0e7
commit
2bd17cdc7c
3 changed files with 7 additions and 10 deletions
|
@ -245,9 +245,7 @@ export default function AuthenticationSection() {
|
||||||
{
|
{
|
||||||
name: "usedBy",
|
name: "usedBy",
|
||||||
displayKey: "usedBy",
|
displayKey: "usedBy",
|
||||||
cellRenderer: (row) => (
|
cellRenderer: (row) => <UsedBy authType={row} />,
|
||||||
<UsedBy authType={row} realm={realm} />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
|
|
|
@ -29,16 +29,15 @@ export const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const form = useForm<BindingForm>();
|
const form = useForm<BindingForm>();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
const { realm } = useRealm();
|
const { realm, realmRepresentation: realmRep, refresh } = useRealm();
|
||||||
|
|
||||||
const onSubmit = async ({ bindingType }: BindingForm) => {
|
const onSubmit = async ({ bindingType }: BindingForm) => {
|
||||||
const realmRep = await adminClient.realms.findOne({ realm });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await adminClient.realms.update(
|
await adminClient.realms.update(
|
||||||
{ realm },
|
{ realm },
|
||||||
{ ...realmRep, [bindingType]: flowAlias },
|
{ ...realmRep, [bindingType]: flowAlias },
|
||||||
);
|
);
|
||||||
|
refresh();
|
||||||
addAlert(t("updateFlowSuccess"), AlertVariant.success);
|
addAlert(t("updateFlowSuccess"), AlertVariant.success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError("updateFlowError", error);
|
addError("updateFlowError", error);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Modal,
|
Modal,
|
||||||
|
@ -17,10 +16,10 @@ import useToggle from "../../utils/useToggle";
|
||||||
import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection";
|
import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection";
|
||||||
|
|
||||||
import style from "./used-by.module.css";
|
import style from "./used-by.module.css";
|
||||||
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
|
|
||||||
type UsedByProps = {
|
type UsedByProps = {
|
||||||
authType: AuthenticationType;
|
authType: AuthenticationType;
|
||||||
realm: RealmRepresentation;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Label = ({ label }: { label: string }) => (
|
const Label = ({ label }: { label: string }) => (
|
||||||
|
@ -96,11 +95,12 @@ const UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UsedBy = ({ authType: { id, usedBy }, realm }: UsedByProps) => {
|
export const UsedBy = ({ authType: { id, usedBy } }: UsedByProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { realmRepresentation: realm } = useRealm();
|
||||||
const [open, toggle] = useToggle();
|
const [open, toggle] = useToggle();
|
||||||
|
|
||||||
const key = Object.entries(realm).find(
|
const key = Object.entries(realm!).find(
|
||||||
(e) => e[1] === usedBy?.values[0],
|
(e) => e[1] === usedBy?.values[0],
|
||||||
)?.[0];
|
)?.[0];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue