Enabled and Disable features incorrect (#3054)

This commit is contained in:
Martin Bartoš 2022-08-08 06:59:00 -04:00 committed by GitHub
parent 4106b9de3f
commit f8a933fcd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 22 deletions

View file

@ -9,8 +9,9 @@
"enabledFeatures": "Enabled features", "enabledFeatures": "Enabled features",
"experimental": "Experimental", "experimental": "Experimental",
"preview": "Preview", "preview": "Preview",
"infoEnabledFeatures": "Something about what enabled features are.", "supported": "Supported",
"infoDisabledFeatures": "Something about what disabled features are.", "infoEnabledFeatures": "Shows enabled preview and experimental features.",
"infoDisabledFeatures": "Shows all disabled features.",
"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", "providerInfo": "Provider info",

View file

@ -1,7 +1,7 @@
import { useMemo } from "react"; import { useMemo } from "react";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { xor } from "lodash-es"; import { union, filter } from "lodash-es";
import { import {
Brand, Brand,
Card, Card,
@ -73,18 +73,17 @@ const Dashboard = () => {
const history = useHistory(); const history = useHistory();
const localeSort = useLocaleSort(); const localeSort = useLocaleSort();
const enabledFeatures = useMemo( const isDeprecatedFeature = (feature: string) =>
() => disabledFeatures.includes(feature);
localeSort(
xor( const isExperimentalFeature = (feature: string) =>
serverInfo.profileInfo?.disabledFeatures, serverInfo.profileInfo?.experimentalFeatures?.includes(feature);
serverInfo.profileInfo?.experimentalFeatures,
serverInfo.profileInfo?.previewFeatures const isPreviewFeature = (feature: string) =>
), serverInfo.profileInfo?.previewFeatures?.includes(feature);
(item) => item
), const isSupportedFeature = (feature: string) =>
[serverInfo.profileInfo] !isExperimentalFeature(feature) && !isPreviewFeature(feature);
);
const disabledFeatures = useMemo( const disabledFeatures = useMemo(
() => () =>
@ -95,11 +94,22 @@ const Dashboard = () => {
[serverInfo.profileInfo] [serverInfo.profileInfo]
); );
const isExperimentalFeature = (feature: string) => const enabledFeatures = useMemo(
serverInfo.profileInfo?.experimentalFeatures?.includes(feature); () =>
localeSort(
const isPreviewFeature = (feature: string) => filter(
serverInfo.profileInfo?.previewFeatures?.includes(feature); union(
serverInfo.profileInfo?.experimentalFeatures,
serverInfo.profileInfo?.previewFeatures
),
(feature) => {
return !isDeprecatedFeature(feature);
}
),
(item) => item
),
[serverInfo.profileInfo]
);
if (Object.keys(serverInfo).length === 0) { if (Object.keys(serverInfo).length === 0) {
return <KeycloakSpinner />; return <KeycloakSpinner />;
@ -186,7 +196,7 @@ const Dashboard = () => {
<DescriptionListDescription> <DescriptionListDescription>
<List variant={ListVariant.inline}> <List variant={ListVariant.inline}>
{enabledFeatures.map((feature) => ( {enabledFeatures.map((feature) => (
<ListItem key={feature}> <ListItem key={feature} className="pf-u-mb-sm">
{feature}{" "} {feature}{" "}
{isExperimentalFeature(feature) ? ( {isExperimentalFeature(feature) ? (
<Label color="orange"> <Label color="orange">
@ -212,7 +222,22 @@ const Dashboard = () => {
<DescriptionListDescription> <DescriptionListDescription>
<List variant={ListVariant.inline}> <List variant={ListVariant.inline}>
{disabledFeatures.map((feature) => ( {disabledFeatures.map((feature) => (
<ListItem key={feature}>{feature}</ListItem> <ListItem key={feature} className="pf-u-mb-sm">
{feature}{" "}
{isExperimentalFeature(feature) ? (
<Label color="orange">
{t("experimental")}
</Label>
) : null}
{isPreviewFeature(feature) ? (
<Label color="blue">{t("preview")}</Label>
) : null}
{isSupportedFeature(feature) ? (
<Label color="green">
{t("supported")}
</Label>
) : null}
</ListItem>
))} ))}
</List> </List>
</DescriptionListDescription> </DescriptionListDescription>