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",
|
||||
"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",
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
);
|
||||
response.ok
|
||||
? addAlert(t("testConnectionSuccess"), AlertVariant.success)
|
||||
: addAlert(t("testConnectionError"), AlertVariant.danger);
|
||||
try {
|
||||
await adminClient.realms.testSMTPConnection(
|
||||
{ realm: realm.realm! },
|
||||
getValues()["smtpServer"] || {}
|
||||
);
|
||||
addAlert(t("testConnectionSuccess"), AlertVariant.success);
|
||||
} catch (error) {
|
||||
addAlert(t("testConnectionError"), AlertVariant.danger);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
@ -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 [[]];
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue