Initial version without filter (#2518)

This commit is contained in:
Erik Jan de Wit 2022-04-28 15:36:43 +02:00 committed by GitHub
parent ebf56dacc0
commit 60a81c8e86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 176 additions and 87 deletions

View file

@ -12,5 +12,9 @@
"infoEnabledFeatures": "Something about what enabled features are.", "infoEnabledFeatures": "Something about what enabled features are.",
"infoDisabledFeatures": "Something about what disabled features are.", "infoDisabledFeatures": "Something about what disabled features are.",
"disabledFeatures": "Disabled features", "disabledFeatures": "Disabled features",
"adminUiVersion": "<0 className=\"pf-u-mr-md\">Admin UI version</0>{{version}}" "adminUiVersion": "<0 className=\"pf-u-mr-md\">Admin UI version</0>{{version}}",
"providerInfo": "Provider info",
"providers": "Providers",
"realmInfo": "Realm info",
"spi": "SPI"
} }

View file

@ -1,3 +1,7 @@
import React from "react";
import { useHistory } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import { xor } from "lodash-es";
import { import {
Brand, Brand,
Card, Card,
@ -16,22 +20,34 @@ import {
ListItem, ListItem,
ListVariant, ListVariant,
PageSection, PageSection,
Tab,
TabTitleText,
Text, Text,
TextContent, TextContent,
Title, Title,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import React from "react"; import {
import { Trans, useTranslation } from "react-i18next"; TableComposable,
import { xor } from "lodash-es"; Tbody,
Td,
Th,
Thead,
Tr,
} from "@patternfly/react-table";
import { useRealm } from "../context/realm-context/RealmContext"; import { useRealm } from "../context/realm-context/RealmContext";
import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { useServerInfo } from "../context/server-info/ServerInfoProvider";
import { toUpperCase } from "../util"; import { toUpperCase } from "../util";
import { HelpItem } from "../components/help-enabler/HelpItem"; import { HelpItem } from "../components/help-enabler/HelpItem";
import environment from "../environment"; 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"; import "./dashboard.css";
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
const EmptyDashboard = () => { const EmptyDashboard = () => {
const { t } = useTranslation("dashboard"); const { t } = useTranslation("dashboard");
@ -60,6 +76,7 @@ const Dashboard = () => {
const { t } = useTranslation("dashboard"); const { t } = useTranslation("dashboard");
const { realm } = useRealm(); const { realm } = useRealm();
const serverInfo = useServerInfo(); const serverInfo = useServerInfo();
const history = useHistory();
const enabledFeatures = xor( const enabledFeatures = xor(
serverInfo.profileInfo?.disabledFeatures, serverInfo.profileInfo?.disabledFeatures,
@ -67,18 +84,25 @@ const Dashboard = () => {
serverInfo.profileInfo?.previewFeatures serverInfo.profileInfo?.previewFeatures
); );
const isExperimentalFeature = (feature: string) => { const isExperimentalFeature = (feature: string) =>
return serverInfo.profileInfo?.experimentalFeatures?.includes(feature); serverInfo.profileInfo?.experimentalFeatures?.includes(feature);
};
const isPreviewFeature = (feature: string) => { const isPreviewFeature = (feature: string) =>
return serverInfo.profileInfo?.previewFeatures?.includes(feature); serverInfo.profileInfo?.previewFeatures?.includes(feature);
};
if (Object.keys(serverInfo).length === 0) { if (Object.keys(serverInfo).length === 0) {
return <KeycloakSpinner />; return <KeycloakSpinner />;
} }
const route = (tab: DashboardTab) =>
routableTab({
to: toDashboard({
realm,
tab,
}),
history,
});
return ( return (
<> <>
<PageSection variant="light"> <PageSection variant="light">
@ -94,7 +118,23 @@ const Dashboard = () => {
</Text> </Text>
</TextContent> </TextContent>
</PageSection> </PageSection>
<PageSection> <PageSection variant="light" className="pf-u-p-0">
<RoutableTabs
data-testid="dashboard-tabs"
defaultLocation={toDashboard({
realm,
tab: "info",
})}
isBox
mountOnEnter
>
<Tab
id="info"
data-testid="infoTab"
title={<TabTitleText>{t("realmInfo")}</TabTitleText>}
{...route("info")}
>
<PageSection variant="light">
<Grid hasGutter> <Grid hasGutter>
<GridItem lg={2} sm={12}> <GridItem lg={2} sm={12}>
<Card className="keycloak__dashboard_card"> <Card className="keycloak__dashboard_card">
@ -102,11 +142,15 @@ const Dashboard = () => {
<CardBody> <CardBody>
<DescriptionList> <DescriptionList>
<DescriptionListGroup> <DescriptionListGroup>
<DescriptionListTerm>{t("version")}</DescriptionListTerm> <DescriptionListTerm>
{t("version")}
</DescriptionListTerm>
<DescriptionListDescription> <DescriptionListDescription>
{serverInfo.systemInfo?.version} {serverInfo.systemInfo?.version}
</DescriptionListDescription> </DescriptionListDescription>
<DescriptionListTerm>{t("product")}</DescriptionListTerm> <DescriptionListTerm>
{t("product")}
</DescriptionListTerm>
<DescriptionListDescription> <DescriptionListDescription>
{toUpperCase(serverInfo.profileInfo?.name!)} {toUpperCase(serverInfo.profileInfo?.name!)}
</DescriptionListDescription> </DescriptionListDescription>
@ -134,7 +178,9 @@ const Dashboard = () => {
<ListItem key={feature}> <ListItem key={feature}>
{feature}{" "} {feature}{" "}
{isExperimentalFeature(feature) ? ( {isExperimentalFeature(feature) ? (
<Label color="orange">{t("experimental")}</Label> <Label color="orange">
{t("experimental")}
</Label>
) : null} ) : null}
{isPreviewFeature(feature) ? ( {isPreviewFeature(feature) ? (
<Label color="blue">{t("preview")}</Label> <Label color="blue">{t("preview")}</Label>
@ -168,6 +214,43 @@ const Dashboard = () => {
</GridItem> </GridItem>
</Grid> </Grid>
</PageSection> </PageSection>
</Tab>
<Tab
id="providers"
data-testid="providersTab"
title={<TabTitleText>{t("providerInfo")}</TabTitleText>}
{...route("providers")}
>
<PageSection variant="light">
<TableComposable variant="compact">
<Thead>
<Tr>
<Th width={20}>{t("spi")}</Th>
<Th>{t("providers")}</Th>
</Tr>
</Thead>
<Tbody>
{Object.keys(serverInfo.providers || []).map((name) => (
<Tr key={name}>
<Td>{name}</Td>
<Td>
<ul>
{Object.keys(
serverInfo.providers?.[name].providers || []
).map((value) => (
<li key={value}>{value}</li>
))}
</ul>
</Td>
</Tr>
))}
</Tbody>
</TableComposable>
<ul></ul>
</PageSection>
</Tab>
</RoutableTabs>
</PageSection>
</> </>
); );
}; };

View file

@ -3,10 +3,12 @@ import { lazy } from "react";
import { generatePath } from "react-router-dom"; import { generatePath } from "react-router-dom";
import type { RouteDef } from "../../route-config"; import type { RouteDef } from "../../route-config";
export type DashboardParams = { realm?: string }; export type DashboardTab = "info" | "providers";
export type DashboardParams = { realm?: string; tab?: DashboardTab };
export const DashboardRoute: RouteDef = { export const DashboardRoute: RouteDef = {
path: "/:realm?", path: "/:realm?/:tab?",
component: lazy(() => import("../Dashboard")), component: lazy(() => import("../Dashboard")),
breadcrumb: (t) => t("common:home"), breadcrumb: (t) => t("common:home"),
access: "anyone", access: "anyone",

View file

@ -43,7 +43,7 @@ export const routes: RouteDef[] = [
...sessionRoutes, ...sessionRoutes,
...userFederationRoutes, ...userFederationRoutes,
...userRoutes, ...userRoutes,
...dashboardRoutes,
...groupsRoutes, ...groupsRoutes,
...dashboardRoutes,
NotFoundRoute, NotFoundRoute,
]; ];