renamed useFetch
to asyncStateFetch
(#277)
* renamed `useFetch` to `asyncStateFetch` otherwise React will mistake it for a react hook and will complain. * added jsdoc * fixed the user red stories * renamed
This commit is contained in:
parent
1763ee1a50
commit
feca61d2b0
25 changed files with 113 additions and 49 deletions
|
@ -19,7 +19,7 @@ import { routes, RouteDef } from "./route-config";
|
||||||
import { PageBreadCrumbs } from "./components/bread-crumb/PageBreadCrumbs";
|
import { PageBreadCrumbs } from "./components/bread-crumb/PageBreadCrumbs";
|
||||||
import { ForbiddenSection } from "./ForbiddenSection";
|
import { ForbiddenSection } from "./ForbiddenSection";
|
||||||
import { useRealm } from "./context/realm-context/RealmContext";
|
import { useRealm } from "./context/realm-context/RealmContext";
|
||||||
import { useAdminClient, useFetch } from "./context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "./context/auth/AdminClient";
|
||||||
|
|
||||||
// This must match the id given as scrollableSelector in scroll-form
|
// This must match the id given as scrollableSelector in scroll-form
|
||||||
const mainPageContentId = "kc-main-content-page-container";
|
const mainPageContentId = "kc-main-content-page-container";
|
||||||
|
@ -41,7 +41,7 @@ const RealmPathSelector = ({ children }: { children: ReactNode }) => {
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
useEffect(
|
useEffect(
|
||||||
() =>
|
() =>
|
||||||
useFetch(
|
asyncStateFetch(
|
||||||
() => adminClient.realms.find(),
|
() => adminClient.realms.find(),
|
||||||
(realms) => {
|
(realms) => {
|
||||||
if (realms.findIndex((r) => r.realm == realm) !== -1) {
|
if (realms.findIndex((r) => r.realm == realm) !== -1) {
|
||||||
|
|
|
@ -24,7 +24,10 @@ import ClientRepresentation from "keycloak-admin/lib/defs/clientRepresentation";
|
||||||
import ProtocolMapperRepresentation from "keycloak-admin/lib/defs/protocolMapperRepresentation";
|
import ProtocolMapperRepresentation from "keycloak-admin/lib/defs/protocolMapperRepresentation";
|
||||||
import { useAlerts } from "../../components/alert/Alerts";
|
import { useAlerts } from "../../components/alert/Alerts";
|
||||||
import { RealmContext } from "../../context/realm-context/RealmContext";
|
import { RealmContext } from "../../context/realm-context/RealmContext";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
|
|
||||||
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
||||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
|
@ -47,7 +50,7 @@ export const RoleMappingForm = () => {
|
||||||
const [clientRoles, setClientRoles] = useState<RoleRepresentation[]>([]);
|
const [clientRoles, setClientRoles] = useState<RoleRepresentation[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
const clients = await adminClient.clients.find();
|
const clients = await adminClient.clients.find();
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ export const RoleMappingForm = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
const client = selectedClient as ClientRepresentation;
|
const client = selectedClient as ClientRepresentation;
|
||||||
if (client && client.name !== "realmRoles") {
|
if (client && client.name !== "realmRoles") {
|
||||||
|
|
|
@ -24,7 +24,10 @@ import { ConfigPropertyRepresentation } from "keycloak-admin/lib/defs/configProp
|
||||||
import ProtocolMapperRepresentation from "keycloak-admin/lib/defs/protocolMapperRepresentation";
|
import ProtocolMapperRepresentation from "keycloak-admin/lib/defs/protocolMapperRepresentation";
|
||||||
|
|
||||||
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
|
||||||
import { useAlerts } from "../../components/alert/Alerts";
|
import { useAlerts } from "../../components/alert/Alerts";
|
||||||
|
@ -56,7 +59,7 @@ export const MappingDetails = () => {
|
||||||
const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/;
|
const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
if (id.match(isGuid)) {
|
if (id.match(isGuid)) {
|
||||||
const data = await adminClient.clientScopes.findProtocolMapper({
|
const data = await adminClient.clientScopes.findProtocolMapper({
|
||||||
|
|
|
@ -22,7 +22,10 @@ import { Controller, useForm } from "react-hook-form";
|
||||||
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
|
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
|
||||||
|
|
||||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useAlerts } from "../../components/alert/Alerts";
|
import { useAlerts } from "../../components/alert/Alerts";
|
||||||
import { useLoginProviders } from "../../context/server-info/ServerInfoProvider";
|
import { useLoginProviders } from "../../context/server-info/ServerInfoProvider";
|
||||||
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
import { ViewHeader } from "../../components/view-header/ViewHeader";
|
||||||
|
@ -49,7 +52,7 @@ export const ClientScopeForm = () => {
|
||||||
const refresh = () => setKey(new Date().getTime());
|
const refresh = () => setKey(new Date().getTime());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
if (id) {
|
if (id) {
|
||||||
const data = await adminClient.clientScopes.findOne({ id });
|
const data = await adminClient.clientScopes.findOne({ id });
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import { useDownloadDialog } from "../components/download-dialog/DownloadDialog";
|
import { useDownloadDialog } from "../components/download-dialog/DownloadDialog";
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "../context/auth/AdminClient";
|
||||||
import { Credentials } from "./credentials/Credentials";
|
import { Credentials } from "./credentials/Credentials";
|
||||||
import {
|
import {
|
||||||
convertFormValuesToObject,
|
convertFormValuesToObject,
|
||||||
|
@ -144,7 +144,7 @@ export const ClientDetails = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.clients.findOne({ id }),
|
() => adminClient.clients.findOne({ id }),
|
||||||
(fetchedClient) => {
|
(fetchedClient) => {
|
||||||
setClient(fetchedClient);
|
setClient(fetchedClient);
|
||||||
|
|
|
@ -22,7 +22,10 @@ import { useAlerts } from "../../components/alert/Alerts";
|
||||||
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
|
||||||
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
|
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { ClientSecret } from "./ClientSecret";
|
import { ClientSecret } from "./ClientSecret";
|
||||||
import { SignedJWT } from "./SignedJWT";
|
import { SignedJWT } from "./SignedJWT";
|
||||||
import { X509 } from "./X509";
|
import { X509 } from "./X509";
|
||||||
|
@ -64,7 +67,7 @@ export const Credentials = ({ clientId, form, save }: CredentialsProps) => {
|
||||||
const [open, isOpen] = useState(false);
|
const [open, isOpen] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
const providers = await adminClient.authenticationManagement.getClientAuthenticatorProviders(
|
const providers = await adminClient.authenticationManagement.getClientAuthenticatorProviders(
|
||||||
{ id: clientId }
|
{ id: clientId }
|
||||||
|
|
|
@ -23,7 +23,10 @@ import { FilterIcon } from "@patternfly/react-icons";
|
||||||
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
|
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
|
||||||
import KeycloakAdminClient from "keycloak-admin";
|
import KeycloakAdminClient from "keycloak-admin";
|
||||||
|
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { TableToolbar } from "../../components/table-toolbar/TableToolbar";
|
import { TableToolbar } from "../../components/table-toolbar/TableToolbar";
|
||||||
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
|
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
|
||||||
import { AddScopeDialog } from "./AddScopeDialog";
|
import { AddScopeDialog } from "./AddScopeDialog";
|
||||||
|
@ -137,7 +140,7 @@ export const ClientScopes = ({ clientId, protocol }: ClientScopesProps) => {
|
||||||
const refresh = () => setKey(new Date().getTime());
|
const refresh = () => setKey(new Date().getTime());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
const defaultClientScopes = await adminClient.clients.listDefaultClientScopes(
|
const defaultClientScopes = await adminClient.clients.listDefaultClientScopes(
|
||||||
{ id: clientId }
|
{ id: clientId }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Spinner } from "@patternfly/react-core";
|
import { Spinner } from "@patternfly/react-core";
|
||||||
import { useFetch } from "../../context/auth/AdminClient";
|
import { asyncStateFetch } from "../../context/auth/AdminClient";
|
||||||
|
|
||||||
type DataLoaderProps<T> = {
|
type DataLoaderProps<T> = {
|
||||||
loader: () => Promise<T>;
|
loader: () => Promise<T>;
|
||||||
|
@ -20,7 +20,7 @@ export function DataLoader<T>(props: DataLoaderProps<T>) {
|
||||||
const refresh = () => setKey(new Date().getTime());
|
const refresh = () => setKey(new Date().getTime());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => props.loader(),
|
() => props.loader(),
|
||||||
(result) => setData({ result })
|
(result) => setData({ result })
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,7 +18,10 @@ import { ConfirmDialogModal } from "../confirm-dialog/ConfirmDialog";
|
||||||
import { HelpItem } from "../help-enabler/HelpItem";
|
import { HelpItem } from "../help-enabler/HelpItem";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { HelpContext } from "../help-enabler/HelpHeader";
|
import { HelpContext } from "../help-enabler/HelpHeader";
|
||||||
|
|
||||||
export type DownloadDialogProps = {
|
export type DownloadDialogProps = {
|
||||||
|
@ -65,7 +68,7 @@ export const DownloadDialog = ({
|
||||||
const [openType, setOpenType] = useState(false);
|
const [openType, setOpenType] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
const snippet = await adminClient.clients.getInstallationProviders({
|
const snippet = await adminClient.clients.getInstallationProviders({
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import _ from "lodash";
|
||||||
|
|
||||||
import { PaginatingTableToolbar } from "./PaginatingTableToolbar";
|
import { PaginatingTableToolbar } from "./PaginatingTableToolbar";
|
||||||
import { TableToolbar } from "./TableToolbar";
|
import { TableToolbar } from "./TableToolbar";
|
||||||
import { useFetch } from "../../context/auth/AdminClient";
|
import { asyncStateFetch } from "../../context/auth/AdminClient";
|
||||||
|
|
||||||
type Row<T> = {
|
type Row<T> = {
|
||||||
data: T;
|
data: T;
|
||||||
|
@ -132,7 +132,7 @@ export function KeycloakDataTable<T>({
|
||||||
const refresh = () => setKey(new Date().getTime());
|
const refresh = () => setKey(new Date().getTime());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const data = await loader(first, max, search);
|
const data = await loader(first, max, search);
|
||||||
|
|
|
@ -17,7 +17,23 @@ export const useAdminClient = () => {
|
||||||
return adminClient;
|
return adminClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useFetch<T>(
|
/**
|
||||||
|
* Util function to only set the state when the component is still mounted.
|
||||||
|
*
|
||||||
|
* It takes 2 functions one you do your adminClient call in and the other to set your state
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* useEffect(() => {
|
||||||
|
* return asyncStateFetch(
|
||||||
|
* () => adminClient.components.findOne({ id }),
|
||||||
|
* (component) => setupForm(component)
|
||||||
|
* );
|
||||||
|
* }, []);
|
||||||
|
*
|
||||||
|
* @param adminClientCall use this to do your adminClient call
|
||||||
|
* @param callback when the data is fetched this is where you set your state
|
||||||
|
*/
|
||||||
|
export function asyncStateFetch<T>(
|
||||||
adminClientCall: () => Promise<T>,
|
adminClientCall: () => Promise<T>,
|
||||||
callback: (param: T) => void
|
callback: (param: T) => void
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { FormAccess } from "../components/form-access/FormAccess";
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
|
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "../context/auth/AdminClient";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import { RoleAttributes } from "./RoleAttributes";
|
import { RoleAttributes } from "./RoleAttributes";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
@ -113,7 +113,7 @@ export const RealmRolesForm = () => {
|
||||||
const [activeTab, setActiveTab] = useState(0);
|
const [activeTab, setActiveTab] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
async () => {
|
async () => {
|
||||||
if (id) {
|
if (id) {
|
||||||
const role = await adminClient.roles.findOneById({ id });
|
const role = await adminClient.roles.findOneById({ id });
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Controller, useForm } from "react-hook-form";
|
||||||
import { FormAccess } from "../components/form-access/FormAccess";
|
import { FormAccess } from "../components/form-access/FormAccess";
|
||||||
|
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "../context/auth/AdminClient";
|
||||||
import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation";
|
import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation";
|
||||||
import { RoleAttributes } from "./RoleAttributes";
|
import { RoleAttributes } from "./RoleAttributes";
|
||||||
import "./RealmRolesSection.css";
|
import "./RealmRolesSection.css";
|
||||||
|
@ -37,7 +37,7 @@ export const RolesTabs = () => {
|
||||||
const { addAlert } = useAlerts();
|
const { addAlert } = useAlerts();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.roles.findOneById({ id }),
|
() => adminClient.roles.findOneById({ id }),
|
||||||
(fetchedRole) => {
|
(fetchedRole) => {
|
||||||
setName(fetchedRole.name!);
|
setName(fetchedRole.name!);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { useParams } from "react-router-dom";
|
||||||
import { Button, ButtonVariant, TextInput } from "@patternfly/react-core";
|
import { Button, ButtonVariant, TextInput } from "@patternfly/react-core";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import "./RealmRolesSection.css";
|
import "./RealmRolesSection.css";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "../context/auth/AdminClient";
|
||||||
import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation";
|
import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ export const RoleAttributes = () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.roles.findOneById({ id }),
|
() => adminClient.roles.findOneById({ id }),
|
||||||
(fetchedRole) => {
|
(fetchedRole) => {
|
||||||
setName(fetchedRole.name!);
|
setName(fetchedRole.name!);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import KeycloakAdminClient from "keycloak-admin";
|
||||||
|
|
||||||
import { AccessContextProvider } from "../context/access/Access";
|
import { AccessContextProvider } from "../context/access/Access";
|
||||||
import { WhoAmIContextProvider } from "../context/whoami/WhoAmI";
|
import { WhoAmIContextProvider } from "../context/whoami/WhoAmI";
|
||||||
import { RealmContextProvider } from "../context/realm-context/RealmContext";
|
import { RealmContext } from "../context/realm-context/RealmContext";
|
||||||
|
|
||||||
import whoamiMock from "../context/whoami/__tests__/mock-whoami.json";
|
import whoamiMock from "../context/whoami/__tests__/mock-whoami.json";
|
||||||
import { AdminClient } from "../context/auth/AdminClient";
|
import { AdminClient } from "../context/auth/AdminClient";
|
||||||
|
@ -39,9 +39,11 @@ export const MockAdminClient = (props: {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<WhoAmIContextProvider>
|
<WhoAmIContextProvider>
|
||||||
<RealmContextProvider>
|
<RealmContext.Provider
|
||||||
|
value={{ realm: "master", setRealm: () => {} }}
|
||||||
|
>
|
||||||
<AccessContextProvider>{props.children}</AccessContextProvider>
|
<AccessContextProvider>{props.children}</AccessContextProvider>
|
||||||
</RealmContextProvider>
|
</RealmContext.Provider>
|
||||||
</WhoAmIContextProvider>
|
</WhoAmIContextProvider>
|
||||||
</AdminClient.Provider>
|
</AdminClient.Provider>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
|
|
|
@ -12,7 +12,9 @@ export default {
|
||||||
export const view = () => {
|
export const view = () => {
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<MockAdminClient>
|
<MockAdminClient
|
||||||
|
mock={{ components: { findOne: () => Promise.resolve({}) } }}
|
||||||
|
>
|
||||||
<UserFederationKerberosSettings />
|
<UserFederationKerberosSettings />
|
||||||
</MockAdminClient>
|
</MockAdminClient>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from "react";
|
||||||
import { Meta } from "@storybook/react";
|
import { Meta } from "@storybook/react";
|
||||||
import { Page } from "@patternfly/react-core";
|
import { Page } from "@patternfly/react-core";
|
||||||
import { UserFederationLdapSettings } from "../user-federation/UserFederationLdapSettings";
|
import { UserFederationLdapSettings } from "../user-federation/UserFederationLdapSettings";
|
||||||
|
import { MockAdminClient } from "./MockAdminClient";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: "User Federation LDAP Settings Tab",
|
title: "User Federation LDAP Settings Tab",
|
||||||
|
@ -11,7 +12,11 @@ export default {
|
||||||
export const view = () => {
|
export const view = () => {
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
<MockAdminClient
|
||||||
|
mock={{ components: { findOne: () => Promise.resolve({}) } }}
|
||||||
|
>
|
||||||
<UserFederationLdapSettings />
|
<UserFederationLdapSettings />
|
||||||
|
</MockAdminClient>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { DatabaseIcon } from "@patternfly/react-icons";
|
import { DatabaseIcon } from "@patternfly/react-icons";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { RealmContext } from "../context/realm-context/RealmContext";
|
import { RealmContext } from "../context/realm-context/RealmContext";
|
||||||
import { useAdminClient, useFetch } from "../context/auth/AdminClient";
|
import { useAdminClient, asyncStateFetch } from "../context/auth/AdminClient";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import "./user-federation.css";
|
import "./user-federation.css";
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export const UserFederationSection = () => {
|
||||||
const refresh = () => setKey(new Date().getTime());
|
const refresh = () => setKey(new Date().getTime());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => {
|
() => {
|
||||||
const testParams: { [name: string]: string | number } = {
|
const testParams: { [name: string]: string | number } = {
|
||||||
parentId: realm,
|
parentId: realm,
|
||||||
|
|
|
@ -12,7 +12,10 @@ import { convertToFormValues } from "../../util";
|
||||||
import { useForm, Controller, useWatch } from "react-hook-form";
|
import { useForm, Controller, useWatch } from "react-hook-form";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
||||||
|
@ -41,7 +44,7 @@ export const KerberosSettingsCache = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(component) => setupForm(component)
|
(component) => setupForm(component)
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { useForm, Controller } from "react-hook-form";
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const LdapSettingsAdvanced = () => {
|
export const LdapSettingsAdvanced = () => {
|
||||||
|
@ -27,7 +30,7 @@ export const LdapSettingsAdvanced = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,7 +16,10 @@ import { convertToFormValues } from "../../util";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { EyeIcon } from "@patternfly/react-icons";
|
import { EyeIcon } from "@patternfly/react-icons";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const LdapSettingsConnection = () => {
|
export const LdapSettingsConnection = () => {
|
||||||
|
@ -62,7 +65,7 @@ export const LdapSettingsConnection = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,10 @@ import { useForm, Controller } from "react-hook-form";
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const LdapSettingsGeneral = () => {
|
export const LdapSettingsGeneral = () => {
|
||||||
|
@ -37,7 +40,7 @@ export const LdapSettingsGeneral = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { useForm, Controller } from "react-hook-form";
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const LdapSettingsKerberosIntegration = () => {
|
export const LdapSettingsKerberosIntegration = () => {
|
||||||
|
@ -28,7 +31,7 @@ export const LdapSettingsKerberosIntegration = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,10 @@ import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
|
|
||||||
|
@ -54,7 +57,7 @@ export const LdapSettingsSearching = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { useForm, Controller } from "react-hook-form";
|
||||||
import { convertToFormValues } from "../../util";
|
import { convertToFormValues } from "../../util";
|
||||||
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
|
||||||
import { FormAccess } from "../../components/form-access/FormAccess";
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
||||||
import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
|
import {
|
||||||
|
useAdminClient,
|
||||||
|
asyncStateFetch,
|
||||||
|
} from "../../context/auth/AdminClient";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const LdapSettingsSynchronization = () => {
|
export const LdapSettingsSynchronization = () => {
|
||||||
|
@ -27,7 +30,7 @@ export const LdapSettingsSynchronization = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return useFetch(
|
return asyncStateFetch(
|
||||||
() => adminClient.components.findOne({ id }),
|
() => adminClient.components.findOne({ id }),
|
||||||
(fetchedComponent) => setupForm(fetchedComponent)
|
(fetchedComponent) => setupForm(fetchedComponent)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue