diff --git a/apps/admin-ui/src/components/data-loader/DataLoader.test.tsx b/apps/admin-ui/src/components/data-loader/DataLoader.test.tsx deleted file mode 100644 index 2de548a44e..0000000000 --- a/apps/admin-ui/src/components/data-loader/DataLoader.test.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @vitest-environment jsdom - */ -import type KeycloakAdminClient from "@keycloak/keycloak-admin-client"; -import type { ServerInfoRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/serverInfoRepesentation"; -import { render, waitFor } from "@testing-library/react"; -import type Keycloak from "keycloak-js"; -import { FunctionComponent } from "react"; -import { HashRouter } from "react-router-dom"; -import { describe, expect, it } from "vitest"; -import { AccessContextProvider } from "../../context/access/Access"; -import { AdminClientContext } from "../../context/auth/AdminClient"; -import { RealmContext } from "../../context/realm-context/RealmContext"; -import { ServerInfoContext } from "../../context/server-info/ServerInfoProvider"; -import serverInfo from "../../context/server-info/__tests__/mock.json"; -import { WhoAmIContextProvider } from "../../context/whoami/WhoAmI"; -import whoamiMock from "../../context/whoami/__tests__/mock-whoami.json"; -import { DataLoader } from "./DataLoader"; - -const MockAdminClient: FunctionComponent = ({ children }) => { - const keycloak = { - init: () => Promise.resolve(), - } as unknown as Keycloak; - const adminClient = { - whoAmI: { find: () => Promise.resolve(whoamiMock) }, - setConfig: () => {}, - } as unknown as KeycloakAdminClient; - - return ( - - - - - - {children} - - - - - - ); -}; - -describe("DataLoader", () => { - it("loads the data and renders the result", async () => { - const loader = () => Promise.resolve(["a", "b"]); - const { container } = render( - - - {(result) => ( -
- {result.map((value) => ( - {value} - ))} -
- )} -
-
- ); - - await waitFor(() => expect(container.textContent).toEqual("ab")); - }); -}); diff --git a/apps/admin-ui/src/components/data-loader/DataLoader.tsx b/apps/admin-ui/src/components/data-loader/DataLoader.tsx deleted file mode 100644 index c1251d7367..0000000000 --- a/apps/admin-ui/src/components/data-loader/DataLoader.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { DependencyList, ReactNode, useState } from "react"; - -import { useFetch } from "../../context/auth/AdminClient"; -import { KeycloakSpinner } from "../keycloak-spinner/KeycloakSpinner"; - -type DataLoaderProps = { - loader: () => Promise; - deps?: DependencyList; - children: ((arg: T) => any) | ReactNode; -}; - -export function DataLoader(props: DataLoaderProps) { - const [data, setData] = useState(); - - useFetch( - () => props.loader(), - (result) => setData(result), - props.deps || [] - ); - - if (data) { - if (props.children instanceof Function) { - return props.children(data); - } - return props.children; - } - return ; -}