Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only render when ui when feature is enabled #29101

Merged
merged 1 commit into from Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions js/apps/admin-ui/src/PageNav.tsx
Expand Up @@ -19,6 +19,7 @@ import { AddRealmRoute } from "./realm/routes/AddRealm";
import { routes } from "./routes";

import "./page-nav.css";
import useIsFeatureEnabled, { Feature } from "./utils/useIsFeatureEnabled";

type LeftNavProps = { title: string; path: string; id?: string };

Expand Down Expand Up @@ -61,9 +62,9 @@ export const PageNav = () => {
const { t } = useTranslation();
const { hasSomeAccess } = useAccess();
const { componentTypes } = useServerInfo();
const isFeatureEnabled = useIsFeatureEnabled();
const pages =
componentTypes?.["org.keycloak.services.ui.extend.UiPageProvider"];

const navigate = useNavigate();

type SelectedItem = {
Expand Down Expand Up @@ -122,14 +123,15 @@ export const PageNav = () => {
<LeftNav title="authentication" path="/authentication" />
<LeftNav title="identityProviders" path="/identity-providers" />
<LeftNav title="userFederation" path="/user-federation" />
{pages?.map((p) => (
<LeftNav
key={p.id}
title={p.id}
path={toPage({ providerId: p.id }).pathname!}
id="/page-section"
/>
))}
{isFeatureEnabled(Feature.DeclarativeUI) &&
pages?.map((p) => (
<LeftNav
key={p.id}
title={p.id}
path={toPage({ providerId: p.id }).pathname!}
id="/page-section"
/>
))}
</NavGroup>
)}
</Nav>
Expand Down
13 changes: 8 additions & 5 deletions js/apps/admin-ui/src/components/routable-tabs/RoutableTabs.tsx
Expand Up @@ -23,6 +23,7 @@ import {
import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
import { PageHandler } from "../../page/PageHandler";
import { TAB_PROVIDER } from "../../page/PageList";
import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled";

// TODO: Remove the custom 'children' props and type once the following issue has been resolved:
// https://github.com/patternfly/patternfly-react/issues/6766
Expand All @@ -47,6 +48,7 @@ export const RoutableTabs = ({
const params = useParams();
const { componentTypes } = useServerInfo();
const tabs = componentTypes?.[TAB_PROVIDER] || [];
const isFeatureEnabled = useIsFeatureEnabled();

const matchedTabs = tabs
.filter((tab) => matchPath({ path: tab.metadata.path }, pathname))
Expand Down Expand Up @@ -92,11 +94,12 @@ export const RoutableTabs = ({
{...otherProps}
>
{children as any}
{matchedTabs.map<any>((t) => (
<DynamicTab key={t.id} eventKey={t.pathname} title={t.id}>
<PageHandler page={t} providerType={TAB_PROVIDER} />
</DynamicTab>
))}
{isFeatureEnabled(Feature.DeclarativeUI) &&
matchedTabs.map<any>((t) => (
<DynamicTab key={t.id} eventKey={t.pathname} title={t.id}>
<PageHandler page={t} providerType={TAB_PROVIDER} />
</DynamicTab>
))}
</Tabs>
);
};
Expand Down
1 change: 1 addition & 0 deletions js/apps/admin-ui/src/utils/useIsFeatureEnabled.ts
Expand Up @@ -9,6 +9,7 @@ export enum Feature {
DeviceFlow = "DEVICE_FLOW",
TransientUsers = "TRANSIENT_USERS",
ClientTypes = "CLIENT_TYPES",
DeclarativeUI = "DECLARATIVE_UI",
}

export default function useIsFeatureEnabled() {
Expand Down