hide popover link when help enabled

This commit is contained in:
jenny-s51 2021-03-02 11:11:08 -05:00
parent 74638f9eb3
commit 78a2c76c79
3 changed files with 44 additions and 40 deletions

View file

@ -9,7 +9,7 @@ import {
Switch, Switch,
TextContent, TextContent,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { Trans, useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { HelpIcon, ExternalLinkAltIcon } from "@patternfly/react-icons"; import { HelpIcon, ExternalLinkAltIcon } from "@patternfly/react-icons";
import "./help-header.css"; import "./help-header.css";

View file

@ -53,11 +53,12 @@ export const AssociatedRolesTab = ({
const getSubRoles = async ( const getSubRoles = async (
role: RoleRepresentation, role: RoleRepresentation,
allRoles: RoleRepresentation[], allRoles: RoleRepresentation[]
): Promise<RoleRepresentation[]> => { ): Promise<RoleRepresentation[]> => {
// Fetch all composite roles // Fetch all composite roles
const allCompositeRoles = await adminClient.roles.getCompositeRoles({id: role.id!}); const allCompositeRoles = await adminClient.roles.getCompositeRoles({
id: role.id!,
});
// Need to ensure we don't get into an infinite loop, do not add any role that is already there or the starting role // Need to ensure we don't get into an infinite loop, do not add any role that is already there or the starting role
const newRoles: Promise<RoleRepresentation[]> = allCompositeRoles.reduce( const newRoles: Promise<RoleRepresentation[]> = allCompositeRoles.reduce(
@ -86,8 +87,6 @@ export const AssociatedRolesTab = ({
return additionalRoles; return additionalRoles;
} }
const allRoles: Promise<RoleRepresentation[]> = additionalRoles.reduce( const allRoles: Promise<RoleRepresentation[]> = additionalRoles.reduce(
async (acc: Promise<RoleRepresentation[]>, role) => { async (acc: Promise<RoleRepresentation[]>, role) => {
const resolvedRoles = await acc; const resolvedRoles = await acc;

View file

@ -1,4 +1,4 @@
import React from "react"; import React, { useContext } from "react";
import { useHistory, useParams } from "react-router-dom"; import { useHistory, useParams } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Button, PageSection, Popover } from "@patternfly/react-core"; import { Button, PageSection, Popover } from "@patternfly/react-core";
@ -8,6 +8,7 @@ import { boolFormatter, emptyFormatter } from "../util";
import { useAdminClient } from "../context/auth/AdminClient"; import { useAdminClient } from "../context/auth/AdminClient";
import { QuestionCircleIcon } from "@patternfly/react-icons"; import { QuestionCircleIcon } from "@patternfly/react-icons";
import { useRealm } from "../context/realm-context/RealmContext"; import { useRealm } from "../context/realm-context/RealmContext";
import { HelpContext } from "../components/help-enabler/HelpHeader";
export const UsersInRoleTab = () => { export const UsersInRoleTab = () => {
const history = useHistory(); const history = useHistory();
@ -29,6 +30,8 @@ export const UsersInRoleTab = () => {
return usersWithRole; return usersWithRole;
}; };
const { enabled } = useContext(HelpContext);
return ( return (
<> <>
<PageSection data-testid="users-page" variant="light"> <PageSection data-testid="users-page" variant="light">
@ -38,40 +41,42 @@ export const UsersInRoleTab = () => {
ariaLabelKey="roles:roleList" ariaLabelKey="roles:roleList"
searchPlaceholderKey="" searchPlaceholderKey=""
toolbarItem={ toolbarItem={
<Popover enabled && (
aria-label="Basic popover" <Popover
position="bottom" aria-label="Basic popover"
bodyContent={ position="bottom"
<div> bodyContent={
{t("roles:whoWillAppearPopoverText")} <div>
<Button {t("roles:whoWillAppearPopoverText")}
className="kc-groups-link" <Button
variant="link" className="kc-groups-link"
onClick={() => history.push(`/${realm}/groups`)} variant="link"
> onClick={() => history.push(`/${realm}/groups`)}
{t("groups")} >
</Button> {t("groups")}
{t("or")} </Button>
<Button {t("or")}
className="kc-users-link" <Button
variant="link" className="kc-users-link"
onClick={() => history.push(`/${realm}/users`)} variant="link"
> onClick={() => history.push(`/${realm}/users`)}
{t("users")}. >
</Button> {t("users")}.
</div> </Button>
} </div>
footerContent={t("roles:whoWillAppearPopoverFooterText")} }
> footerContent={t("roles:whoWillAppearPopoverFooterText")}
<Button
variant="link"
className="kc-who-will-appear-button"
key="who-will-appear-button"
icon={<QuestionCircleIcon />}
> >
{t("roles:whoWillAppearLinkText")} <Button
</Button> variant="link"
</Popover> className="kc-who-will-appear-button"
key="who-will-appear-button"
icon={<QuestionCircleIcon />}
>
{t("roles:whoWillAppearLinkText")}
</Button>
</Popover>
)
} }
emptyState={ emptyState={
<ListEmptyState <ListEmptyState