Skip to content

Commit

Permalink
fix bundling issues
Browse files Browse the repository at this point in the history
fixes: keycloak#34386

Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit committed Oct 28, 2024
1 parent dbc2ab3 commit 4ae51dc
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 40 deletions.
31 changes: 7 additions & 24 deletions js/apps/admin-ui/src/authentication/AuthenticationSection.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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";
Expand All @@ -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<string, string>([
["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();
Expand Down
7 changes: 3 additions & 4 deletions js/apps/admin-ui/src/authentication/BindFlowDialog.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions js/apps/admin-ui/src/authentication/components/UsedBy.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared";
import {
Button,
Modal,
Expand All @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions js/apps/admin-ui/src/authentication/constants.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>([
["browserFlow", "browser"],
["registrationFlow", "registration"],
["directGrantFlow", "direct grant"],
["resetCredentialsFlow", "reset credentials"],
["clientAuthenticationFlow", "clients"],
["dockerAuthenticationFlow", "docker auth"],
["firstBrokerLoginFlow", "firstBrokerLogin"],
]);
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion js/apps/admin-ui/src/page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion js/apps/admin-ui/src/page/PageHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
12 changes: 6 additions & 6 deletions js/apps/admin-ui/src/page/PageList.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions js/apps/admin-ui/src/page/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const PAGE_PROVIDER = "org.keycloak.services.ui.extend.UiPageProvider";
export const TAB_PROVIDER = "org.keycloak.services.ui.extend.UiTabProvider";
1 change: 1 addition & 0 deletions js/apps/admin-ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineConfig(({ mode }) => {
}
: {
outDir: "target/classes/theme/keycloak.v2/admin/resources",
external: ["src/index.ts"],
};
return {
base: "",
Expand Down

0 comments on commit 4ae51dc

Please sign in to comment.