From 2549a88f2446c575d865952dbd61635f2ed19ae6 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 9 Jul 2024 07:39:01 +0200 Subject: [PATCH 1/2] update realm when changing bind Signed-off-by: Erik Jan de Wit --- js/apps/admin-ui/src/authentication/BindFlowDialog.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx b/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx index 53e26d78fa29..6fdd00950bb9 100644 --- a/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx +++ b/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx @@ -29,16 +29,15 @@ export const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => { const { t } = useTranslation(); const form = useForm(); const { addAlert, addError } = useAlerts(); - const { realm } = useRealm(); + const { realm, realmRepresentation: realmRep, refresh } = useRealm(); const onSubmit = async ({ bindingType }: BindingForm) => { - const realmRep = await adminClient.realms.findOne({ realm }); - try { await adminClient.realms.update( { realm }, { ...realmRep, [bindingType]: flowAlias }, ); + refresh(); addAlert(t("updateFlowSuccess"), AlertVariant.success); } catch (error) { addError("updateFlowError", error); From 01bf8269082d6b393fca7b5e88d0207544d2bcde Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 11 Jul 2024 11:57:44 +0200 Subject: [PATCH 2/2] also update used by label Signed-off-by: Erik Jan de Wit --- .../admin-ui/src/authentication/AuthenticationSection.tsx | 4 +--- js/apps/admin-ui/src/authentication/components/UsedBy.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx b/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx index 457027aad998..65e18c4b567b 100644 --- a/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx +++ b/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx @@ -244,9 +244,7 @@ export default function AuthenticationSection() { { name: "usedBy", displayKey: "usedBy", - cellRenderer: (row) => ( - - ), + cellRenderer: (row) => , }, { name: "description", diff --git a/js/apps/admin-ui/src/authentication/components/UsedBy.tsx b/js/apps/admin-ui/src/authentication/components/UsedBy.tsx index 7e2d7b638617..2ed4c5e42587 100644 --- a/js/apps/admin-ui/src/authentication/components/UsedBy.tsx +++ b/js/apps/admin-ui/src/authentication/components/UsedBy.tsx @@ -1,4 +1,3 @@ -import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; import { Button, Modal, @@ -17,10 +16,10 @@ import useToggle from "../../utils/useToggle"; import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection"; import style from "./used-by.module.css"; +import { useRealm } from "../../context/realm-context/RealmContext"; type UsedByProps = { authType: AuthenticationType; - realm: RealmRepresentation; }; 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 { realmRepresentation: realm } = useRealm(); const [open, toggle] = useToggle(); - const key = Object.entries(realm).find( + const key = Object.entries(realm!).find( (e) => e[1] === usedBy?.values[0], )?.[0];