2021-09-29 08:51:47 +00:00
|
|
|
import React, { useState } from "react";
|
2021-11-16 11:10:10 +00:00
|
|
|
|
|
|
|
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
2022-06-15 12:57:39 +00:00
|
|
|
import type { RealmSettingsParams } from "./routes/RealmSettings";
|
2021-11-16 11:10:10 +00:00
|
|
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
2021-04-29 06:28:59 +00:00
|
|
|
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
2021-09-02 20:14:43 +00:00
|
|
|
import { RealmSettingsTabs } from "./RealmSettingsTabs";
|
2022-06-15 12:57:39 +00:00
|
|
|
import { useParams } from "react-router-dom";
|
2021-10-21 18:40:02 +00:00
|
|
|
|
2021-10-29 16:11:06 +00:00
|
|
|
export default function RealmSettingsSection() {
|
2021-01-13 19:59:45 +00:00
|
|
|
const adminClient = useAdminClient();
|
2022-06-15 12:57:39 +00:00
|
|
|
const { realm: realmName } = useParams<RealmSettingsParams>();
|
2021-04-30 19:08:12 +00:00
|
|
|
const [realm, setRealm] = useState<RealmRepresentation>();
|
2021-09-27 17:15:36 +00:00
|
|
|
const [key, setKey] = useState(0);
|
|
|
|
|
|
|
|
const refresh = () => {
|
|
|
|
setKey(key + 1);
|
2022-06-15 12:57:39 +00:00
|
|
|
setRealm(undefined);
|
2021-09-27 17:15:36 +00:00
|
|
|
};
|
|
|
|
|
2022-02-28 15:22:00 +00:00
|
|
|
useFetch(() => adminClient.realms.findOne({ realm: realmName }), setRealm, [
|
|
|
|
key,
|
|
|
|
]);
|
2021-01-13 19:59:45 +00:00
|
|
|
|
2022-02-28 15:22:00 +00:00
|
|
|
if (!realm) {
|
2021-11-16 11:10:10 +00:00
|
|
|
return <KeycloakSpinner />;
|
2021-08-23 19:00:42 +00:00
|
|
|
}
|
2022-02-28 15:22:00 +00:00
|
|
|
return <RealmSettingsTabs realm={realm} refresh={refresh} />;
|
2021-10-29 16:11:06 +00:00
|
|
|
}
|