Reference admin client from module instead of context (#20118)

This commit is contained in:
Jon Koops 2023-05-03 13:51:02 +00:00 committed by GitHub
parent 228da0e29a
commit 483246e24b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
179 changed files with 1027 additions and 1208 deletions

View file

@ -13,7 +13,6 @@ import { KeycloakSpinner } from "./components/keycloak-spinner/KeycloakSpinner";
import { RealmsProvider } from "./context/RealmsContext";
import { RecentRealmsProvider } from "./context/RecentRealms";
import { AccessContextProvider } from "./context/access/Access";
import { AdminClientProvider } from "./context/auth/AdminClient";
import { RealmContextProvider } from "./context/realm-context/RealmContext";
import { ServerInfoProvider } from "./context/server-info/ServerInfoProvider";
import { WhoAmIContextProvider } from "./context/whoami/WhoAmI";
@ -23,23 +22,21 @@ import { AuthWall } from "./root/AuthWall";
export const mainPageContentId = "kc-main-content-page-container";
const AppContexts = ({ children }: PropsWithChildren) => (
<AdminClientProvider>
<WhoAmIContextProvider>
<RealmsProvider>
<RealmContextProvider>
<RecentRealmsProvider>
<AccessContextProvider>
<Help>
<AlertProvider>
<SubGroups>{children}</SubGroups>
</AlertProvider>
</Help>
</AccessContextProvider>
</RecentRealmsProvider>
</RealmContextProvider>
</RealmsProvider>
</WhoAmIContextProvider>
</AdminClientProvider>
<WhoAmIContextProvider>
<RealmsProvider>
<RealmContextProvider>
<RecentRealmsProvider>
<AccessContextProvider>
<Help>
<AlertProvider>
<SubGroups>{children}</SubGroups>
</AlertProvider>
</Help>
</AccessContextProvider>
</RecentRealmsProvider>
</RealmContextProvider>
</RealmsProvider>
</WhoAmIContextProvider>
);
export const App = () => {

View file

@ -1,3 +1,5 @@
import type AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation";
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import {
AlertVariant,
Button,
@ -13,10 +15,10 @@ import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import type AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation";
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import {
RoutableTabs,
@ -24,7 +26,7 @@ import {
} from "../components/routable-tabs/RoutableTabs";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import helpUrls from "../help-urls";
import { addTrailingSlash } from "../util";
@ -32,16 +34,15 @@ import { getAuthorizationHeaders } from "../utils/getAuthorizationHeaders";
import useLocaleSort, { mapByKey } from "../utils/useLocaleSort";
import useToggle from "../utils/useToggle";
import { BindFlowDialog } from "./BindFlowDialog";
import { UsedBy } from "./components/UsedBy";
import { DuplicateFlowModal } from "./DuplicateFlowModal";
import { Policies } from "./policies/Policies";
import { RequiredActions } from "./RequiredActions";
import { UsedBy } from "./components/UsedBy";
import { Policies } from "./policies/Policies";
import { AuthenticationTab, toAuthentication } from "./routes/Authentication";
import { toCreateFlow } from "./routes/CreateFlow";
import { toFlow } from "./routes/Flow";
import "./authentication-section.css";
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
type UsedBy = "SPECIFIC_CLIENTS" | "SPECIFIC_PROVIDERS" | "DEFAULT";
@ -83,7 +84,6 @@ const AliasRenderer = ({ id, alias, usedBy, builtIn }: AuthenticationType) => {
export default function AuthenticationSection() {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { realm: realmName } = useRealm();
const [key, setKey] = useState(0);
const refresh = () => {

View file

@ -13,8 +13,8 @@ import {
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useAdminClient } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import useToggle from "../utils/useToggle";
import { REALM_FLOWS } from "./AuthenticationSection";
@ -31,7 +31,6 @@ type BindFlowDialogProps = {
export const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => {
const { t } = useTranslation("authentication");
const { control, handleSubmit } = useForm<BindingForm>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const [open, toggleOpen] = useToggle();

View file

@ -12,8 +12,8 @@ import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useAdminClient } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { NameDescription } from "./form/NameDescription";
import { toFlow } from "./routes/Flow";
@ -34,7 +34,6 @@ export const DuplicateFlowModal = ({
const { t } = useTranslation("authentication");
const form = useForm<AuthenticationFlowRepresentation>({ mode: "onChange" });
const { setValue, getValues, handleSubmit } = form;
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const navigate = useNavigate();
const { realm } = useRealm();

View file

@ -9,10 +9,10 @@ import {
} from "@patternfly/react-core";
import { useEffect } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useAdminClient } from "../context/auth/AdminClient";
import { NameDescription } from "./form/NameDescription";
type EditFlowModalProps = {
@ -22,7 +22,6 @@ type EditFlowModalProps = {
export const EditFlowModal = ({ flow, toggleDialog }: EditFlowModalProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const form = useForm<AuthenticationFlowRepresentation>({ mode: "onChange" });
const { reset, handleSubmit } = form;

View file

@ -1,52 +1,53 @@
import { useState } from "react";
import { useParams, useNavigate } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import type AuthenticationExecutionInfoRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationExecutionInfoRepresentation";
import type AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import {
DataList,
Label,
PageSection,
Toolbar,
ToolbarItem,
ToolbarContent,
ToggleGroup,
ToggleGroupItem,
AlertVariant,
Button,
ButtonVariant,
DataList,
DropdownItem,
Label,
PageSection,
ToggleGroup,
ToggleGroupItem,
Toolbar,
ToolbarContent,
ToolbarItem,
} from "@patternfly/react-core";
import {
CheckCircleIcon,
TableIcon,
DomainIcon,
TableIcon,
} from "@patternfly/react-icons";
import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useNavigate, useParams } from "react-router-dom";
import type AuthenticationExecutionInfoRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationExecutionInfoRepresentation";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import type AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation";
import type { FlowParams } from "./routes/Flow";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import useToggle from "../utils/useToggle";
import { BindFlowDialog } from "./BindFlowDialog";
import { DuplicateFlowModal } from "./DuplicateFlowModal";
import { EditFlowModal } from "./EditFlowModal";
import { EmptyExecutionState } from "./EmptyExecutionState";
import { FlowDiagram } from "./components/FlowDiagram";
import { FlowHeader } from "./components/FlowHeader";
import { FlowRow } from "./components/FlowRow";
import { AddStepModal } from "./components/modals/AddStepModal";
import { AddSubFlowModal, Flow } from "./components/modals/AddSubFlowModal";
import {
ExecutionList,
ExpandableExecution,
IndexChange,
LevelChange,
} from "./execution-model";
import { FlowDiagram } from "./components/FlowDiagram";
import { useAlerts } from "../components/alert/Alerts";
import { AddStepModal } from "./components/modals/AddStepModal";
import { AddSubFlowModal, Flow } from "./components/modals/AddSubFlowModal";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { DuplicateFlowModal } from "./DuplicateFlowModal";
import { useRealm } from "../context/realm-context/RealmContext";
import useToggle from "../utils/useToggle";
import { toAuthentication } from "./routes/Authentication";
import { EditFlowModal } from "./EditFlowModal";
import { BindFlowDialog } from "./BindFlowDialog";
import type { FlowParams } from "./routes/Flow";
export const providerConditionFilter = (
value: AuthenticationProviderRepresentation
@ -54,7 +55,6 @@ export const providerConditionFilter = (
export default function FlowDetails() {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { addAlert, addError } = useAlerts();
const { id, usedBy, builtIn } = useParams<FlowParams>();

View file

@ -1,14 +1,15 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { AlertVariant, Switch } from "@patternfly/react-core";
import type RequiredActionProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderRepresentation";
import type RequiredActionProviderSimpleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/requiredActionProviderSimpleRepresentation";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { DraggableTable } from "./components/DraggableTable";
import { AlertVariant, Switch } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
import { useFetch } from "../context/auth/AdminClient";
import { toKey } from "../util";
import { DraggableTable } from "./components/DraggableTable";
type DataType = RequiredActionProviderRepresentation &
RequiredActionProviderSimpleRepresentation;
@ -22,7 +23,6 @@ type Row = {
export const RequiredActions = () => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [actions, setActions] = useState<Row[]>();

View file

@ -1,5 +1,4 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import {
Dropdown,
DropdownItem,
@ -7,11 +6,13 @@ import {
Tooltip,
} from "@patternfly/react-core";
import { PlusIcon } from "@patternfly/react-icons";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import type { ExpandableExecution } from "../execution-model";
import { AddStepModal, FlowType } from "./modals/AddStepModal";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { AddSubFlowModal, Flow } from "./modals/AddSubFlowModal";
type AddFlowDropdownProps = {
@ -29,7 +30,6 @@ export const AddFlowDropdown = ({
onAddFlow,
}: AddFlowDropdownProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const [open, setOpen] = useState(false);
const [type, setType] = useState<FlowType>();

View file

@ -16,12 +16,13 @@ import { CogIcon, TrashIcon } from "@patternfly/react-icons";
import { useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { convertFormValuesToObject, convertToFormValues } from "../../util";
import type { ExpandableExecution } from "../execution-model";
@ -38,7 +39,6 @@ export const ExecutionConfigModal = ({
execution,
}: ExecutionConfigModalProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [show, setShow] = useState(false);

View file

@ -13,7 +13,6 @@ import { useTranslation } from "react-i18next";
import { fetchUsedBy } from "../../components/role-mapping/resource";
import { KeycloakDataTable } from "../../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../../context/auth/AdminClient";
import useToggle from "../../utils/useToggle";
import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection";
@ -39,7 +38,6 @@ type UsedByModalProps = {
const UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const loader = async (
first?: number,
@ -47,7 +45,6 @@ const UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {
search?: string
): Promise<{ name: string }[]> => {
const result = await fetchUsedBy({
adminClient,
id,
type: isSpecificClient ? "clients" : "idp",
first: first || 0,

View file

@ -1,5 +1,4 @@
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import {
Button,
ButtonVariant,
@ -9,10 +8,12 @@ import {
PageSection,
Radio,
} from "@patternfly/react-core";
import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../../admin-client";
import { PaginatingTableToolbar } from "../../../components/table-toolbar/PaginatingTableToolbar";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { useFetch } from "../../../context/auth/AdminClient";
import useLocaleSort, { mapByKey } from "../../../utils/useLocaleSort";
import { providerConditionFilter } from "../../FlowDetails";
@ -56,7 +57,6 @@ type AddStepModalProps = {
export const AddStepModal = ({ name, type, onSelect }: AddStepModalProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const [value, setValue] = useState<AuthenticationProviderRepresentation>();
const [providers, setProviders] =

View file

@ -14,10 +14,11 @@ import {
import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../../admin-client";
import { KeycloakTextInput } from "../../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { useFetch } from "../../../context/auth/AdminClient";
type AddSubFlowProps = {
name: string;
@ -51,7 +52,6 @@ export const AddSubFlowModal = ({
const [openProvider, setOpenProvider] = useState(false);
const [formProviders, setFormProviders] =
useState<AuthenticationProviderRepresentation[]>();
const { adminClient } = useAdminClient();
useFetch(
() => adminClient.authenticationManagement.getFormProviders(),

View file

@ -9,10 +9,10 @@ import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toAuthentication } from "../routes/Authentication";
import { toFlow } from "../routes/Flow";
@ -23,7 +23,6 @@ export default function CreateFlow() {
const { t } = useTranslation("authentication");
const navigate = useNavigate();
const { realm } = useRealm();
const { adminClient } = useAdminClient();
const { addAlert } = useAlerts();
const form = useForm<AuthenticationFlowRepresentation>();
const { handleSubmit } = form;

View file

@ -15,12 +15,12 @@ import {
import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { convertFormValuesToObject, convertToFormValues } from "../../util";
@ -49,7 +49,6 @@ export const CibaPolicy = ({ realm, realmUpdated }: CibaPolicyProps) => {
setValue,
formState: { errors, isValid, isDirty },
} = useForm<FormFields>({ mode: "onChange" });
const { adminClient } = useAdminClient();
const { realm: realmName } = useRealm();
const { addAlert, addError } = useAlerts();
const [

View file

@ -19,12 +19,12 @@ import {
import { useEffect, useMemo } from "react";
import { Controller, useForm, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import useLocaleSort from "../../utils/useLocaleSort";
import useToggle from "../../utils/useToggle";
@ -53,7 +53,6 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
handleSubmit,
formState: { isValid, isDirty, errors },
} = useForm<FormFields>({ mode: "onChange", defaultValues: realm });
const { adminClient } = useAdminClient();
const { realm: realmName } = useRealm();
const { addAlert, addError } = useAlerts();
const localeSort = useLocaleSort();

View file

@ -1,3 +1,5 @@
import type PasswordPolicyTypeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/passwordPolicyTypeRepresentation";
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import {
ActionGroup,
AlertVariant,
@ -21,15 +23,13 @@ import { useEffect, useMemo, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import type PasswordPolicyTypeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/passwordPolicyTypeRepresentation";
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { PolicyRow } from "./PolicyRow";
import { parsePolicy, serializePolicy, SubmittedValues } from "./util";
import { SubmittedValues, parsePolicy, serializePolicy } from "./util";
type PolicySelectProps = {
onSelect: (row: PasswordPolicyTypeRepresentation) => void;
@ -82,7 +82,6 @@ export const PasswordPolicy = ({
const { t } = useTranslation("authentication");
const { passwordPolicies } = useServerInfo();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm: realmName } = useRealm();

View file

@ -3,8 +3,9 @@ import { Tab, Tabs, TabTitleText } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { CibaPolicy } from "./CibaPolicy";
import { OtpPolicy } from "./OtpPolicy";
@ -14,7 +15,6 @@ import { WebauthnPolicy } from "./WebauthnPolicy";
export const Policies = () => {
const { t } = useTranslation("authentication");
const [subTab, setSubTab] = useState(1);
const { adminClient } = useAdminClient();
const { realm: realmName } = useRealm();
const [realm, setRealm] = useState<RealmRepresentation>();

View file

@ -1,3 +1,4 @@
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import {
ActionGroup,
AlertVariant,
@ -22,15 +23,14 @@ import {
useFormContext,
} from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem, useHelp } from "ui-shared";
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { useHelp, HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { MultiLineInput } from "../../components/multi-line-input/MultiLineInput";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { convertFormValuesToObject, convertToFormValues } from "../../util";
@ -158,7 +158,6 @@ export const WebauthnPolicy = ({
isPasswordLess = false,
}: WebauthnPolicyProps) => {
const { t } = useTranslation("authentication");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm: realmName } = useRealm();
const { enabled } = useHelp();

View file

@ -1,17 +1,16 @@
import { AlertVariant, Select } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { AlertVariant, Select } from "@patternfly/react-core";
import type { Row } from "../clients/scopes/ClientScopes";
import { useAlerts } from "../components/alert/Alerts";
import {
ClientScope,
allClientScopeTypes,
changeClientScope,
changeScope,
ClientScope,
clientScopeTypesSelectOptions,
} from "../components/client-scope/ClientScopeTypes";
import type { Row } from "../clients/scopes/ClientScopes";
import { useAdminClient } from "../context/auth/AdminClient";
import { useAlerts } from "../components/alert/Alerts";
type ChangeTypeDropdownProps = {
clientId?: string;
@ -27,7 +26,6 @@ export const ChangeTypeDropdown = ({
const { t } = useTranslation("client-scopes");
const [open, setOpen] = useState(false);
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
return (
@ -45,13 +43,12 @@ export const ChangeTypeDropdown = ({
selectedRows.map((row) => {
return clientId
? changeClientScope(
adminClient,
clientId,
row,
row.type,
value as ClientScope
)
: changeScope(adminClient, row, value as ClientScope);
: changeScope(row, value as ClientScope);
})
);
setOpen(false);

View file

@ -1,6 +1,3 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import {
AlertVariant,
Button,
@ -12,43 +9,45 @@ import {
ToolbarItem,
} from "@patternfly/react-core";
import { cellWidth } from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { useAdminClient } from "../context/auth/AdminClient";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { adminClient } from "../admin-client";
import type { Row } from "../clients/scopes/ClientScopes";
import { getProtocolName } from "../clients/utils";
import { useAlerts } from "../components/alert/Alerts";
import {
AllClientScopeType,
AllClientScopes,
CellDropdown,
ClientScope,
ClientScopeDefaultOptionalType,
changeScope,
removeScope,
} from "../components/client-scope/ClientScopeTypes";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import {
Action,
KeycloakDataTable,
} from "../components/table-toolbar/KeycloakDataTable";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useRealm } from "../context/realm-context/RealmContext";
import helpUrls from "../help-urls";
import { emptyFormatter } from "../util";
import useLocaleSort, { mapByKey } from "../utils/useLocaleSort";
import {
CellDropdown,
ClientScope,
AllClientScopes,
ClientScopeDefaultOptionalType,
changeScope,
removeScope,
AllClientScopeType,
} from "../components/client-scope/ClientScopeTypes";
import { ChangeTypeDropdown } from "./ChangeTypeDropdown";
import { toNewClientScope } from "./routes/NewClientScope";
import { toClientScope } from "./routes/ClientScope";
import {
nameFilter,
protocolFilter,
ProtocolType,
SearchDropdown,
SearchToolbar,
SearchType,
nameFilter,
protocolFilter,
typeFilter,
} from "./details/SearchFilter";
import type { Row } from "../clients/scopes/ClientScopes";
import { getProtocolName } from "../clients/utils";
import helpUrls from "../help-urls";
import { toClientScope } from "./routes/ClientScope";
import { toNewClientScope } from "./routes/NewClientScope";
import "./client-scope.css";
@ -58,8 +57,8 @@ type TypeSelectorProps = ClientScopeDefaultOptionalType & {
const TypeSelector = (scope: TypeSelectorProps) => {
const { t } = useTranslation("client-scopes");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
return (
<CellDropdown
clientScope={scope}
@ -67,7 +66,7 @@ const TypeSelector = (scope: TypeSelectorProps) => {
all
onSelect={async (value) => {
try {
await changeScope(adminClient, scope, value as AllClientScopeType);
await changeScope(scope, value as AllClientScopeType);
addAlert(t("clientScopeSuccess"), AlertVariant.success);
scope.refresh();
} catch (error) {
@ -93,8 +92,6 @@ const ClientScopeDetailLink = ({
export default function ClientScopesSection() {
const { realm } = useRealm();
const { t } = useTranslation("client-scopes");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [kebabOpen, setKebabOpen] = useState(false);
@ -165,7 +162,7 @@ export default function ClientScopesSection() {
try {
for (const scope of selectedScopes) {
try {
await removeScope(adminClient, scope);
await removeScope(scope);
} catch (error: any) {
console.warn(
"could not remove scope",

View file

@ -2,13 +2,13 @@ import { AlertVariant, PageSection } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import {
changeScope,
ClientScopeDefaultOptionalType,
changeScope,
} from "../components/client-scope/ClientScopeTypes";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { convertFormValuesToObject } from "../util";
import { ScopeForm } from "./details/ScopeForm";
@ -18,7 +18,6 @@ export default function CreateClientScope() {
const { t } = useTranslation("client-scopes");
const navigate = useNavigate();
const { realm } = useRealm();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const onSubmit = async (formData: ClientScopeDefaultOptionalType) => {
@ -38,11 +37,7 @@ export default function CreateClientScope() {
throw new Error(t("common:notFound"));
}
await changeScope(
adminClient,
{ ...clientScope, id: scope.id },
clientScope.type
);
await changeScope({ ...clientScope, id: scope.id }, clientScope.type);
addAlert(t("createSuccess", AlertVariant.success));

View file

@ -14,16 +14,17 @@ import {
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { useAlerts } from "../components/alert/Alerts";
import { useHelp } from "ui-shared";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import {
AllClientScopes,
changeScope,
ClientScope,
ClientScopeDefaultOptionalType,
changeScope,
} from "../components/client-scope/ClientScopeTypes";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { useHelp } from "ui-shared";
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
import { RoleMapping, Row } from "../components/role-mapping/RoleMapping";
import {
@ -31,7 +32,7 @@ import {
useRoutableTab,
} from "../components/routable-tabs/RoutableTabs";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { convertFormValuesToObject } from "../util";
import { useParams } from "../utils/useParams";
@ -48,7 +49,6 @@ export default function EditClientScope() {
const { t } = useTranslation("client-scopes");
const navigate = useNavigate();
const { realm } = useRealm();
const { adminClient } = useAdminClient();
const { id } = useParams<ClientScopeParams>();
const { addAlert, addError } = useAlerts();
const { enabled } = useHelp();
@ -117,7 +117,7 @@ export default function EditClientScope() {
try {
await adminClient.clientScopes.update({ id }, clientScope);
await changeScope(adminClient, { ...clientScope, id }, clientScope.type);
await changeScope({ ...clientScope, id }, clientScope.type);
addAlert(t("updateSuccess"), AlertVariant.success);
} catch (error) {

View file

@ -14,16 +14,17 @@ import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useMatch, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { toClient } from "../../clients/routes/Client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { convertFormValuesToObject, convertToFormValues } from "../../util";
@ -35,7 +36,6 @@ import "./mapping-details.css";
export default function MappingDetails() {
const { t } = useTranslation("client-scopes");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { id, mapperId } = useParams<MapperParams>();

View file

@ -17,6 +17,7 @@ import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import {
ConfirmDialogModal,
@ -36,7 +37,7 @@ import {
ViewHeaderBadge,
} from "../components/view-header/ViewHeader";
import { useAccess } from "../context/access/Access";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import {
convertAttributeNameToForm,
@ -188,7 +189,6 @@ export type FormFields = Omit<
export default function ClientDetails() {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const { hasAccess } = useAccess();

View file

@ -2,9 +2,8 @@ import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/
import type UserSessionRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userSessionRepresentation";
import { PageSection } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import type { LoaderFunction } from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient";
import SessionsTable from "../sessions/SessionsTable";
type ClientSessionsProps = {
@ -12,7 +11,6 @@ type ClientSessionsProps = {
};
export const ClientSessions = ({ client }: ClientSessionsProps) => {
const { adminClient } = useAdminClient();
const { t } = useTranslation("sessions");
const loader: LoaderFunction<UserSessionRepresentation> = async (

View file

@ -1,3 +1,5 @@
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import {
AlertVariant,
Badge,
@ -8,37 +10,36 @@ import {
TabTitleText,
ToolbarItem,
} from "@patternfly/react-core";
import { cellWidth, IRowData, TableText } from "@patternfly/react-table";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import { IRowData, TableText, cellWidth } from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { FormattedLink } from "../components/external-link/FormattedLink";
import {
RoutableTabs,
useRoutableTab,
} from "../components/routable-tabs/RoutableTabs";
import {
Action,
KeycloakDataTable,
} from "../components/table-toolbar/KeycloakDataTable";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient } from "../context/auth/AdminClient";
import { useAccess } from "../context/access/Access";
import { useRealm } from "../context/realm-context/RealmContext";
import helpUrls from "../help-urls";
import { emptyFormatter, exportClient } from "../util";
import { convertClientToUrl } from "../utils/client-url";
import { InitialAccessTokenList } from "./initial-access/InitialAccessTokenList";
import { ClientRegistration } from "./registration/ClientRegistration";
import { toAddClient } from "./routes/AddClient";
import { toClient } from "./routes/Client";
import { toImportClient } from "./routes/ImportClient";
import { isRealmClient, getProtocolName } from "./utils";
import helpUrls from "../help-urls";
import { useAccess } from "../context/access/Access";
import {
RoutableTabs,
useRoutableTab,
} from "../components/routable-tabs/RoutableTabs";
import { ClientsTab, toClients } from "./routes/Clients";
import { ClientRegistration } from "./registration/ClientRegistration";
import { toImportClient } from "./routes/ImportClient";
import { getProtocolName, isRealmClient } from "./utils";
const ClientDetailLink = (client: ClientRepresentation) => {
const { t } = useTranslation("clients");
@ -71,7 +72,6 @@ const ClientDescription = (client: ClientRepresentation) => (
);
const ClientHomeLink = (client: ClientRepresentation) => {
const { adminClient } = useAdminClient();
const href = convertClientToUrl(client, adminClient.baseUrl);
if (!href) {
@ -117,8 +117,6 @@ const ToolbarItems = () => {
export default function ClientsSection() {
const { t } = useTranslation("clients");
const { addAlert, addError } = useAlerts();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const [key, setKey] = useState(0);

View file

@ -11,10 +11,10 @@ import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { convertFormValuesToObject } from "../../util";
import { FormFields } from "../ClientDetails";
@ -27,7 +27,6 @@ import { LoginSettings } from "./LoginSettings";
export default function NewClientForm() {
const { t } = useTranslation("clients");
const { realm } = useRealm();
const { adminClient } = useAdminClient();
const navigate = useNavigate();
const [step, setStep] = useState(0);

View file

@ -9,9 +9,9 @@ import {
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient } from "../../context/auth/AdminClient";
type FormFields = {
node: string;
@ -36,7 +36,6 @@ export const AddHostDialog = ({
handleSubmit,
formState: { isDirty, isValid },
} = useForm<FormFields>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
async function onSubmit({ node }: FormFields) {

View file

@ -11,13 +11,14 @@ import {
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { FormAccess } from "../../components/form-access/FormAccess";
import { KeyValueInput } from "../../components/key-value-form/KeyValueInput";
import { MultiLineInput } from "../../components/multi-line-input/MultiLineInput";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { convertAttributeNameToForm } from "../../util";
import { FormFields } from "../ClientDetails";
@ -41,7 +42,6 @@ export const AdvancedSettings = ({
const [realm, setRealm] = useState<RealmRepresentation>();
const { realm: realmName } = useRealm();
const { adminClient } = useAdminClient();
useFetch(
() => adminClient.realms.findOne({ realm: realmName }),

View file

@ -10,10 +10,11 @@ import { sortBy } from "lodash-es";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { FormAccess } from "../../components/form-access/FormAccess";
import { useFetch } from "../../context/auth/AdminClient";
type AuthenticationOverridesProps = {
save: () => void;
@ -28,7 +29,6 @@ export const AuthenticationOverrides = ({
reset,
hasConfigureAccess,
}: AuthenticationOverridesProps) => {
const { adminClient } = useAdminClient();
const { t } = useTranslation("clients");
const [flows, setFlows] = useState<JSX.Element[]>([]);
const [browserFlowOpen, setBrowserFlowOpen] = useState(false);

View file

@ -11,18 +11,18 @@ import {
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import {
Action,
KeycloakDataTable,
} from "../../components/table-toolbar/KeycloakDataTable";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useAdminClient } from "../../context/auth/AdminClient";
import useFormatDate, { FORMAT_DATE_AND_TIME } from "../../utils/useFormatDate";
import { AddHostDialog } from ".././advanced/AddHostDialog";
import { AdvancedProps, parseResult } from "../AdvancedTab";
@ -38,7 +38,6 @@ export const ClusteringPanel = ({
}: AdvancedProps) => {
const { t } = useTranslation("clients");
const { control } = useFormContext();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const formatDate = useFormatDate();

View file

@ -10,12 +10,12 @@ import { useEffect, useRef } from "react";
import { useFormContext } from "react-hook-form";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import useFormatDate, { FORMAT_DATE_AND_TIME } from "../../utils/useFormatDate";
import { AdvancedProps, parseResult } from "../AdvancedTab";
@ -29,7 +29,6 @@ export const RevocationPanel = ({
const pushRevocationButtonRef = useRef<HTMLElement>();
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { addAlert } = useAlerts();
const formatDate = useFormatDate();

View file

@ -1,3 +1,10 @@
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type EvaluationResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/evaluationResultRepresentation";
import type PolicyEvaluationResponse from "@keycloak/keycloak-admin-client/lib/defs/policyEvaluationResponse";
import type ResourceEvaluation from "@keycloak/keycloak-admin-client/lib/defs/resourceEvaluation";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import {
ActionGroup,
Button,
@ -12,34 +19,27 @@ import {
import { useState } from "react";
import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type EvaluationResultRepresentation from "@keycloak/keycloak-admin-client/lib/defs/evaluationResultRepresentation";
import type PolicyEvaluationResponse from "@keycloak/keycloak-admin-client/lib/defs/policyEvaluationResponse";
import type ResourceEvaluation from "@keycloak/keycloak-admin-client/lib/defs/resourceEvaluation";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import { ForbiddenSection } from "../../ForbiddenSection";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { ClientSelect } from "../../components/client/ClientSelect";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import {
keyValueToArray,
KeyValueType,
keyValueToArray,
} from "../../components/key-value-form/key-value-convert";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { FormPanel } from "../../components/scroll-form/FormPanel";
import { UserSelect } from "../../components/users/UserSelect";
import { useAccess } from "../../context/access/Access";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { ForbiddenSection } from "../../ForbiddenSection";
import { FormFields } from "../ClientDetails";
import { defaultContextAttributes } from "../utils";
import { Results } from "./evaluate/Results";
import { KeyBasedAttributeInput } from "./KeyBasedAttributeInput";
import { useAlerts } from "../../components/alert/Alerts";
import { Results } from "./evaluate/Results";
import "./auth-evaluate.css";
@ -91,7 +91,6 @@ export const AuthorizationEvaluate = ({ client }: Props) => {
formState: { isValid, errors },
} = form;
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addError } = useAlerts();
const realm = useRealm();

View file

@ -9,13 +9,14 @@ import {
import { saveAs } from "file-saver";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { KeycloakTextArea } from "../../components/keycloak-text-area/KeycloakTextArea";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { prettyPrintJSON } from "../../util";
import { useParams } from "../../utils/useParams";
import type { ClientParams } from "../routes/Client";
@ -24,7 +25,6 @@ import "./authorization-details.css";
export const AuthorizationExport = () => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { clientId } = useParams<ClientParams>();
const { addAlert, addError } = useAlerts();

View file

@ -1,11 +1,11 @@
import { useTranslation } from "react-i18next";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import { Alert, AlertVariant } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import type { PermissionScopeRepresentation } from "./Scopes";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import type { PermissionScopeRepresentation } from "./Scopes";
type DeleteScopeDialogProps = {
clientId: string;
@ -26,7 +26,6 @@ export const DeleteScopeDialog = ({
toggleDialog,
}: DeleteScopeDialogProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
return (

View file

@ -1,13 +1,14 @@
import { useState } from "react";
import { DescriptionList } from "@patternfly/react-core";
import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation";
import { DescriptionList } from "@patternfly/react-core";
import { useState } from "react";
import { adminClient } from "../../admin-client";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { DetailDescription, DetailDescriptionLink } from "./DetailDescription";
import { toScopeDetails } from "../routes/Scope";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toPermissionDetails } from "../routes/PermissionDetails";
import { toScopeDetails } from "../routes/Scope";
import { DetailDescription, DetailDescriptionLink } from "./DetailDescription";
import "./detail-cell.css";
@ -20,7 +21,6 @@ type DetailCellProps = {
};
export const DetailCell = ({ id, clientId, uris }: DetailCellProps) => {
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const [scope, setScope] = useState<Scope>();
const [permissions, setPermissions] =

View file

@ -16,16 +16,17 @@ import { useState } from "react";
import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { KeycloakTextArea } from "../../components/keycloak-text-area/KeycloakTextArea";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { toUpperCase } from "../../util";
import { useParams } from "../../utils/useParams";
import { toAuthorizationTab } from "../routes/AuthenticationTab";
@ -60,7 +61,6 @@ export default function PermissionDetails() {
NewPermissionParams & PermissionDetailsParams
>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [permission, setPermission] = useState<PolicyRepresentation>();
const [applyToResourceTypeFlag, setApplyToResourceTypeFlag] = useState(false);

View file

@ -1,6 +1,5 @@
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import {
Alert,
AlertVariant,
@ -22,24 +21,26 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import useToggle from "../../utils/useToggle";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { SearchDropdown, SearchForm } from "./SearchDropdown";
import { MoreLabel } from "./MoreLabel";
import { DetailDescriptionLink } from "./DetailDescription";
import { EmptyPermissionsState } from "./EmptyPermissionsState";
import useToggle from "../../utils/useToggle";
import { toNewPermission } from "../routes/NewPermission";
import { toPermissionDetails } from "../routes/PermissionDetails";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { toPolicyDetails } from "../routes/PolicyDetails";
import { DetailDescriptionLink } from "./DetailDescription";
import { EmptyPermissionsState } from "./EmptyPermissionsState";
import { MoreLabel } from "./MoreLabel";
import { SearchDropdown, SearchForm } from "./SearchDropdown";
import "./permissions.css";
@ -68,7 +69,6 @@ const AssociatedPoliciesRenderer = ({
export const AuthorizationPermissions = ({ clientId }: PermissionsProps) => {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();

View file

@ -1,6 +1,5 @@
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import {
Alert,
AlertVariant,
@ -18,25 +17,27 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import type PolicyProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyProviderRepresentation";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toPolicyDetails } from "../routes/PolicyDetails";
import { MoreLabel } from "./MoreLabel";
import { toUpperCase } from "../../util";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toUpperCase } from "../../util";
import useToggle from "../../utils/useToggle";
import { NewPolicyDialog } from "./NewPolicyDialog";
import { toCreatePolicy } from "../routes/NewPolicy";
import { toPermissionDetails } from "../routes/PermissionDetails";
import { SearchDropdown, SearchForm } from "./SearchDropdown";
import { toPolicyDetails } from "../routes/PolicyDetails";
import { DetailDescriptionLink } from "./DetailDescription";
import { MoreLabel } from "./MoreLabel";
import { NewPolicyDialog } from "./NewPolicyDialog";
import { SearchDropdown, SearchForm } from "./SearchDropdown";
type PoliciesProps = {
clientId: string;
@ -62,7 +63,6 @@ const DependentPoliciesRenderer = ({
export const AuthorizationPolicies = ({ clientId }: PoliciesProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const navigate = useNavigate();

View file

@ -17,18 +17,19 @@ import { useState } from "react";
import { Controller, FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import type { KeyValueType } from "../../components/key-value-form/key-value-convert";
import { KeyValueInput } from "../../components/key-value-form/KeyValueInput";
import type { KeyValueType } from "../../components/key-value-form/key-value-convert";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { MultiLineInput } from "../../components/multi-line-input/MultiLineInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { convertFormValuesToObject, convertToFormValues } from "../../util";
import { useParams } from "../../utils/useParams";
import { toAuthorizationTab } from "../routes/AuthenticationTab";
@ -52,7 +53,6 @@ export default function ResourceDetails() {
const [permissions, setPermission] =
useState<ResourceServerRepresentation[]>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const form = useForm<SubmittedResource>({
mode: "onChange",

View file

@ -1,6 +1,5 @@
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation";
import {
Alert,
AlertVariant,
@ -17,21 +16,23 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { DetailCell } from "./DetailCell";
import { toCreateResource } from "../routes/NewResource";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toResourceDetails } from "../routes/Resource";
import { MoreLabel } from "./MoreLabel";
import { toNewPermission } from "../routes/NewPermission";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toNewPermission } from "../routes/NewPermission";
import { toCreateResource } from "../routes/NewResource";
import { toResourceDetails } from "../routes/Resource";
import { DetailCell } from "./DetailCell";
import { MoreLabel } from "./MoreLabel";
import { SearchDropdown, SearchForm } from "./SearchDropdown";
type ResourcesProps = {
@ -51,7 +52,6 @@ const UriRenderer = ({ row }: { row: ResourceRepresentation }) => (
export const AuthorizationResources = ({ clientId }: ResourcesProps) => {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();

View file

@ -1,15 +1,16 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useFormContext } from "react-hook-form";
import { Select, SelectOption, SelectVariant } from "@patternfly/react-core";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type {
Clients,
PolicyQuery,
} from "@keycloak/keycloak-admin-client/lib/resources/clients";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { Select, SelectOption, SelectVariant } from "@patternfly/react-core";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
type Type = "resources" | "policies";
@ -57,7 +58,6 @@ export const ResourcesPolicySelect = ({
isRequired = false,
}: ResourcesPolicySelectProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const {
control,

View file

@ -13,13 +13,14 @@ import { useState } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useParams } from "../../utils/useParams";
import useToggle from "../../utils/useToggle";
import { toAuthorizationTab } from "../routes/AuthenticationTab";
@ -33,7 +34,6 @@ export default function ScopeDetails() {
const { id, scopeId, realm } = useParams<ScopeDetailsParams>();
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [deleteDialog, toggleDeleteDialog] = useToggle();

View file

@ -1,17 +1,18 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useFormContext } from "react-hook-form";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import {
FormGroup,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
type Scope = {
id: string;
name: string;
@ -25,8 +26,6 @@ export const ScopePicker = ({ clientId }: { clientId: string }) => {
const [scopes, setScopes] = useState<ScopeRepresentation[]>();
const [search, setSearch] = useState("");
const { adminClient } = useAdminClient();
useFetch(
() => {
const params = {

View file

@ -1,10 +1,11 @@
import { useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useFormContext } from "react-hook-form";
import { Select, SelectOption, SelectVariant } from "@patternfly/react-core";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { Select, SelectOption, SelectVariant } from "@patternfly/react-core";
import { useRef, useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
type ScopeSelectProps = {
clientId: string;
@ -18,7 +19,6 @@ export const ScopeSelect = ({
preSelected,
}: ScopeSelectProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const {
control,

View file

@ -1,6 +1,5 @@
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import {
Button,
DescriptionList,
@ -16,23 +15,24 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import { adminClient } from "../../admin-client";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toScopeDetails } from "../routes/Scope";
import { toNewScope } from "../routes/NewScope";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import useToggle from "../../utils/useToggle";
import { toNewPermission } from "../routes/NewPermission";
import { toNewScope } from "../routes/NewScope";
import { toPermissionDetails } from "../routes/PermissionDetails";
import { toResourceDetails } from "../routes/Resource";
import { toScopeDetails } from "../routes/Scope";
import { DeleteScopeDialog } from "./DeleteScopeDialog";
import { DetailDescriptionLink } from "./DetailDescription";
import { toNewPermission } from "../routes/NewPermission";
import { toResourceDetails } from "../routes/Resource";
import { toPermissionDetails } from "../routes/PermissionDetails";
type ScopesProps = {
clientId: string;
@ -51,7 +51,6 @@ type ExpandableRow = {
export const AuthorizationScopes = ({ clientId }: ScopesProps) => {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const [deleteDialog, toggleDeleteDialog] = useToggle();

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, FormProvider, useForm } from "react-hook-form";
import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation";
import {
AlertVariant,
Button,
@ -10,17 +8,20 @@ import {
Radio,
Switch,
} from "@patternfly/react-core";
import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { FormAccess } from "../../components/form-access/FormAccess";
import { useState } from "react";
import { Controller, FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { SaveReset } from "../advanced/SaveReset";
import { ImportDialog } from "./ImportDialog";
import useToggle from "../../utils/useToggle";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { useFetch } from "../../context/auth/AdminClient";
import useToggle from "../../utils/useToggle";
import { SaveReset } from "../advanced/SaveReset";
import { DecisionStrategySelect } from "./DecisionStrategySelect";
import { ImportDialog } from "./ImportDialog";
const POLICY_ENFORCEMENT_MODES = [
"ENFORCING",
@ -41,7 +42,6 @@ export const AuthorizationSettings = ({ clientId }: { clientId: string }) => {
const form = useForm<FormFields>({});
const { control, reset, handleSubmit } = form;
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
useFetch(

View file

@ -1,17 +1,18 @@
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import {
SelectOption,
FormGroup,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../../admin-client";
import { useFetch } from "../../../context/auth/AdminClient";
export const Client = () => {
const { t } = useTranslation("clients");
@ -26,8 +27,6 @@ export const Client = () => {
const [clients, setClients] = useState<ClientRepresentation[]>([]);
const [search, setSearch] = useState("");
const { adminClient } = useAdminClient();
useFetch(
async () => {
const params: ClientQuery = {

View file

@ -1,7 +1,5 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useFormContext, Controller } from "react-hook-form";
import { FormGroup, Button, Checkbox } from "@patternfly/react-core";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import { Button, Checkbox, FormGroup } from "@patternfly/react-core";
import { MinusCircleIcon } from "@patternfly/react-icons";
import {
TableComposable,
@ -11,12 +9,15 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { AddScopeDialog } from "../../scopes/AddScopeDialog";
import { adminClient } from "../../../admin-client";
import { useFetch } from "../../../context/auth/AdminClient";
import useLocaleSort, { mapByKey } from "../../../utils/useLocaleSort";
import { AddScopeDialog } from "../../scopes/AddScopeDialog";
export type RequiredIdValue = {
id: string;
@ -40,7 +41,6 @@ export const ClientScope = () => {
ClientScopeRepresentation[]
>([]);
const { adminClient } = useAdminClient();
const localeSort = useLocaleSort();
useFetch(

View file

@ -1,22 +1,23 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useFormContext, Controller } from "react-hook-form";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { Button, Checkbox, FormGroup } from "@patternfly/react-core";
import { MinusCircleIcon } from "@patternfly/react-icons";
import { FormGroup, Button, Checkbox } from "@patternfly/react-core";
import {
TableComposable,
Thead,
Tr,
Th,
Tbody,
Td,
Th,
Thead,
Tr,
} from "@patternfly/react-table";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { adminClient } from "../../../admin-client";
import { GroupPickerDialog } from "../../../components/group/GroupPickerDialog";
import { KeycloakTextInput } from "../../../components/keycloak-text-input/KeycloakTextInput";
import { useFetch } from "../../../context/auth/AdminClient";
type GroupForm = {
groups?: GroupValue[];
@ -44,8 +45,6 @@ export const Group = () => {
[]
);
const { adminClient } = useAdminClient();
useFetch(
() => {
if (values && values.length > 0)

View file

@ -12,12 +12,13 @@ import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { adminClient } from "../../../admin-client";
import { useAlerts } from "../../../components/alert/Alerts";
import { useConfirmDialog } from "../../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../../components/form-access/FormAccess";
import { KeycloakSpinner } from "../../../components/keycloak-spinner/KeycloakSpinner";
import { ViewHeader } from "../../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { useFetch } from "../../../context/auth/AdminClient";
import { useParams } from "../../../utils/useParams";
import { toAuthorizationTab } from "../../routes/AuthenticationTab";
import {
@ -67,7 +68,6 @@ export default function PolicyDetails() {
const form = useForm();
const { reset, handleSubmit } = form;
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [policy, setPolicy] = useState<PolicyRepresentation>();

View file

@ -1,22 +1,23 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useFormContext, Controller } from "react-hook-form";
import { FormGroup, Button, Checkbox } from "@patternfly/react-core";
import { Button, Checkbox, FormGroup } from "@patternfly/react-core";
import { MinusCircleIcon } from "@patternfly/react-icons";
import {
TableComposable,
Thead,
Tr,
Th,
Tbody,
Td,
Th,
Thead,
Tr,
} from "@patternfly/react-table";
import { Row, ServiceRole } from "../../../components/role-mapping/RoleMapping";
import type { RequiredIdValue } from "./ClientScope";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../../context/auth/AdminClient";
import { adminClient } from "../../../admin-client";
import { AddRoleMappingModal } from "../../../components/role-mapping/AddRoleMappingModal";
import { Row, ServiceRole } from "../../../components/role-mapping/RoleMapping";
import { useFetch } from "../../../context/auth/AdminClient";
import type { RequiredIdValue } from "./ClientScope";
export const Role = () => {
const { t } = useTranslation("clients");
@ -33,8 +34,6 @@ export const Role = () => {
const [open, setOpen] = useState(false);
const [selectedRoles, setSelectedRoles] = useState<Row[]>([]);
const { adminClient } = useAdminClient();
useFetch(
async () => {
if (values && values.length > 0) {

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useFormContext } from "react-hook-form";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import {
Alert,
Button,
@ -9,15 +7,17 @@ import {
Split,
SplitItem,
} from "@patternfly/react-core";
import { useState } from "react";
import { useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { PasswordInput } from "../../components/password-input/PasswordInput";
import { CopyToClipboardButton } from "../scopes/CopyToClipboardButton";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import useFormatDate from "../../utils/useFormatDate";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { PasswordInput } from "../../components/password-input/PasswordInput";
import { useAccess } from "../../context/access/Access";
import useFormatDate from "../../utils/useFormatDate";
import { CopyToClipboardButton } from "../scopes/CopyToClipboardButton";
export type ClientSecretProps = {
client: ClientRepresentation;
@ -86,7 +86,6 @@ const ExpireDateFormatter = ({ time }: { time: number }) => {
export const ClientSecret = ({ client, secret, toggle }: ClientSecretProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [secretRotated, setSecretRotated] = useState<string | undefined>(

View file

@ -21,18 +21,18 @@ import {
import { useState } from "react";
import { Controller, useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { FormFields } from "../ClientDetails";
import { ClientSecret } from "./ClientSecret";
import { SignedJWT } from "./SignedJWT";
import { X509 } from "./X509";
import "./credentials.css";
import { FormFields } from "../ClientDetails";
type AccessToken = {
registrationAccessToken: string;
@ -46,7 +46,6 @@ export type CredentialsProps = {
export const Credentials = ({ client, save, refresh }: CredentialsProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const clientId = client.id!;

View file

@ -1,3 +1,4 @@
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { Language } from "@patternfly/react-code-editor";
import {
ActionGroup,
@ -11,14 +12,12 @@ import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { FileUploadForm } from "../../components/json-file-upload/FileUploadForm";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import {
addTrailingSlash,
@ -26,9 +25,9 @@ import {
convertToFormValues,
} from "../../util";
import { getAuthorizationHeaders } from "../../utils/getAuthorizationHeaders";
import { CapabilityConfig } from "../add/CapabilityConfig";
import { ClientDescription } from "../ClientDescription";
import { FormFields } from "../ClientDetails";
import { CapabilityConfig } from "../add/CapabilityConfig";
import { toClient } from "../routes/Client";
import { toClients } from "../routes/Clients";
@ -37,7 +36,6 @@ const isXml = (text: string) => text.match(/(<.[^(><.)]+>)/g);
export default function ImportForm() {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const form = useForm<FormFields>();
const { register, handleSubmit, setValue } = form;

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useForm } from "react-hook-form";
import type ClientInitialAccessPresentation from "@keycloak/keycloak-admin-client/lib/defs/clientInitialAccessPresentation";
import {
ActionGroup,
AlertVariant,
@ -9,18 +7,20 @@ import {
NumberInput,
PageSection,
} from "@patternfly/react-core";
import type ClientInitialAccessPresentation from "@keycloak/keycloak-admin-client/lib/defs/clientInitialAccessPresentation";
import { FormAccess } from "../../components/form-access/FormAccess";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { HelpItem } from "ui-shared";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useAdminClient } from "../../context/auth/AdminClient";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { AccessTokenDialog } from "./AccessTokenDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { TimeSelector } from "../../components/time-selector/TimeSelector";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toClients } from "../routes/Clients";
import { AccessTokenDialog } from "./AccessTokenDialog";
export default function CreateInitialAccessToken() {
const { t } = useTranslation("clients");
@ -30,7 +30,6 @@ export default function CreateInitialAccessToken() {
formState: { isValid, errors },
} = useForm({ mode: "onChange" });
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { addAlert, addError } = useAlerts();

View file

@ -1,9 +1,11 @@
import type ClientInitialAccessPresentation from "@keycloak/keycloak-admin-client/lib/defs/clientInitialAccessPresentation";
import { AlertVariant, Button, ButtonVariant } from "@patternfly/react-core";
import { wrappable } from "@patternfly/react-table";
import type ClientInitialAccessPresentation from "@keycloak/keycloak-admin-client/lib/defs/clientInitialAccessPresentation";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
@ -11,15 +13,13 @@ import {
Action,
KeycloakDataTable,
} from "../../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toCreateInitialAccessToken } from "../routes/CreateInitialAccessToken";
import useFormatDate, { FORMAT_DATE_AND_TIME } from "../../utils/useFormatDate";
import { toCreateInitialAccessToken } from "../routes/CreateInitialAccessToken";
export const InitialAccessTokenList = () => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const formatDate = useFormatDate();

View file

@ -1,13 +1,13 @@
import { useTranslation } from "react-i18next";
import { FormProvider, useForm } from "react-hook-form";
import { Button, Modal, Form } from "@patternfly/react-core";
import { saveAs } from "file-saver";
import KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
import { KeyForm, getFileExtension } from "./GenerateKeyDialog";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useAdminClient } from "../../context/auth/AdminClient";
import { Button, Form, Modal } from "@patternfly/react-core";
import { saveAs } from "file-saver";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useRealm } from "../../context/realm-context/RealmContext";
import { KeyForm, getFileExtension } from "./GenerateKeyDialog";
type ExportSamlKeyDialogProps = {
clientId: string;
@ -21,7 +21,6 @@ export const ExportSamlKeyDialog = ({
const { t } = useTranslation("clients");
const { realm } = useRealm();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const form = useForm<KeyStoreConfig>({

View file

@ -1,3 +1,5 @@
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import type KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
import {
ActionGroup,
AlertVariant,
@ -14,16 +16,15 @@ import {
} from "@patternfly/react-core";
import { saveAs } from "file-saver";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import type KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
import { Controller, useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { convertAttributeNameToForm } from "../../util";
import useToggle from "../../utils/useToggle";
import { FormFields } from "../ClientDetails";
@ -47,7 +48,6 @@ export const Keys = ({ clientId, save, hasConfigureAccess }: KeysProps) => {
getValues,
formState: { isDirty },
} = useFormContext<FormFields>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [keyInfo, setKeyInfo] = useState<CertificateRepresentation>();

View file

@ -1,13 +1,12 @@
import { useTranslation } from "react-i18next";
import { FormProvider, useFormContext } from "react-hook-form";
import { AlertVariant } from "@patternfly/react-core";
import { FormProvider, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import type { KeyTypes } from "./SamlKeys";
import { KeyForm } from "./GenerateKeyDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useAlerts } from "../../components/alert/Alerts";
import { SamlKeysDialogForm, submitForm } from "./SamlKeysDialog";
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
import { KeyForm } from "./GenerateKeyDialog";
import type { KeyTypes } from "./SamlKeys";
import { SamlKeysDialogForm, submitForm } from "./SamlKeysDialog";
type SamlImportKeyDialogProps = {
id: string;
@ -24,11 +23,10 @@ export const SamlImportKeyDialog = ({
const form = useFormContext<SamlKeysDialogForm>();
const { handleSubmit } = form;
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const submit = (form: SamlKeysDialogForm) => {
submitForm(form, id, attr, adminClient, (error) => {
submitForm(form, id, attr, (error) => {
if (error) {
addError("clients:importError", error);
} else {

View file

@ -1,3 +1,4 @@
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import {
ActionGroup,
AlertVariant,
@ -15,14 +16,14 @@ import { saveAs } from "file-saver";
import { Fragment, useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { FormPanel } from "../../components/scroll-form/FormPanel";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { convertAttributeNameToForm } from "../../util";
import useToggle from "../../utils/useToggle";
import { FormFields } from "../ClientDetails";
@ -162,8 +163,6 @@ export const SamlKeys = ({ clientId, save }: SamlKeysProps) => {
const [refresh, setRefresh] = useState(0);
const { setValue } = useFormContext();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
useFetch(

View file

@ -1,7 +1,5 @@
import { useState } from "react";
import { saveAs } from "file-saver";
import { useTranslation } from "react-i18next";
import { FormProvider, useForm } from "react-hook-form";
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import type KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
import {
AlertVariant,
Button,
@ -19,16 +17,17 @@ import {
TextContent,
Title,
} from "@patternfly/react-core";
import type CertificateRepresentation from "@keycloak/keycloak-admin-client/lib/defs/certificateRepresentation";
import type KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
import type { KeyTypes } from "./SamlKeys";
import { saveAs } from "file-saver";
import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { useAdminClient } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { KeyForm } from "./GenerateKeyDialog";
import { Certificate } from "./Certificate";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { KeyForm } from "./GenerateKeyDialog";
import type { KeyTypes } from "./SamlKeys";
type SamlKeysDialogProps = {
id: string;
@ -45,7 +44,6 @@ export const submitForm = async (
form: SamlKeysDialogForm,
id: string,
attr: KeyTypes,
adminClient: KeycloakAdminClient,
callback: (error?: unknown) => void
) => {
try {
@ -81,11 +79,10 @@ export const SamlKeysDialog = ({
formState: { isValid },
} = form;
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const submit = (form: SamlKeysDialogForm) => {
submitForm(form, id, attr, adminClient, (error) => {
submitForm(form, id, attr, (error) => {
if (error) {
addError("clients:importError", error);
} else {

View file

@ -4,16 +4,16 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate, useParams } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import {
Action,
KeycloakDataTable,
} from "../../components/table-toolbar/KeycloakDataTable";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import useToggle from "../../utils/useToggle";
import { toRegistrationProvider } from "../routes/AddRegistrationProvider";
import { ClientRegistrationParams } from "../routes/ClientRegistration";
import { AddProviderDialog } from "./AddProviderDialog";
@ -48,7 +48,6 @@ export const ClientRegistrationList = ({
const { subTab } = useParams<ClientRegistrationParams>();
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const [policies, setPolicies] = useState<ComponentRepresentation[]>([]);

View file

@ -13,15 +13,17 @@ import { useState } from "react";
import { FormProvider, useForm, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
import { FormAccess } from "../../components/form-access/FormAccess";
import { HelpItem } from "ui-shared";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useParams } from "../../utils/useParams";
import {
@ -45,7 +47,6 @@ export default function DetailProvider() {
formState: { errors },
} = form;
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { addAlert, addError } = useAlerts();
const [provider, setProvider] = useState<ComponentTypeRepresentation>();

View file

@ -4,10 +4,10 @@ import { SubmitHandler, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useNavigate, useParams } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { AttributeForm } from "../../components/key-value-form/AttributeForm";
import { RoleForm } from "../../components/role-form/RoleForm";
import { useAdminClient } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toClient } from "../routes/Client";
import { toClientRole } from "../routes/ClientRole";
@ -18,7 +18,6 @@ export default function CreateClientRole() {
const form = useForm<AttributeForm>({ mode: "onChange" });
const navigate = useNavigate();
const { clientId } = useParams<NewRoleParams>();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { addAlert, addError } = useAlerts();

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import {
AlertVariant,
Button,
@ -10,39 +8,40 @@ import {
KebabToggle,
ToolbarItem,
} from "@patternfly/react-core";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { useAdminClient } from "../../context/auth/AdminClient";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import { AddScopeDialog } from "./AddScopeDialog";
import { adminClient } from "../../admin-client";
import { ChangeTypeDropdown } from "../../client-scopes/ChangeTypeDropdown";
import {
SearchDropdown,
SearchToolbar,
SearchType,
nameFilter,
typeFilter,
} from "../../client-scopes/details/SearchFilter";
import { useAlerts } from "../../components/alert/Alerts";
import {
ClientScope,
CellDropdown,
AllClientScopes,
AllClientScopeType,
changeClientScope,
AllClientScopes,
CellDropdown,
ClientScope,
addClientScope,
changeClientScope,
removeClientScope,
} from "../../components/client-scope/ClientScopeTypes";
import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
import {
Action,
KeycloakDataTable,
} from "../../components/table-toolbar/KeycloakDataTable";
import {
nameFilter,
SearchDropdown,
SearchToolbar,
SearchType,
typeFilter,
} from "../../client-scopes/details/SearchFilter";
import { ChangeTypeDropdown } from "../../client-scopes/ChangeTypeDropdown";
import { toDedicatedScope } from "../routes/DedicatedScopeDetails";
import { useAccess } from "../../context/access/Access";
import { useRealm } from "../../context/realm-context/RealmContext";
import useLocaleSort, { mapByKey } from "../../utils/useLocaleSort";
import { useAccess } from "../../context/access/Access";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { toDedicatedScope } from "../routes/DedicatedScopeDetails";
import { AddScopeDialog } from "./AddScopeDialog";
import "./client-scopes.css";
@ -73,7 +72,6 @@ const TypeSelector = ({
...scope
}: TypeSelectorProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { hasAccess } = useAccess();
@ -89,7 +87,6 @@ const TypeSelector = ({
onSelect={async (value) => {
try {
await changeClientScope(
adminClient,
clientId,
scope,
scope.type,
@ -112,7 +109,6 @@ export const ClientScopes = ({
fineGrainedAccess,
}: ClientScopesProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const localeSort = useLocaleSort();
@ -204,7 +200,6 @@ export const ClientScopes = ({
onConfirm: async () => {
try {
await removeClientScope(
adminClient,
clientId,
selectedRows[0],
selectedRows[0].type as ClientScope
@ -230,12 +225,7 @@ export const ClientScopes = ({
await Promise.all(
scopes.map(
async (scope) =>
await addClientScope(
adminClient,
clientId,
scope.scope,
scope.type!
)
await addClientScope(clientId, scope.scope, scope.type!)
)
);
addAlert(t("clientScopeSuccess"), AlertVariant.success);
@ -306,7 +296,6 @@ export const ClientScopes = ({
await Promise.all(
selectedRows.map((row) =>
removeClientScope(
adminClient,
clientId,
{ ...row },
row.type as ClientScope

View file

@ -1,5 +1,5 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { RoleMappingPayload } from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import {
AlertVariant,
Divider,
@ -7,14 +7,14 @@ import {
PageSection,
Switch,
} from "@patternfly/react-core";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { FormAccess } from "../../components/form-access/FormAccess";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { useAdminClient } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { FormAccess } from "../../components/form-access/FormAccess";
import { RoleMapping, Row } from "../../components/role-mapping/RoleMapping";
import type { RoleMappingPayload } from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import { useAccess } from "../../context/access/Access";
type DedicatedScopeProps = {
@ -25,7 +25,6 @@ export const DedicatedScope = ({
client: initialClient,
}: DedicatedScopeProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [client, setClient] = useState<ClientRepresentation>(initialClient);

View file

@ -11,6 +11,7 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { adminClient } from "../../admin-client";
import { MapperList } from "../../client-scopes/details/MapperList";
import { useAlerts } from "../../components/alert/Alerts";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
@ -19,7 +20,7 @@ import {
useRoutableTab,
} from "../../components/routable-tabs/RoutableTabs";
import { ViewHeader } from "../../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useParams } from "../../utils/useParams";
import {
DedicatedScopeDetailsParams,
@ -33,8 +34,6 @@ export default function DedicatedScopes() {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { realm, clientId } = useParams<DedicatedScopeDetailsParams>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [client, setClient] = useState<ClientRepresentation>();

View file

@ -25,11 +25,12 @@ import { QuestionCircleIcon } from "@patternfly/react-icons";
import { useEffect, useRef, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem, useHelp } from "ui-shared";
import { useHelp, HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { KeycloakDataTable } from "../../components/table-toolbar/KeycloakDataTable";
import { UserSelect } from "../../components/users/UserSelect";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { prettyPrintJSON } from "../../util";
@ -113,7 +114,6 @@ export const EvaluateScopes = ({ clientId, protocol }: EvaluateScopesProps) => {
const prefix = "openid";
const { t } = useTranslation("clients");
const { enabled } = useHelp();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const mapperTypes = useServerInfo().protocolMapperTypes![protocol];

View file

@ -1,19 +1,20 @@
import { useState } from "react";
import { Link } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { RoleMappingPayload } from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import { AlertVariant, PageSection } from "@patternfly/react-core";
import { InfoCircleIcon } from "@patternfly/react-icons";
import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import type { RoleMappingPayload } from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { RoleMapping, Row } from "../../components/role-mapping/RoleMapping";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { toUser } from "../../user/routes/User";
import { useRealm } from "../../context/realm-context/RealmContext";
import { RoleMapping, Row } from "../../components/role-mapping/RoleMapping";
import { useAccess } from "../../context/access/Access";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toUser } from "../../user/routes/User";
import "./service-account.css";
@ -23,7 +24,6 @@ type ServiceAccountProps = {
export const ServiceAccount = ({ client }: ServiceAccountProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();

View file

@ -1,16 +1,15 @@
import { useState } from "react";
import type { TFunction } from "i18next";
import { useTranslation } from "react-i18next";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import {
DropdownItem,
Select,
SelectOption,
SelectProps,
} from "@patternfly/react-core";
import type { TFunction } from "i18next";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type ClientScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientScopeRepresentation";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { adminClient } from "../../admin-client";
import { toUpperCase } from "../../util";
export enum ClientScope {
@ -96,25 +95,23 @@ export type ClientScopeDefaultOptionalType = ClientScopeRepresentation & {
};
export const changeScope = async (
adminClient: KeycloakAdminClient,
clientScope: ClientScopeDefaultOptionalType,
changeTo: AllClientScopeType
) => {
await removeScope(adminClient, clientScope);
await addScope(adminClient, clientScope, changeTo);
await removeScope(clientScope);
await addScope(clientScope, changeTo);
};
const castAdminClient = (adminClient: KeycloakAdminClient) =>
const castAdminClient = () =>
adminClient.clientScopes as unknown as {
[index: string]: Function;
};
export const removeScope = async (
adminClient: KeycloakAdminClient,
clientScope: ClientScopeDefaultOptionalType
) => {
if (clientScope.type !== AllClientScopes.none)
await castAdminClient(adminClient)[
await castAdminClient()[
`delDefault${
clientScope.type === ClientScope.optional ? "Optional" : ""
}ClientScope`
@ -124,12 +121,11 @@ export const removeScope = async (
};
const addScope = async (
adminClient: KeycloakAdminClient,
clientScope: ClientScopeDefaultOptionalType,
type: AllClientScopeType
) => {
if (type !== AllClientScopes.none)
await castAdminClient(adminClient)[
await castAdminClient()[
`addDefault${type === ClientScope.optional ? "Optional" : ""}ClientScope`
]({
id: clientScope.id!,
@ -137,20 +133,18 @@ const addScope = async (
};
export const changeClientScope = async (
adminClient: KeycloakAdminClient,
clientId: string,
clientScope: ClientScopeRepresentation,
type: AllClientScopeType,
changeTo: ClientScopeType
) => {
if (type !== "none") {
await removeClientScope(adminClient, clientId, clientScope, type);
await removeClientScope(clientId, clientScope, type);
}
await addClientScope(adminClient, clientId, clientScope, changeTo);
await addClientScope(clientId, clientScope, changeTo);
};
export const removeClientScope = async (
adminClient: KeycloakAdminClient,
clientId: string,
clientScope: ClientScopeRepresentation,
type: ClientScope
@ -164,7 +158,6 @@ export const removeClientScope = async (
};
export const addClientScope = async (
adminClient: KeycloakAdminClient,
clientId: string,
clientScope: ClientScopeRepresentation,
type: ClientScopeType

View file

@ -1,3 +1,5 @@
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import {
FormGroup,
Select,
@ -7,13 +9,12 @@ import {
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import type { ComponentProps } from "../dynamic/components";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import type { ComponentProps } from "../dynamic/components";
type ClientSelectProps = ComponentProps & {
namespace: string;
required?: boolean;
@ -38,8 +39,6 @@ export const ClientSelect = ({
const [clients, setClients] = useState<ClientRepresentation[]>([]);
const [search, setSearch] = useState("");
const { adminClient } = useAdminClient();
useFetch(
() => {
const params: ClientQuery = {

View file

@ -11,13 +11,15 @@ import {
import { saveAs } from "file-saver";
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { HelpItem, useHelp } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { addTrailingSlash, prettyPrintJSON } from "../../util";
import { getAuthorizationHeaders } from "../../utils/getAuthorizationHeaders";
import { ConfirmDialogModal } from "../confirm-dialog/ConfirmDialog";
import { useHelp, HelpItem } from "ui-shared";
import { KeycloakTextArea } from "../keycloak-text-area/KeycloakTextArea";
type DownloadDialogProps = {
@ -33,7 +35,6 @@ export const DownloadDialog = ({
toggleDialog,
protocol = "openid-connect",
}: DownloadDialogProps) => {
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const { t } = useTranslation("common");
const { enabled } = useHelp();

View file

@ -1,5 +1,4 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import {
Breadcrumb,
BreadcrumbItem,
@ -15,9 +14,11 @@ import {
ModalVariant,
} from "@patternfly/react-core";
import { AngleRightIcon } from "@patternfly/react-icons";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
import { PaginatingTableToolbar } from "../table-toolbar/PaginatingTableToolbar";
import { GroupPath } from "./GroupPath";
@ -48,7 +49,6 @@ export const GroupPickerDialog = ({
onConfirm,
}: GroupPickerDialogProps) => {
const { t } = useTranslation();
const { adminClient } = useAdminClient();
const [selectedRows, setSelectedRows] = useState<SelectableGroup[]>([]);
const [navigation, setNavigation] = useState<SelectableGroup[]>([]);

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import type { ManagementPermissionReference } from "@keycloak/keycloak-admin-client/lib/defs/managementPermissionReference";
import {
Card,
CardBody,
@ -19,13 +17,16 @@ import {
Thead,
Tr,
} from "@patternfly/react-table";
import { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import type { ManagementPermissionReference } from "@keycloak/keycloak-admin-client/lib/defs/managementPermissionReference";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { adminClient } from "../../admin-client";
import { toPermissionDetails } from "../../clients/routes/PermissionDetails";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import { HelpItem } from "ui-shared";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import useLocaleSort from "../../utils/useLocaleSort";
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
@ -46,7 +47,6 @@ type PermissionsTabProps = {
export const PermissionsTab = ({ id, type }: PermissionsTabProps) => {
const { t } = useTranslation("common");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const [realmId, setRealmId] = useState("");
const [permission, setPermission] = useState<ManagementPermissionReference>();

View file

@ -1,5 +1,3 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
Dropdown,
@ -10,14 +8,15 @@ import {
ToolbarItem,
} from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../../context/auth/AdminClient";
import useLocaleSort from "../../utils/useLocaleSort";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
import { KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
import { ResourcesKey, Row, ServiceRole } from "./RoleMapping";
import { getAvailableRoles } from "./queries";
import { getAvailableClientRoles } from "./resource";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
type AddRoleMappingModalProps = {
id: string;
@ -41,7 +40,6 @@ export const AddRoleMappingModal = ({
onClose,
}: AddRoleMappingModalProps) => {
const { t } = useTranslation(type);
const { adminClient } = useAdminClient();
const [searchToggle, setSearchToggle] = useState(false);
@ -67,7 +65,7 @@ export const AddRoleMappingModal = ({
params.search = search;
}
const roles = await getAvailableRoles(adminClient, type, { ...params, id });
const roles = await getAvailableRoles(type, { ...params, id });
const sorted = localeSort(roles, compareRow);
return sorted.map((row) => {
return {
@ -83,7 +81,6 @@ export const AddRoleMappingModal = ({
search?: string
): Promise<Row[]> => {
const roles = await getAvailableClientRoles({
adminClient,
id,
type,
first: first || 0,

View file

@ -1,5 +1,6 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import {
AlertVariant,
Badge,
@ -9,17 +10,15 @@ import {
ToolbarItem,
} from "@patternfly/react-core";
import { cellWidth } from "@patternfly/react-table";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { AddRoleMappingModal } from "./AddRoleMappingModal";
import { Action, KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
import { emptyFormatter, upperCaseFormatter } from "../../util";
import { useAlerts } from "../alert/Alerts";
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
import { Action, KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
import { AddRoleMappingModal } from "./AddRoleMappingModal";
import { deleteMapping, getEffectiveRoles, getMapping } from "./queries";
import { getEffectiveClientRoles } from "./resource";
@ -88,7 +87,6 @@ export const RoleMapping = ({
save,
}: RoleMappingProps) => {
const { t } = useTranslation(type);
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [key, setKey] = useState(0);
@ -107,11 +105,10 @@ export const RoleMapping = ({
let effectiveRoles: Row[] = [];
let effectiveClientRoles: Row[] = [];
if (!hide) {
effectiveRoles = await getEffectiveRoles(adminClient, type, id);
effectiveRoles = await getEffectiveRoles(type, id);
effectiveClientRoles = (
await getEffectiveClientRoles({
adminClient,
type,
id,
})
@ -121,7 +118,7 @@ export const RoleMapping = ({
}));
}
const roles = await getMapping(adminClient, type, id);
const roles = await getMapping(type, id);
const realmRolesMapping =
roles.realmMappings?.map((role) => ({ role })) || [];
const clientMapping = Object.values(roles.clientMappings || {})
@ -149,7 +146,7 @@ export const RoleMapping = ({
continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => {
try {
await Promise.all(deleteMapping(adminClient, type, id, selected));
await Promise.all(deleteMapping(type, id, selected));
addAlert(t("clients:clientScopeRemoveSuccess"), AlertVariant.success);
refresh();
} catch (error) {

View file

@ -1,12 +1,13 @@
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import type MappingsRepresentation from "@keycloak/keycloak-admin-client/lib/defs/mappingsRepresentation";
import type RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import type { ClientScopes } from "@keycloak/keycloak-admin-client/lib/resources/clientScopes";
import type { Clients } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import type { Groups } from "@keycloak/keycloak-admin-client/lib/resources/groups";
import type { Roles } from "@keycloak/keycloak-admin-client/lib/resources/roles";
import type { Users } from "@keycloak/keycloak-admin-client/lib/resources/users";
import type { Clients } from "@keycloak/keycloak-admin-client/lib/resources/clients";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { adminClient } from "../../admin-client";
import { Row } from "./RoleMapping";
export type ResourcesKey = keyof KeycloakAdminClient;
@ -96,34 +97,23 @@ type queryType =
| ListAvailableFunction
| ListEffectiveFunction;
const castAdminClient = (
adminClient: KeycloakAdminClient,
resource: ResourcesKey
) =>
const castAdminClient = (resource: ResourcesKey) =>
adminClient[resource] as unknown as {
[index in queryType]: (...params: any) => Promise<RoleRepresentation[]>;
};
const applyQuery = (
adminClient: KeycloakAdminClient,
type: ResourcesKey,
query: queryType,
...params: object[]
): Promise<RoleRepresentation[]> =>
castAdminClient(adminClient, type)[query](...params);
): Promise<RoleRepresentation[]> => castAdminClient(type)[query](...params);
export const deleteMapping = (
adminClient: KeycloakAdminClient,
type: ResourcesKey,
id: string,
rows: Row[]
) =>
export const deleteMapping = (type: ResourcesKey, id: string, rows: Row[]) =>
rows.map((row) => {
const role = { id: row.role.id!, name: row.role.name! };
const query = mapping[type]?.delete[row.client ? 0 : 1]!;
return applyQuery(
adminClient,
type,
query,
{
@ -137,12 +127,11 @@ export const deleteMapping = (
});
export const getMapping = async (
adminClient: KeycloakAdminClient,
type: ResourcesKey,
id: string
): Promise<MappingsRepresentation> => {
const query = mapping[type]!.listEffective[0];
const result = applyQuery(adminClient, type, query, { id });
const result = applyQuery(type, query, { id });
if (type !== "roles") {
return result as MappingsRepresentation;
}
@ -167,32 +156,30 @@ export const getMapping = async (
};
export const getEffectiveRoles = async (
adminClient: KeycloakAdminClient,
type: ResourcesKey,
id: string
): Promise<Row[]> => {
const query = mapping[type]!.listEffective[1];
if (type !== "roles") {
return (await applyQuery(adminClient, type, query, { id })).map((role) => ({
return (await applyQuery(type, query, { id })).map((role) => ({
role,
}));
}
const roles = await applyQuery(adminClient, type, query, { id });
const roles = await applyQuery(type, query, { id });
const parentRoles = await Promise.all(
roles
.filter((r) => r.composite)
.map((r) => applyQuery(adminClient, type, query, { id: r.id }))
.map((r) => applyQuery(type, query, { id: r.id }))
);
return [...roles, ...parentRoles.flat()].map((role) => ({ role }));
};
export const getAvailableRoles = async (
adminClient: KeycloakAdminClient,
type: ResourcesKey,
params: Record<string, string | number>
): Promise<Row[]> => {
const query = mapping[type]!.listAvailable[1];
return (await applyQuery(adminClient, type, query, params)).map((role) => ({
return (await applyQuery(type, query, params)).map((role) => ({
role,
}));
};

View file

@ -1,12 +1,8 @@
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { fetchAdminUI } from "../../context/auth/admin-ui-endpoint";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
type BaseQuery = {
adminClient: KeycloakAdminClient;
};
import { fetchAdminUI } from "../../context/auth/admin-ui-endpoint";
type IDQuery = BaseQuery & {
type IDQuery = {
id: string;
type: string;
};
@ -20,7 +16,6 @@ type PaginatingQuery = IDQuery & {
type EffectiveClientRolesQuery = IDQuery;
type Query = Partial<Omit<PaginatingQuery, "adminClient">> & {
adminClient: KeycloakAdminClient;
endpoint: string;
};
@ -33,7 +28,6 @@ type ClientRole = {
};
const fetchEndpoint = async ({
adminClient,
id,
type,
first,
@ -41,7 +35,7 @@ const fetchEndpoint = async ({
search,
endpoint,
}: Query): Promise<any> =>
fetchAdminUI(adminClient, `/ui-ext/${endpoint}/${type}/${id}`, {
fetchAdminUI(`/ui-ext/${endpoint}/${type}/${id}`, {
first: (first || 0).toString(),
max: (max || 10).toString(),
search: search || "",
@ -57,7 +51,7 @@ export const getEffectiveClientRoles = (
): Promise<ClientRole[]> =>
fetchEndpoint({ ...query, endpoint: "effective-roles" });
type UserQuery = BaseQuery & {
type UserQuery = {
lastName?: string;
firstName?: string;
email?: string;
@ -75,15 +69,8 @@ export type BruteUser = UserRepresentation & {
bruteForceStatus?: Record<string, object>;
};
export const findUsers = ({
adminClient,
...query
}: UserQuery): Promise<BruteUser[]> =>
fetchAdminUI(
adminClient,
"ui-ext/brute-force-user",
query as Record<string, string>
);
export const findUsers = (query: UserQuery): Promise<BruteUser[]> =>
fetchAdminUI("ui-ext/brute-force-user", query as Record<string, string>);
export const fetchUsedBy = (query: PaginatingQuery): Promise<string[]> =>
fetchEndpoint({ ...query, endpoint: "authentication-management" });

View file

@ -4,14 +4,15 @@ import { AlertVariant, Button, ButtonVariant } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, To, useNavigate } from "react-router-dom";
import { HelpItem } from "ui-shared";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import { useRealm } from "../../context/realm-context/RealmContext";
import { toRealmSettings } from "../../realm-settings/routes/RealmSettings";
import { emptyFormatter, upperCaseFormatter } from "../../util";
import { useAlerts } from "../alert/Alerts";
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
import { HelpItem } from "ui-shared";
import { KeycloakSpinner } from "../keycloak-spinner/KeycloakSpinner";
import { ListEmptyState } from "../list-empty-state/ListEmptyState";
import { Action, KeycloakDataTable } from "../table-toolbar/KeycloakDataTable";
@ -73,7 +74,6 @@ export const RolesList = ({
}: RolesListProps) => {
const { t } = useTranslation(messageBundle);
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm: realmName } = useRealm();
const [realm, setRealm] = useState<RealmRepresentation>();

View file

@ -1,21 +1,21 @@
import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import { Controller, useFormContext } from "react-hook-form";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import type { UserQuery } from "@keycloak/keycloak-admin-client/lib/resources/users";
import {
SelectOption,
FormGroup,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import { debounce } from "lodash-es";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import type { UserQuery } from "@keycloak/keycloak-admin-client/lib/resources/users";
import type { ComponentProps } from "../dynamic/components";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useCallback, useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared";
import { adminClient } from "../../admin-client";
import { useFetch } from "../../context/auth/AdminClient";
import useToggle from "../../utils/useToggle";
import type { ComponentProps } from "../dynamic/components";
type UserSelectProps = ComponentProps & {
variant?: SelectVariant;
@ -42,7 +42,6 @@ export const UserSelect = ({
const [users, setUsers] = useState<(UserRepresentation | undefined)[]>([]);
const [search, setSearch] = useState("");
const { adminClient } = useAdminClient();
const debounceFn = useCallback(debounce(setSearch, 1000), []);
useFetch(

View file

@ -4,8 +4,9 @@ import { sortBy } from "lodash-es";
import { PropsWithChildren, useCallback, useMemo, useState } from "react";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { adminClient } from "../admin-client";
import { keycloak } from "../keycloak";
import { useAdminClient, useFetch } from "./auth/AdminClient";
import { useFetch } from "./auth/AdminClient";
type RealmsContextProps = {
/** A list of all the realms. */
@ -20,7 +21,6 @@ export const RealmsContext = createNamedContext<RealmsContextProps | undefined>(
);
export const RealmsProvider = ({ children }: PropsWithChildren) => {
const { adminClient } = useAdminClient();
const [realms, setRealms] = useState<RealmRepresentation[]>([]);
const [refreshCount, setRefreshCount] = useState(0);

View file

@ -1,26 +1,5 @@
import KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { DependencyList, PropsWithChildren, useEffect } from "react";
import { DependencyList, useEffect } from "react";
import { useErrorHandler } from "react-error-boundary";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { adminClient } from "../../admin-client";
export type AdminClientProps = {
adminClient: KeycloakAdminClient;
};
const AdminClientContext = createNamedContext<AdminClientProps | undefined>(
"AdminClientContext",
undefined
);
export const AdminClientProvider = ({ children }: PropsWithChildren) => (
<AdminClientContext.Provider value={{ adminClient }}>
{children}
</AdminClientContext.Provider>
);
export const useAdminClient = () => useRequiredContext(AdminClientContext);
/**
* Util function to only set the state when the component is still mounted.

View file

@ -1,10 +1,8 @@
import KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { adminClient } from "../../admin-client";
import { getAuthorizationHeaders } from "../../utils/getAuthorizationHeaders";
import { joinPath } from "../../utils/joinPath";
export async function fetchAdminUI<T>(
adminClient: KeycloakAdminClient,
endpoint: string,
query?: Record<string, string>
): Promise<T> {

View file

@ -1,10 +1,10 @@
import { PropsWithChildren, useEffect, useMemo } from "react";
import { useMatch } from "react-router-dom";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { adminClient } from "../../admin-client";
import { DashboardRouteWithRealm } from "../../dashboard/routes/Dashboard";
import environment from "../../environment";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { useAdminClient } from "../auth/AdminClient";
type RealmContextType = {
realm: string;
@ -16,7 +16,6 @@ export const RealmContext = createNamedContext<RealmContextType | undefined>(
);
export const RealmContextProvider = ({ children }: PropsWithChildren) => {
const { adminClient } = useAdminClient();
const routeMatch = useMatch({
path: DashboardRouteWithRealm.path,
end: false,

View file

@ -1,9 +1,10 @@
import type { ServerInfoRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/serverInfoRepesentation";
import { PropsWithChildren, useState } from "react";
import { sortProviders } from "../../util";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { useAdminClient, useFetch } from "../auth/AdminClient";
import { adminClient } from "../../admin-client";
import { sortProviders } from "../../util";
import { useFetch } from "../auth/AdminClient";
export const ServerInfoContext = createNamedContext<
ServerInfoRepresentation | undefined
@ -15,7 +16,6 @@ export const useLoginProviders = () =>
sortProviders(useServerInfo().providers!["login-protocol"].providers);
export const ServerInfoProvider = ({ children }: PropsWithChildren) => {
const { adminClient } = useAdminClient();
const [serverInfo, setServerInfo] = useState<ServerInfoRepresentation>({});
useFetch(adminClient.serverInfo.find, setServerInfo, []);

View file

@ -1,11 +1,12 @@
import type WhoAmIRepresentation from "@keycloak/keycloak-admin-client/lib/defs/whoAmIRepresentation";
import type { AccessType } from "@keycloak/keycloak-admin-client/lib/defs/whoAmIRepresentation";
import { PropsWithChildren, useState } from "react";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { adminClient } from "../../admin-client";
import environment from "../../environment";
import i18n, { DEFAULT_LOCALE } from "../../i18n";
import { createNamedContext, useRequiredContext } from "ui-shared";
import { useAdminClient, useFetch } from "../auth/AdminClient";
import { useFetch } from "../auth/AdminClient";
export class WhoAmI {
constructor(private me?: WhoAmIRepresentation) {
@ -62,7 +63,6 @@ export const WhoAmIContext = createNamedContext<WhoAmIProps | undefined>(
export const useWhoAmI = () => useRequiredContext(WhoAmIContext);
export const WhoAmIContextProvider = ({ children }: PropsWithChildren) => {
const { adminClient } = useAdminClient();
const [whoAmI, setWhoAmI] = useState<WhoAmI>(new WhoAmI());
const [key, setKey] = useState(0);

View file

@ -19,24 +19,24 @@ import {
SelectVariant,
} from "@patternfly/react-core";
import {
cellWidth,
Table,
TableBody,
TableHeader,
TableVariant,
cellWidth,
} from "@patternfly/react-table";
import { pickBy } from "lodash-es";
import { PropsWithChildren, useMemo, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import {
Action,
KeycloakDataTable,
} from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import { prettyPrintJSON } from "../util";
@ -94,7 +94,6 @@ const DisplayDialog = ({
export const AdminEvents = () => {
const { t } = useTranslation("events");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const serverInfo = useServerInfo();
const formatDate = useFormatDate();

View file

@ -33,6 +33,7 @@ import { Controller, useForm } from "react-hook-form";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { adminClient } from "../admin-client";
import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import {
@ -41,7 +42,7 @@ import {
} from "../components/routable-tabs/RoutableTabs";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import helpUrls from "../help-urls";
import { toRealmSettings } from "../realm-settings/routes/RealmSettings";
@ -126,7 +127,6 @@ const UserDetailLink = (event: EventRepresentation) => {
export default function EventsSection() {
const { t } = useTranslation("events");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const formatDate = useFormatDate();
const [key, setKey] = useState(0);

View file

@ -1,30 +1,28 @@
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useForm } from "react-hook-form";
import {
AlertVariant,
PageSection,
PageSectionVariants,
} from "@patternfly/react-core";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { useLocation } from "react-router-dom";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import {
AttributeForm,
AttributesForm,
} from "../components/key-value-form/AttributeForm";
import {
keyValueToArray,
arrayToKeyValue,
keyValueToArray,
} from "../components/key-value-form/key-value-convert";
import { useAdminClient } from "../context/auth/AdminClient";
import { getLastId } from "./groupIdUtils";
import { useSubGroups } from "./SubGroupsContext";
import { useLocation } from "react-router-dom";
import { getLastId } from "./groupIdUtils";
export const GroupAttributes = () => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const form = useForm<AttributeForm>({
mode: "onChange",

View file

@ -1,8 +1,8 @@
import { useTranslation } from "react-i18next";
import { AlertVariant } from "@patternfly/react-core";
import type { RoleMappingPayload } from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import { useAdminClient } from "../context/auth/AdminClient";
import { AlertVariant } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { RoleMapping, Row } from "../components/role-mapping/RoleMapping";
@ -13,7 +13,6 @@ type GroupRoleMappingProps = {
export const GroupRoleMapping = ({ id, name }: GroupRoleMappingProps) => {
const { t } = useTranslation("clients");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const assignRoles = async (rows: Row[]) => {

View file

@ -1,23 +1,23 @@
import { useState } from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { SearchInput, ToolbarItem } from "@patternfly/react-core";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useAdminClient } from "../context/auth/AdminClient";
import { SearchInput, ToolbarItem } from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { adminClient } from "../admin-client";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { useAccess } from "../context/access/Access";
import { fetchAdminUI } from "../context/auth/admin-ui-endpoint";
import { useRealm } from "../context/realm-context/RealmContext";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { GroupsModal } from "./GroupsModal";
import { getLastId } from "./groupIdUtils";
import { useSubGroups } from "./SubGroupsContext";
import { toGroups } from "./routes/Groups";
import { useAccess } from "../context/access/Access";
import useToggle from "../utils/useToggle";
import { GroupsModal } from "./GroupsModal";
import { useSubGroups } from "./SubGroupsContext";
import { DeleteGroup } from "./components/DeleteGroup";
import { GroupToolbar } from "./components/GroupToolbar";
import { MoveDialog } from "./components/MoveDialog";
import { getLastId } from "./groupIdUtils";
import { toGroups } from "./routes/Groups";
type GroupTableProps = {
refresh: () => void;
@ -30,7 +30,6 @@ export const GroupTable = ({
}: GroupTableProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const [selectedRows, setSelectedRows] = useState<GroupRepresentation[]>([]);
@ -70,14 +69,10 @@ export const GroupTable = ({
? group.subGroups
: group.subGroups?.filter((g) => g.name?.includes(search));
} else {
groupsData = await fetchAdminUI<GroupRepresentation[]>(
adminClient,
"ui-ext/groups",
{
...params,
global: "false",
}
);
groupsData = await fetchAdminUI<GroupRepresentation[]>("ui-ext/groups", {
...params,
global: "false",
});
}
if (!groupsData) {

View file

@ -1,3 +1,4 @@
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import {
AlertVariant,
Button,
@ -8,11 +9,10 @@ import {
ModalVariant,
ValidatedOptions,
} from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useAdminClient } from "../context/auth/AdminClient";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput";
@ -30,7 +30,6 @@ export const GroupsModal = ({
refresh,
}: GroupsModalProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const {
register,

View file

@ -16,11 +16,12 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useLocation, useNavigate } from "react-router-dom";
import { adminClient } from "../admin-client";
import { GroupBreadCrumbs } from "../components/bread-crumb/GroupBreadCrumbs";
import { PermissionsTab } from "../components/permission-tab/PermissionTab";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAccess } from "../context/access/Access";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import helpUrls from "../help-urls";
import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled";
@ -42,7 +43,6 @@ export default function GroupsSection() {
const { t } = useTranslation("groups");
const [activeTab, setActiveTab] = useState(0);
const { adminClient } = useAdminClient();
const { subGroups, setSubGroups, currentGroup } = useSubGroups();
const { realm } = useRealm();

View file

@ -1,7 +1,5 @@
import { useState } from "react";
import { Link, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { uniqBy } from "lodash-es";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import {
AlertVariant,
Button,
@ -11,25 +9,26 @@ import {
KebabToggle,
ToolbarItem,
} from "@patternfly/react-core";
import { uniqBy } from "lodash-es";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useLocation } from "react-router-dom";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { GroupPath } from "../components/group/GroupPath";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import {
Action,
KeycloakDataTable,
} from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { useAlerts } from "../components/alert/Alerts";
import { emptyFormatter } from "../util";
import { getLastId } from "./groupIdUtils";
import { useSubGroups } from "./SubGroupsContext";
import { MemberModal } from "./MembersModal";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { GroupPath } from "../components/group/GroupPath";
import { toUser } from "../user/routes/User";
import { useAccess } from "../context/access/Access";
import { useRealm } from "../context/realm-context/RealmContext";
import { toUser } from "../user/routes/User";
import { emptyFormatter } from "../util";
import { MemberModal } from "./MembersModal";
import { useSubGroups } from "./SubGroupsContext";
import { getLastId } from "./groupIdUtils";
type MembersOf = UserRepresentation & {
membership: GroupRepresentation[];
@ -59,7 +58,6 @@ const UserDetailLink = (user: MembersOf) => {
export const Members = () => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const location = useLocation();

View file

@ -1,19 +1,19 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import {
AlertVariant,
Button,
Modal,
ModalVariant,
} from "@patternfly/react-core";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import { useAdminClient } from "../context/auth/AdminClient";
import { useAlerts } from "../components/alert/Alerts";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { emptyFormatter } from "../util";
import { differenceBy } from "lodash-es";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { emptyFormatter } from "../util";
type MemberModalProps = {
groupId: string;
@ -22,7 +22,6 @@ type MemberModalProps = {
export const MemberModal = ({ groupId, onClose }: MemberModalProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const [selectedRows, setSelectedRows] = useState<UserRepresentation[]>([]);

View file

@ -1,10 +1,10 @@
import { useTranslation } from "react-i18next";
import { ButtonVariant } from "@patternfly/react-core";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
import { ButtonVariant } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { ConfirmDialogModal } from "../../components/confirm-dialog/ConfirmDialog";
type DeleteConfirmProps = {
selectedRows: GroupRepresentation[];
@ -20,7 +20,6 @@ export const DeleteGroup = ({
refresh,
}: DeleteConfirmProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const multiDelete = async () => {

View file

@ -1,6 +1,4 @@
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import {
AlertVariant,
Checkbox,
@ -14,22 +12,25 @@ import {
TreeView,
TreeViewDataItem,
} from "@patternfly/react-core";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
import useToggle from "../../utils/useToggle";
import { DeleteGroup } from "./DeleteGroup";
import { GroupsModal } from "../GroupsModal";
import { MoveDialog } from "./MoveDialog";
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
import { useSubGroups } from "../SubGroupsContext";
import { useAccess } from "../../context/access/Access";
import { useFetch } from "../../context/auth/AdminClient";
import { fetchAdminUI } from "../../context/auth/admin-ui-endpoint";
import { useRealm } from "../../context/realm-context/RealmContext";
import { joinPath } from "../../utils/joinPath";
import useToggle from "../../utils/useToggle";
import { GroupsModal } from "../GroupsModal";
import { useSubGroups } from "../SubGroupsContext";
import { toGroups } from "../routes/Groups";
import { useAlerts } from "../../components/alert/Alerts";
import { useAccess } from "../../context/access/Access";
import { DeleteGroup } from "./DeleteGroup";
import { MoveDialog } from "./MoveDialog";
import "./group-tree.css";
@ -113,7 +114,6 @@ export const GroupTree = ({
canViewDetails,
}: GroupTreeProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { realm } = useRealm();
const navigate = useNavigate();
const { addAlert } = useAlerts();
@ -163,7 +163,6 @@ export const GroupTree = ({
useFetch(
async () => {
const groups = await fetchAdminUI<GroupRepresentation[]>(
adminClient,
"ui-ext/groups",
Object.assign(
{

View file

@ -1,10 +1,9 @@
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import { useTranslation } from "react-i18next";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
import type KeycloakAdminClient from "@keycloak/keycloak-admin-client";
import { adminClient } from "../../admin-client";
import { useAlerts } from "../../components/alert/Alerts";
import { GroupPickerDialog } from "../../components/group/GroupPickerDialog";
import { useAdminClient } from "../../context/auth/AdminClient";
type MoveDialogProps = {
source: GroupRepresentation;
@ -12,10 +11,7 @@ type MoveDialogProps = {
refresh: () => void;
};
const moveToRoot = async (
adminClient: KeycloakAdminClient,
source: GroupRepresentation
) => {
const moveToRoot = async (source: GroupRepresentation) => {
await adminClient.groups.del({ id: source.id! });
const { id } = await adminClient.groups.create({
...source,
@ -37,7 +33,6 @@ const moveToRoot = async (
};
const moveToGroup = async (
adminClient: KeycloakAdminClient,
source: GroupRepresentation,
dest: GroupRepresentation
) => {
@ -52,15 +47,11 @@ const moveToGroup = async (
export const MoveDialog = ({ source, onClose, refresh }: MoveDialogProps) => {
const { t } = useTranslation("groups");
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const moveGroup = async (group?: GroupRepresentation[]) => {
try {
await (group
? moveToGroup(adminClient, source, group[0])
: moveToRoot(adminClient, source));
await (group ? moveToGroup(source, group[0]) : moveToRoot(source));
refresh();
addAlert(t("moveGroupSuccess"));
} catch (error) {

View file

@ -1,3 +1,4 @@
import type IdentityProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation";
import {
AlertVariant,
Badge,
@ -22,9 +23,9 @@ import { groupBy, sortBy } from "lodash-es";
import { Fragment, useState } from "react";
import { useTranslation } from "react-i18next";
import { Link, useNavigate } from "react-router-dom";
import type IdentityProviderRepresentation from "@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation";
import { IconMapper } from "ui-shared";
import { adminClient } from "../admin-client";
import { useAlerts } from "../components/alert/Alerts";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { ClickableCard } from "../components/keycloak-card/ClickableCard";
@ -33,7 +34,7 @@ import {
KeycloakDataTable,
} from "../components/table-toolbar/KeycloakDataTable";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
import { useFetch } from "../context/auth/AdminClient";
import { useRealm } from "../context/realm-context/RealmContext";
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import helpUrls from "../help-urls";
@ -87,8 +88,6 @@ export default function IdentityProvidersSection() {
useState<IdentityProviderRepresentation[]>();
const [selectedProvider, setSelectedProvider] =
useState<IdentityProviderRepresentation>();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
useFetch(

Some files were not shown because too many files have changed in this diff Show more