2021-01-15 01:44:16 +00:00
|
|
|
import {
|
|
|
|
Brand,
|
|
|
|
Card,
|
|
|
|
CardBody,
|
|
|
|
CardTitle,
|
|
|
|
DescriptionList,
|
|
|
|
DescriptionListDescription,
|
|
|
|
DescriptionListGroup,
|
|
|
|
DescriptionListTerm,
|
|
|
|
EmptyState,
|
|
|
|
EmptyStateBody,
|
|
|
|
Grid,
|
|
|
|
GridItem,
|
|
|
|
Label,
|
|
|
|
List,
|
|
|
|
ListItem,
|
|
|
|
ListVariant,
|
|
|
|
PageSection,
|
|
|
|
Text,
|
|
|
|
TextContent,
|
|
|
|
Title,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
import React from "react";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import _ from "lodash";
|
|
|
|
|
|
|
|
import { useRealm } from "../context/realm-context/RealmContext";
|
|
|
|
import { useServerInfo } from "../context/server-info/ServerInfoProvider";
|
|
|
|
|
|
|
|
import "./dashboard.css";
|
2021-07-15 09:50:01 +00:00
|
|
|
import { toUpperCase } from "../util";
|
2021-01-31 17:58:16 +00:00
|
|
|
import { HelpItem } from "../components/help-enabler/HelpItem";
|
2021-07-15 09:50:01 +00:00
|
|
|
import environment from "../environment";
|
2021-01-15 01:44:16 +00:00
|
|
|
|
|
|
|
const EmptyDashboard = () => {
|
|
|
|
const { t } = useTranslation("dashboard");
|
2021-07-14 15:35:49 +00:00
|
|
|
const { realm } = useRealm();
|
2021-01-15 01:44:16 +00:00
|
|
|
return (
|
|
|
|
<PageSection variant="light">
|
|
|
|
<EmptyState variant="large">
|
|
|
|
<Brand
|
2021-07-15 09:50:01 +00:00
|
|
|
src={environment.resourceUrl + "/icon.svg"}
|
2021-01-15 01:44:16 +00:00
|
|
|
alt="Keycloak icon"
|
|
|
|
className="keycloak__dashboard_icon"
|
|
|
|
/>
|
|
|
|
<Title headingLevel="h4" size="3xl">
|
|
|
|
{t("welcome")}
|
|
|
|
</Title>
|
|
|
|
<Title headingLevel="h4" size="4xl">
|
|
|
|
{realm}
|
|
|
|
</Title>
|
|
|
|
<EmptyStateBody>{t("introduction")}</EmptyStateBody>
|
|
|
|
</EmptyState>
|
|
|
|
</PageSection>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const Dashboard = () => {
|
|
|
|
const { t } = useTranslation("dashboard");
|
|
|
|
const { realm } = useRealm();
|
|
|
|
const serverInfo = useServerInfo();
|
|
|
|
|
|
|
|
const enabledFeatures = _.xor(
|
|
|
|
serverInfo.profileInfo?.disabledFeatures,
|
|
|
|
serverInfo.profileInfo?.experimentalFeatures,
|
|
|
|
serverInfo.profileInfo?.previewFeatures
|
|
|
|
);
|
|
|
|
|
|
|
|
const isExperimentalFeature = (feature: string) => {
|
|
|
|
return serverInfo.profileInfo?.experimentalFeatures?.includes(feature);
|
|
|
|
};
|
|
|
|
|
|
|
|
const isPreviewFeature = (feature: string) => {
|
|
|
|
return serverInfo.profileInfo?.previewFeatures?.includes(feature);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PageSection variant="light">
|
|
|
|
<TextContent className="pf-u-mr-sm">
|
|
|
|
<Text component="h1">{toUpperCase(realm)} realm</Text>
|
|
|
|
</TextContent>
|
|
|
|
</PageSection>
|
|
|
|
<PageSection>
|
|
|
|
<Grid hasGutter>
|
2021-02-08 20:35:38 +00:00
|
|
|
<GridItem lg={2} sm={12}>
|
2021-01-15 01:44:16 +00:00
|
|
|
<Card className="keycloak__dashboard_card">
|
|
|
|
<CardTitle>{t("serverInfo")}</CardTitle>
|
|
|
|
<CardBody>
|
|
|
|
<DescriptionList>
|
|
|
|
<DescriptionListGroup>
|
|
|
|
<DescriptionListTerm>{t("version")}</DescriptionListTerm>
|
|
|
|
<DescriptionListDescription>
|
|
|
|
{serverInfo.systemInfo?.version}
|
|
|
|
</DescriptionListDescription>
|
|
|
|
<DescriptionListTerm>{t("product")}</DescriptionListTerm>
|
|
|
|
<DescriptionListDescription>
|
2021-01-31 17:58:16 +00:00
|
|
|
{toUpperCase(serverInfo.profileInfo?.name!)}
|
2021-01-15 01:44:16 +00:00
|
|
|
</DescriptionListDescription>
|
|
|
|
</DescriptionListGroup>
|
|
|
|
</DescriptionList>
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
</GridItem>
|
2021-02-08 20:35:38 +00:00
|
|
|
<GridItem lg={10} sm={12}>
|
2021-01-15 01:44:16 +00:00
|
|
|
<Card className="keycloak__dashboard_card">
|
|
|
|
<CardTitle>{t("profile")}</CardTitle>
|
|
|
|
<CardBody>
|
|
|
|
<DescriptionList>
|
|
|
|
<DescriptionListGroup>
|
|
|
|
<DescriptionListTerm>
|
2021-01-31 17:58:16 +00:00
|
|
|
{t("enabledFeatures")}{" "}
|
|
|
|
<HelpItem
|
2021-07-09 16:15:21 +00:00
|
|
|
forID={t(`common:helpLabel`, {
|
|
|
|
label: t("enabledFeatures"),
|
|
|
|
})}
|
2021-01-31 17:58:16 +00:00
|
|
|
forLabel={t("enabledFeatures")}
|
|
|
|
helpText="dashboard:infoEnabledFeatures"
|
|
|
|
/>
|
2021-01-15 01:44:16 +00:00
|
|
|
</DescriptionListTerm>
|
|
|
|
<DescriptionListDescription>
|
|
|
|
<List variant={ListVariant.inline}>
|
|
|
|
{enabledFeatures.map((feature) => (
|
|
|
|
<ListItem key={feature}>
|
|
|
|
{feature}{" "}
|
|
|
|
{isExperimentalFeature(feature) ? (
|
|
|
|
<Label color="orange">{t("experimental")}</Label>
|
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
{isPreviewFeature(feature) ? (
|
2021-01-31 17:58:16 +00:00
|
|
|
<Label color="blue">{t("preview")}</Label>
|
2021-01-15 01:44:16 +00:00
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
</ListItem>
|
|
|
|
))}
|
|
|
|
</List>
|
|
|
|
</DescriptionListDescription>
|
|
|
|
</DescriptionListGroup>
|
|
|
|
<DescriptionListGroup>
|
|
|
|
<DescriptionListTerm>
|
2021-01-31 17:58:16 +00:00
|
|
|
{t("disabledFeatures")}{" "}
|
|
|
|
<HelpItem
|
2021-07-09 16:15:21 +00:00
|
|
|
forID={t(`common:helpLabel`, {
|
|
|
|
label: t("disabledFeatures"),
|
|
|
|
})}
|
2021-01-31 17:58:16 +00:00
|
|
|
forLabel={t("disabledFeatures")}
|
|
|
|
helpText="dashboard:infoDisabledFeatures"
|
|
|
|
/>
|
2021-01-15 01:44:16 +00:00
|
|
|
</DescriptionListTerm>
|
|
|
|
<DescriptionListDescription>
|
|
|
|
<List variant={ListVariant.inline}>
|
|
|
|
{serverInfo.profileInfo?.disabledFeatures?.map(
|
|
|
|
(feature) => (
|
|
|
|
<ListItem key={feature}>{feature}</ListItem>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</List>
|
|
|
|
</DescriptionListDescription>
|
|
|
|
</DescriptionListGroup>
|
|
|
|
</DescriptionList>
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
</GridItem>
|
|
|
|
</Grid>
|
|
|
|
</PageSection>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DashboardSection = () => {
|
|
|
|
const { realm } = useRealm();
|
|
|
|
const isMasterRealm = realm === "master";
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{!isMasterRealm && <EmptyDashboard />}
|
|
|
|
{isMasterRealm && <Dashboard />}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|