updated admin client with new endpoints (#725)
This commit is contained in:
parent
80fc50e642
commit
6864207dac
4 changed files with 19 additions and 40 deletions
|
@ -33,7 +33,7 @@
|
||||||
"@patternfly/react-table": "4.27.24",
|
"@patternfly/react-table": "4.27.24",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"i18next": "^20.3.1",
|
"i18next": "^20.3.1",
|
||||||
"keycloak-admin": "1.14.17",
|
"keycloak-admin": "1.14.18",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
|
|
|
@ -20,7 +20,6 @@ import { emailRegexPattern } from "../util";
|
||||||
import { useAdminClient } from "../context/auth/AdminClient";
|
import { useAdminClient } from "../context/auth/AdminClient";
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
import { getBaseUrl } from "../util";
|
|
||||||
|
|
||||||
import "./RealmSettingsSection.css";
|
import "./RealmSettingsSection.css";
|
||||||
import type UserRepresentation from "keycloak-admin/lib/defs/userRepresentation";
|
import type UserRepresentation from "keycloak-admin/lib/defs/userRepresentation";
|
||||||
|
@ -121,23 +120,15 @@ export const RealmSettingsEmailTab = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const testConnection = async () => {
|
const testConnection = async () => {
|
||||||
const response = await fetch(
|
try {
|
||||||
`${getBaseUrl(adminClient)}admin/realms/${
|
await adminClient.realms.testSMTPConnection(
|
||||||
realm.realm
|
{ realm: realm.realm! },
|
||||||
}/testSMTPConnection`,
|
getValues()["smtpServer"] || {}
|
||||||
{
|
);
|
||||||
method: "POST",
|
addAlert(t("testConnectionSuccess"), AlertVariant.success);
|
||||||
headers: {
|
} catch (error) {
|
||||||
Authorization: `bearer ${await adminClient.getAccessToken()}`,
|
addAlert(t("testConnectionError"), AlertVariant.danger);
|
||||||
Accept: "application/json",
|
}
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(getValues()["smtpServer"] as BodyInit),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
response.ok
|
|
||||||
? addAlert(t("testConnectionSuccess"), AlertVariant.success)
|
|
||||||
: addAlert(t("testConnectionError"), AlertVariant.danger);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -19,7 +19,6 @@ import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
||||||
import { FormPanel } from "../components/scroll-form/FormPanel";
|
import { FormPanel } from "../components/scroll-form/FormPanel";
|
||||||
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
||||||
import { useAdminClient } from "../context/auth/AdminClient";
|
import { useAdminClient } from "../context/auth/AdminClient";
|
||||||
import { getBaseUrl } from "../util";
|
|
||||||
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
||||||
|
|
||||||
type LocalizationTabProps = {
|
type LocalizationTabProps = {
|
||||||
|
@ -42,7 +41,6 @@ export const LocalizationTab = ({
|
||||||
const [defaultLocaleOpen, setDefaultLocaleOpen] = useState(false);
|
const [defaultLocaleOpen, setDefaultLocaleOpen] = useState(false);
|
||||||
|
|
||||||
const { getValues, control, handleSubmit } = useFormContext();
|
const { getValues, control, handleSubmit } = useFormContext();
|
||||||
// const [selectedLocale, setSelectedLocale] = useState("en");
|
|
||||||
const [valueSelected, setValueSelected] = useState(false);
|
const [valueSelected, setValueSelected] = useState(false);
|
||||||
const themeTypes = useServerInfo().themes!;
|
const themeTypes = useServerInfo().themes!;
|
||||||
|
|
||||||
|
@ -60,21 +58,11 @@ export const LocalizationTab = ({
|
||||||
|
|
||||||
const loader = async () => {
|
const loader = async () => {
|
||||||
if (realm) {
|
if (realm) {
|
||||||
const response = await fetch(
|
const result = await adminClient.realms.getRealmLocalizationTexts({
|
||||||
`${getBaseUrl(adminClient)}admin/realms/${realm.realm}/localization/${
|
realm: realm.realm!,
|
||||||
getValues("defaultLocale") || "en"
|
selectedLocale: getValues("defaultLocale") || "en",
|
||||||
}`,
|
});
|
||||||
{
|
return Object.keys(result).map((key) => [key, result[key]]);
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Authorization: `bearer ${await adminClient.getAccessToken()}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
const resultTest = Object.keys(result).map((key) => [key, result[key]]);
|
|
||||||
return resultTest;
|
|
||||||
}
|
}
|
||||||
return [[]];
|
return [[]];
|
||||||
};
|
};
|
||||||
|
|
|
@ -12329,10 +12329,10 @@ junk@^3.1.0:
|
||||||
resolved "https://registry.yarnpkg.com/junk/-/junk-3.1.0.tgz#31499098d902b7e98c5d9b9c80f43457a88abfa1"
|
resolved "https://registry.yarnpkg.com/junk/-/junk-3.1.0.tgz#31499098d902b7e98c5d9b9c80f43457a88abfa1"
|
||||||
integrity sha512-pBxcB3LFc8QVgdggvZWyeys+hnrNWg4OcZIU/1X59k5jQdLBlCsYGRQaz234SqoRLTCgMH00fY0xRJH+F9METQ==
|
integrity sha512-pBxcB3LFc8QVgdggvZWyeys+hnrNWg4OcZIU/1X59k5jQdLBlCsYGRQaz234SqoRLTCgMH00fY0xRJH+F9METQ==
|
||||||
|
|
||||||
keycloak-admin@1.14.17:
|
keycloak-admin@1.14.18:
|
||||||
version "1.14.17"
|
version "1.14.18"
|
||||||
resolved "https://registry.yarnpkg.com/keycloak-admin/-/keycloak-admin-1.14.17.tgz#fbeba43ae3a2d7ee6876afd334549f5675e272d8"
|
resolved "https://registry.yarnpkg.com/keycloak-admin/-/keycloak-admin-1.14.18.tgz#f6be3942d733fd4a1759665d7ff002bdee364e75"
|
||||||
integrity sha512-YbGq0wXOuK5StzKdmsO/2WwfJxQmVPUpRScYETkEj7HmiE0IwECzh1OjeSXZ9lXJPFwH+lCQ6q5pNEL6/6gv9Q==
|
integrity sha512-Jtj8guOrXNwyWXog8Q+Zzxemcj2yh+QxtOGDf+A2Q90lMVRL8+yR6zsKMeFFaWnoa8Z9F5LlBrL6eJFROsTJJw==
|
||||||
dependencies:
|
dependencies:
|
||||||
axios "^0.21.0"
|
axios "^0.21.0"
|
||||||
camelize "^1.0.0"
|
camelize "^1.0.0"
|
||||||
|
|
Loading…
Reference in a new issue