updated admin client with new endpoints (#725)

This commit is contained in:
Erik Jan de Wit 2021-06-28 08:02:35 +02:00 committed by GitHub
parent 80fc50e642
commit 6864207dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 40 deletions

View file

@ -33,7 +33,7 @@
"@patternfly/react-table": "4.27.24",
"file-saver": "^2.0.5",
"i18next": "^20.3.1",
"keycloak-admin": "1.14.17",
"keycloak-admin": "1.14.18",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"react": "^16.14.0",

View file

@ -20,7 +20,6 @@ import { emailRegexPattern } from "../util";
import { useAdminClient } from "../context/auth/AdminClient";
import { useAlerts } from "../components/alert/Alerts";
import { useRealm } from "../context/realm-context/RealmContext";
import { getBaseUrl } from "../util";
import "./RealmSettingsSection.css";
import type UserRepresentation from "keycloak-admin/lib/defs/userRepresentation";
@ -121,23 +120,15 @@ export const RealmSettingsEmailTab = ({
};
const testConnection = async () => {
const response = await fetch(
`${getBaseUrl(adminClient)}admin/realms/${
realm.realm
}/testSMTPConnection`,
{
method: "POST",
headers: {
Authorization: `bearer ${await adminClient.getAccessToken()}`,
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(getValues()["smtpServer"] as BodyInit),
}
try {
await adminClient.realms.testSMTPConnection(
{ realm: realm.realm! },
getValues()["smtpServer"] || {}
);
response.ok
? addAlert(t("testConnectionSuccess"), AlertVariant.success)
: addAlert(t("testConnectionError"), AlertVariant.danger);
addAlert(t("testConnectionSuccess"), AlertVariant.success);
} catch (error) {
addAlert(t("testConnectionError"), AlertVariant.danger);
}
};
return (

View file

@ -19,7 +19,6 @@ import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import { FormPanel } from "../components/scroll-form/FormPanel";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient";
import { getBaseUrl } from "../util";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
type LocalizationTabProps = {
@ -42,7 +41,6 @@ export const LocalizationTab = ({
const [defaultLocaleOpen, setDefaultLocaleOpen] = useState(false);
const { getValues, control, handleSubmit } = useFormContext();
// const [selectedLocale, setSelectedLocale] = useState("en");
const [valueSelected, setValueSelected] = useState(false);
const themeTypes = useServerInfo().themes!;
@ -60,21 +58,11 @@ export const LocalizationTab = ({
const loader = async () => {
if (realm) {
const response = await fetch(
`${getBaseUrl(adminClient)}admin/realms/${realm.realm}/localization/${
getValues("defaultLocale") || "en"
}`,
{
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;
const result = await adminClient.realms.getRealmLocalizationTexts({
realm: realm.realm!,
selectedLocale: getValues("defaultLocale") || "en",
});
return Object.keys(result).map((key) => [key, result[key]]);
}
return [[]];
};

View file

@ -12329,10 +12329,10 @@ junk@^3.1.0:
resolved "https://registry.yarnpkg.com/junk/-/junk-3.1.0.tgz#31499098d902b7e98c5d9b9c80f43457a88abfa1"
integrity sha512-pBxcB3LFc8QVgdggvZWyeys+hnrNWg4OcZIU/1X59k5jQdLBlCsYGRQaz234SqoRLTCgMH00fY0xRJH+F9METQ==
keycloak-admin@1.14.17:
version "1.14.17"
resolved "https://registry.yarnpkg.com/keycloak-admin/-/keycloak-admin-1.14.17.tgz#fbeba43ae3a2d7ee6876afd334549f5675e272d8"
integrity sha512-YbGq0wXOuK5StzKdmsO/2WwfJxQmVPUpRScYETkEj7HmiE0IwECzh1OjeSXZ9lXJPFwH+lCQ6q5pNEL6/6gv9Q==
keycloak-admin@1.14.18:
version "1.14.18"
resolved "https://registry.yarnpkg.com/keycloak-admin/-/keycloak-admin-1.14.18.tgz#f6be3942d733fd4a1759665d7ff002bdee364e75"
integrity sha512-Jtj8guOrXNwyWXog8Q+Zzxemcj2yh+QxtOGDf+A2Q90lMVRL8+yR6zsKMeFFaWnoa8Z9F5LlBrL6eJFROsTJJw==
dependencies:
axios "^0.21.0"
camelize "^1.0.0"