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,6 +41,7 @@ export const UsersInRoleTab = () => {
ariaLabelKey="roles:roleList" ariaLabelKey="roles:roleList"
searchPlaceholderKey="" searchPlaceholderKey=""
toolbarItem={ toolbarItem={
enabled && (
<Popover <Popover
aria-label="Basic popover" aria-label="Basic popover"
position="bottom" position="bottom"
@ -72,6 +76,7 @@ export const UsersInRoleTab = () => {
{t("roles:whoWillAppearLinkText")} {t("roles:whoWillAppearLinkText")}
</Button> </Button>
</Popover> </Popover>
)
} }
emptyState={ emptyState={
<ListEmptyState <ListEmptyState