From 4ae51dc912227cfcbce648a8d6f477783c6a6558 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Mon, 28 Oct 2024 11:10:44 +0100 Subject: [PATCH] fix bundling issues fixes: #34386 Signed-off-by: Erik Jan de Wit --- .../authentication/AuthenticationSection.tsx | 31 +++++-------------- .../src/authentication/BindFlowDialog.tsx | 7 ++--- .../src/authentication/components/UsedBy.tsx | 6 ++-- .../admin-ui/src/authentication/constants.ts | 19 ++++++++++++ .../components/routable-tabs/RoutableTabs.tsx | 2 +- js/apps/admin-ui/src/page/Page.tsx | 2 +- js/apps/admin-ui/src/page/PageHandler.tsx | 2 +- js/apps/admin-ui/src/page/PageList.tsx | 12 +++---- js/apps/admin-ui/src/page/constants.ts | 2 ++ js/apps/admin-ui/vite.config.ts | 1 + 10 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 js/apps/admin-ui/src/authentication/constants.ts create mode 100644 js/apps/admin-ui/src/page/constants.ts diff --git a/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx b/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx index a60a7afa6b37..55e977debb1a 100644 --- a/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx +++ b/js/apps/admin-ui/src/authentication/AuthenticationSection.tsx @@ -1,7 +1,10 @@ import { fetchWithError } from "@keycloak/keycloak-admin-client"; -import type AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation"; -import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; -import { useAlerts } from "@keycloak/keycloak-ui-shared"; +import { + KeycloakDataTable, + KeycloakSpinner, + ListEmptyState, + useAlerts, +} from "@keycloak/keycloak-ui-shared"; import { AlertVariant, Button, @@ -16,16 +19,12 @@ import { sortBy } from "lodash-es"; import { useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; - import { useAdminClient } from "../admin-client"; import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; -import { KeycloakSpinner } from "@keycloak/keycloak-ui-shared"; -import { ListEmptyState } from "@keycloak/keycloak-ui-shared"; import { RoutableTabs, useRoutableTab, } from "../components/routable-tabs/RoutableTabs"; -import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared"; import { ViewHeader } from "../components/view-header/ViewHeader"; import { useRealm } from "../context/realm-context/RealmContext"; import helpUrls from "../help-urls"; @@ -37,28 +36,12 @@ import { BindFlowDialog } from "./BindFlowDialog"; import { DuplicateFlowModal } from "./DuplicateFlowModal"; import { RequiredActions } from "./RequiredActions"; import { UsedBy } from "./components/UsedBy"; +import { AuthenticationType } from "./constants"; import { Policies } from "./policies/Policies"; import { AuthenticationTab, toAuthentication } from "./routes/Authentication"; import { toCreateFlow } from "./routes/CreateFlow"; import { toFlow } from "./routes/Flow"; -type UsedBy = "SPECIFIC_CLIENTS" | "SPECIFIC_PROVIDERS" | "DEFAULT"; - -export type AuthenticationType = AuthenticationFlowRepresentation & { - usedBy?: { type?: UsedBy; values: string[] }; - realm: RealmRepresentation; -}; - -export const REALM_FLOWS = new Map([ - ["browserFlow", "browser"], - ["registrationFlow", "registration"], - ["directGrantFlow", "direct grant"], - ["resetCredentialsFlow", "reset credentials"], - ["clientAuthenticationFlow", "clients"], - ["dockerAuthenticationFlow", "docker auth"], - ["firstBrokerLoginFlow", "firstBrokerLogin"], -]); - const AliasRenderer = ({ id, alias, usedBy, builtIn }: AuthenticationType) => { const { t } = useTranslation(); const { realm } = useRealm(); diff --git a/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx b/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx index 0193d2e5106a..e8fb92231793 100644 --- a/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx +++ b/js/apps/admin-ui/src/authentication/BindFlowDialog.tsx @@ -1,4 +1,5 @@ import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; +import { SelectControl, useAlerts } from "@keycloak/keycloak-ui-shared"; import { AlertVariant, Button, @@ -8,11 +9,9 @@ import { } from "@patternfly/react-core"; import { FormProvider, useForm } from "react-hook-form"; import { useTranslation } from "react-i18next"; -import { SelectControl } from "@keycloak/keycloak-ui-shared"; -import { useAlerts } from "@keycloak/keycloak-ui-shared"; -import { useRealm } from "../context/realm-context/RealmContext"; -import { REALM_FLOWS } from "./AuthenticationSection"; import { useAdminClient } from "../admin-client"; +import { useRealm } from "../context/realm-context/RealmContext"; +import { REALM_FLOWS } from "./constants"; type BindingForm = { bindingType: keyof RealmRepresentation; diff --git a/js/apps/admin-ui/src/authentication/components/UsedBy.tsx b/js/apps/admin-ui/src/authentication/components/UsedBy.tsx index 3f50d2714c27..9cc4320a3ad8 100644 --- a/js/apps/admin-ui/src/authentication/components/UsedBy.tsx +++ b/js/apps/admin-ui/src/authentication/components/UsedBy.tsx @@ -1,3 +1,4 @@ +import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared"; import { Button, Modal, @@ -11,12 +12,11 @@ import { CheckCircleIcon } from "@patternfly/react-icons"; import { useTranslation } from "react-i18next"; import { useAdminClient } from "../../admin-client"; import { fetchUsedBy } from "../../components/role-mapping/resource"; -import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared"; +import { useRealm } from "../../context/realm-context/RealmContext"; import useToggle from "../../utils/useToggle"; -import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection"; +import { AuthenticationType, REALM_FLOWS } from "../constants"; import style from "./used-by.module.css"; -import { useRealm } from "../../context/realm-context/RealmContext"; type UsedByProps = { authType: AuthenticationType; diff --git a/js/apps/admin-ui/src/authentication/constants.ts b/js/apps/admin-ui/src/authentication/constants.ts new file mode 100644 index 000000000000..eb5461a3dc73 --- /dev/null +++ b/js/apps/admin-ui/src/authentication/constants.ts @@ -0,0 +1,19 @@ +import AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation"; +import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; + +type UsedBy = "SPECIFIC_CLIENTS" | "SPECIFIC_PROVIDERS" | "DEFAULT"; + +export type AuthenticationType = AuthenticationFlowRepresentation & { + usedBy?: { type?: UsedBy; values: string[] }; + realm: RealmRepresentation; +}; + +export const REALM_FLOWS = new Map([ + ["browserFlow", "browser"], + ["registrationFlow", "registration"], + ["directGrantFlow", "direct grant"], + ["resetCredentialsFlow", "reset credentials"], + ["clientAuthenticationFlow", "clients"], + ["dockerAuthenticationFlow", "docker auth"], + ["firstBrokerLoginFlow", "firstBrokerLogin"], +]); diff --git a/js/apps/admin-ui/src/components/routable-tabs/RoutableTabs.tsx b/js/apps/admin-ui/src/components/routable-tabs/RoutableTabs.tsx index 9735936427e5..00f899959080 100644 --- a/js/apps/admin-ui/src/components/routable-tabs/RoutableTabs.tsx +++ b/js/apps/admin-ui/src/components/routable-tabs/RoutableTabs.tsx @@ -22,7 +22,7 @@ import { } from "react-router-dom"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { PageHandler } from "../../page/PageHandler"; -import { TAB_PROVIDER } from "../../page/PageList"; +import { TAB_PROVIDER } from "../../page/constants"; import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled"; import { useTranslation } from "react-i18next"; diff --git a/js/apps/admin-ui/src/page/Page.tsx b/js/apps/admin-ui/src/page/Page.tsx index f81a09031f85..66775f494d82 100644 --- a/js/apps/admin-ui/src/page/Page.tsx +++ b/js/apps/admin-ui/src/page/Page.tsx @@ -11,7 +11,7 @@ import { ViewHeader } from "../components/view-header/ViewHeader"; import { useRealm } from "../context/realm-context/RealmContext"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { PageHandler } from "./PageHandler"; -import { PAGE_PROVIDER } from "./PageList"; +import { PAGE_PROVIDER } from "./constants"; import { PageParams, toPage } from "./routes"; export default function Page() { diff --git a/js/apps/admin-ui/src/page/PageHandler.tsx b/js/apps/admin-ui/src/page/PageHandler.tsx index 6aa7b176e3be..a7277f0fbbdc 100644 --- a/js/apps/admin-ui/src/page/PageHandler.tsx +++ b/js/apps/admin-ui/src/page/PageHandler.tsx @@ -10,7 +10,7 @@ import { useAdminClient } from "../admin-client"; import { DynamicComponents } from "../components/dynamic/DynamicComponents"; import { useRealm } from "../context/realm-context/RealmContext"; import { useParams } from "../utils/useParams"; -import { type PAGE_PROVIDER, TAB_PROVIDER } from "./PageList"; +import { type PAGE_PROVIDER, TAB_PROVIDER } from "./constants"; import { toPage } from "./routes"; type PageHandlerProps = { diff --git a/js/apps/admin-ui/src/page/PageList.tsx b/js/apps/admin-ui/src/page/PageList.tsx index e9b42ea157e4..22634d4b5405 100644 --- a/js/apps/admin-ui/src/page/PageList.tsx +++ b/js/apps/admin-ui/src/page/PageList.tsx @@ -1,6 +1,10 @@ import ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation"; import type { ComponentQuery } from "@keycloak/keycloak-admin-client/lib/resources/components"; -import { useAlerts } from "@keycloak/keycloak-ui-shared"; +import { + KeycloakDataTable, + ListEmptyState, + useAlerts, +} from "@keycloak/keycloak-ui-shared"; import { Button, ButtonVariant, @@ -14,16 +18,12 @@ import { useTranslation } from "react-i18next"; import { Link, useNavigate, useParams } from "react-router-dom"; import { useAdminClient } from "../admin-client"; import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; -import { ListEmptyState } from "@keycloak/keycloak-ui-shared"; -import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared"; import { ViewHeader } from "../components/view-header/ViewHeader"; import { useRealm } from "../context/realm-context/RealmContext"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; +import { PAGE_PROVIDER } from "./constants"; import { addDetailPage, PageListParams, toDetailPage } from "./routes"; -export const PAGE_PROVIDER = "org.keycloak.services.ui.extend.UiPageProvider"; -export const TAB_PROVIDER = "org.keycloak.services.ui.extend.UiTabProvider"; - type DetailLinkProps = { obj: ComponentRepresentation; field: string; diff --git a/js/apps/admin-ui/src/page/constants.ts b/js/apps/admin-ui/src/page/constants.ts new file mode 100644 index 000000000000..68749d7cc3b1 --- /dev/null +++ b/js/apps/admin-ui/src/page/constants.ts @@ -0,0 +1,2 @@ +export const PAGE_PROVIDER = "org.keycloak.services.ui.extend.UiPageProvider"; +export const TAB_PROVIDER = "org.keycloak.services.ui.extend.UiTabProvider"; diff --git a/js/apps/admin-ui/vite.config.ts b/js/apps/admin-ui/vite.config.ts index b039718021bb..50d33fa5a638 100644 --- a/js/apps/admin-ui/vite.config.ts +++ b/js/apps/admin-ui/vite.config.ts @@ -25,6 +25,7 @@ export default defineConfig(({ mode }) => { } : { outDir: "target/classes/theme/keycloak.v2/admin/resources", + external: ["src/index.ts"], }; return { base: "",