Skip to content

Commit 9efe7e8

Browse files
Backport to update realm when changing bind (#31212)
Signed-off-by: Agnieszka Gancarczyk <[email protected]> Co-authored-by: Agnieszka Gancarczyk <[email protected]>
1 parent 6783b97 commit 9efe7e8

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

js/apps/admin-ui/src/authentication/AuthenticationSection.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ export default function AuthenticationSection() {
244244
{
245245
name: "usedBy",
246246
displayKey: "usedBy",
247-
cellRenderer: (row) => (
248-
<UsedBy authType={row} realm={realm} />
249-
),
247+
cellRenderer: (row) => <UsedBy authType={row} />,
250248
},
251249
{
252250
name: "description",

js/apps/admin-ui/src/authentication/BindFlowDialog.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ export const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => {
2929
const { t } = useTranslation();
3030
const form = useForm<BindingForm>();
3131
const { addAlert, addError } = useAlerts();
32-
const { realm } = useRealm();
32+
const { realm, realmRepresentation: realmRep, refresh } = useRealm();
3333

3434
const onSubmit = async ({ bindingType }: BindingForm) => {
35-
const realmRep = await adminClient.realms.findOne({ realm });
36-
3735
try {
3836
await adminClient.realms.update(
3937
{ realm },
4038
{ ...realmRep, [bindingType]: flowAlias },
4139
);
40+
refresh();
4241
addAlert(t("updateFlowSuccess"), AlertVariant.success);
4342
} catch (error) {
4443
addError("updateFlowError", error);

js/apps/admin-ui/src/authentication/components/UsedBy.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
21
import {
32
Button,
43
Modal,
@@ -17,10 +16,10 @@ import useToggle from "../../utils/useToggle";
1716
import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection";
1817

1918
import style from "./used-by.module.css";
19+
import { useRealm } from "../../context/realm-context/RealmContext";
2020

2121
type UsedByProps = {
2222
authType: AuthenticationType;
23-
realm: RealmRepresentation;
2423
};
2524

2625
const Label = ({ label }: { label: string }) => (
@@ -96,11 +95,12 @@ const UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {
9695
);
9796
};
9897

99-
export const UsedBy = ({ authType: { id, usedBy }, realm }: UsedByProps) => {
98+
export const UsedBy = ({ authType: { id, usedBy } }: UsedByProps) => {
10099
const { t } = useTranslation();
100+
const { realmRepresentation: realm } = useRealm();
101101
const [open, toggle] = useToggle();
102102

103-
const key = Object.entries(realm).find(
103+
const key = Object.entries(realm!).find(
104104
(e) => e[1] === usedBy?.values[0],
105105
)?.[0];
106106

0 commit comments

Comments
 (0)