import React from "react"; import { useHistory } from "react-router-dom"; import { Trans, useTranslation } from "react-i18next"; import { xor } from "lodash-es"; import { Brand, Card, CardBody, CardTitle, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, EmptyState, EmptyStateBody, Grid, GridItem, Label, List, ListItem, ListVariant, PageSection, Tab, TabTitleText, Text, TextContent, Title, } from "@patternfly/react-core"; import { TableComposable, Tbody, Td, Th, Thead, Tr, } from "@patternfly/react-table"; import { useRealm } from "../context/realm-context/RealmContext"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { toUpperCase } from "../util"; import { HelpItem } from "../components/help-enabler/HelpItem"; import environment from "../environment"; import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner"; import { routableTab, RoutableTabs, } from "../components/routable-tabs/RoutableTabs"; import { DashboardTab, toDashboard } from "./routes/Dashboard"; import "./dashboard.css"; const EmptyDashboard = () => { const { t } = useTranslation("dashboard"); const { realm } = useRealm(); return ( {t("welcome")} {realm} {t("introduction")} ); }; const Dashboard = () => { const { t } = useTranslation("dashboard"); const { realm } = useRealm(); const serverInfo = useServerInfo(); const history = useHistory(); const enabledFeatures = xor( serverInfo.profileInfo?.disabledFeatures, serverInfo.profileInfo?.experimentalFeatures, serverInfo.profileInfo?.previewFeatures ); const isExperimentalFeature = (feature: string) => serverInfo.profileInfo?.experimentalFeatures?.includes(feature); const isPreviewFeature = (feature: string) => serverInfo.profileInfo?.previewFeatures?.includes(feature); if (Object.keys(serverInfo).length === 0) { return ; } const route = (tab: DashboardTab) => routableTab({ to: toDashboard({ realm, tab, }), history, }); return ( <> {t("realmName", { name: toUpperCase(realm) })} Admin UI version {{ version: environment.commitHash }} {t("realmInfo")}} {...route("info")} > {t("serverInfo")} {t("version")} {serverInfo.systemInfo?.version} {t("product")} {toUpperCase(serverInfo.profileInfo?.name!)} {t("profile")} {t("enabledFeatures")}{" "} {enabledFeatures.map((feature) => ( {feature}{" "} {isExperimentalFeature(feature) ? ( ) : null} {isPreviewFeature(feature) ? ( ) : null} ))} {t("disabledFeatures")}{" "} {serverInfo.profileInfo?.disabledFeatures?.map( (feature) => ( {feature} ) )} {t("providerInfo")}} {...route("providers")} > {t("spi")} {t("providers")} {Object.keys(serverInfo.providers || []).map((name) => ( {name}
    {Object.keys( serverInfo.providers?.[name].providers || [] ).map((value) => (
  • {value}
  • ))}
))}
    ); }; export default function DashboardSection() { const { realm } = useRealm(); const isMasterRealm = realm === "master"; return ( <> {!isMasterRealm && } {isMasterRealm && } ); }