remove use of deprecated components (#28800)
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
6a020d93f1
commit
2c069433f9
3 changed files with 112 additions and 93 deletions
|
@ -11,7 +11,7 @@ export default class Masthead extends CommonElements {
|
||||||
#globalAlerts = "global-alerts";
|
#globalAlerts = "global-alerts";
|
||||||
#documentationLink = "#link";
|
#documentationLink = "#link";
|
||||||
#backToAdminConsoleLink = "referrer-link";
|
#backToAdminConsoleLink = "referrer-link";
|
||||||
#userDrpdwnItem = ".pf-v5-c-dropdown__menu-item";
|
#userDrpdwnItem = ".pf-v5-c-menu__item";
|
||||||
|
|
||||||
#getAlertsContainer() {
|
#getAlertsContainer() {
|
||||||
return cy.findByTestId(this.#globalAlerts);
|
return cy.findByTestId(this.#globalAlerts);
|
||||||
|
|
|
@ -3122,3 +3122,5 @@ parRequestUriLifespanHelp=Number that represents the lifetime of the request URI
|
||||||
identityBrokeringLink=Identity brokering link
|
identityBrokeringLink=Identity brokering link
|
||||||
searchClientRegistration=Search for policy
|
searchClientRegistration=Search for policy
|
||||||
importFileHelp=File to import a key
|
importFileHelp=File to import a key
|
||||||
|
logo=Logo
|
||||||
|
avatarImage=Avatar image
|
|
@ -1,19 +1,23 @@
|
||||||
import { Avatar, Brand } from "@patternfly/react-core";
|
|
||||||
import {
|
import {
|
||||||
|
Avatar,
|
||||||
|
Divider,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
DropdownItem,
|
DropdownItem,
|
||||||
DropdownSeparator,
|
DropdownList,
|
||||||
DropdownToggle,
|
Masthead,
|
||||||
KebabToggle,
|
MastheadBrand,
|
||||||
PageHeader,
|
MastheadContent,
|
||||||
PageHeaderTools,
|
MastheadToggle,
|
||||||
PageHeaderToolsGroup,
|
MenuToggle,
|
||||||
PageHeaderToolsItem,
|
PageToggleButton,
|
||||||
} from "@patternfly/react-core/deprecated";
|
Toolbar,
|
||||||
import { HelpIcon } from "@patternfly/react-icons";
|
ToolbarContent,
|
||||||
import { ReactNode, useState } from "react";
|
ToolbarItem,
|
||||||
|
} from "@patternfly/react-core";
|
||||||
|
import { BarsIcon, EllipsisVIcon, HelpIcon } from "@patternfly/react-icons";
|
||||||
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link } from "react-router-dom";
|
import { Link, useHref } from "react-router-dom";
|
||||||
import { useHelp } from "ui-shared";
|
import { useHelp } from "ui-shared";
|
||||||
|
|
||||||
import { HelpHeader } from "./components/help-enabler/HelpHeader";
|
import { HelpHeader } from "./components/help-enabler/HelpHeader";
|
||||||
|
@ -56,12 +60,7 @@ const ServerInfoDropdownItem = () => {
|
||||||
return (
|
return (
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="server info"
|
key="server info"
|
||||||
component={
|
component={(props) => <Link {...props} to={toDashboard({ realm })} />}
|
||||||
// The type definition in PatternFly is incorrect, so we need to cast here.
|
|
||||||
((props: any) => (
|
|
||||||
<Link {...props} to={toDashboard({ realm })} />
|
|
||||||
)) as unknown as ReactNode
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{t("realmInfo")}
|
{t("realmInfo")}
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
@ -86,14 +85,14 @@ const kebabDropdownItems = [
|
||||||
<ManageAccountDropdownItem key="kebab Manage Account" />,
|
<ManageAccountDropdownItem key="kebab Manage Account" />,
|
||||||
<ServerInfoDropdownItem key="kebab Server Info" />,
|
<ServerInfoDropdownItem key="kebab Server Info" />,
|
||||||
<HelpDropdownItem key="kebab Help" />,
|
<HelpDropdownItem key="kebab Help" />,
|
||||||
<DropdownSeparator key="kebab sign out separator" />,
|
<Divider component="li" key="kebab sign out separator" />,
|
||||||
<SignOutDropdownItem key="kebab Sign out" />,
|
<SignOutDropdownItem key="kebab Sign out" />,
|
||||||
];
|
];
|
||||||
|
|
||||||
const userDropdownItems = [
|
const userDropdownItems = [
|
||||||
<ManageAccountDropdownItem key="Manage Account" />,
|
<ManageAccountDropdownItem key="Manage Account" />,
|
||||||
<ServerInfoDropdownItem key="Server info" />,
|
<ServerInfoDropdownItem key="Server info" />,
|
||||||
<DropdownSeparator key="sign out separator" />,
|
<Divider component="li" key="sign out separator" />,
|
||||||
<SignOutDropdownItem key="Sign out" />,
|
<SignOutDropdownItem key="Sign out" />,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -102,13 +101,23 @@ const KebabDropdown = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
id="user-dropdown-kebab"
|
|
||||||
isPlain
|
isPlain
|
||||||
position="right"
|
onOpenChange={(isOpen) => setDropdownOpen(isOpen)}
|
||||||
toggle={<KebabToggle onToggle={(_event, val) => setDropdownOpen(val)} />}
|
toggle={(ref) => (
|
||||||
|
<MenuToggle
|
||||||
|
id="user-dropdown-kebab"
|
||||||
|
ref={ref}
|
||||||
|
variant="plain"
|
||||||
|
onClick={() => setDropdownOpen(!isDropdownOpen)}
|
||||||
|
isExpanded={isDropdownOpen}
|
||||||
|
>
|
||||||
|
<EllipsisVIcon />
|
||||||
|
</MenuToggle>
|
||||||
|
)}
|
||||||
isOpen={isDropdownOpen}
|
isOpen={isDropdownOpen}
|
||||||
dropdownItems={kebabDropdownItems}
|
>
|
||||||
/>
|
<DropdownList>{kebabDropdownItems}</DropdownList>
|
||||||
|
</Dropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,82 +128,90 @@ const UserDropdown = () => {
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
isPlain
|
isPlain
|
||||||
position="right"
|
|
||||||
id="user-dropdown"
|
|
||||||
isOpen={isDropdownOpen}
|
isOpen={isDropdownOpen}
|
||||||
toggle={
|
onOpenChange={(isOpen) => setDropdownOpen(isOpen)}
|
||||||
<DropdownToggle onToggle={(_event, val) => setDropdownOpen(val)}>
|
toggle={(ref) => (
|
||||||
|
<MenuToggle
|
||||||
|
id="user-dropdown"
|
||||||
|
ref={ref}
|
||||||
|
onClick={() => setDropdownOpen(!isDropdownOpen)}
|
||||||
|
>
|
||||||
{whoAmI.getDisplayName()}
|
{whoAmI.getDisplayName()}
|
||||||
</DropdownToggle>
|
</MenuToggle>
|
||||||
}
|
)}
|
||||||
dropdownItems={userDropdownItems}
|
>
|
||||||
/>
|
<DropdownList>{userDropdownItems}</DropdownList>
|
||||||
|
</Dropdown>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
const headerTools = () => {
|
|
||||||
const picture = keycloak.tokenParsed?.picture;
|
const picture = keycloak.tokenParsed?.picture;
|
||||||
|
const logo = environment.logo ? environment.logo : "/logo.svg";
|
||||||
|
const url = useHref(toDashboard({ realm }));
|
||||||
|
const logoUrl = environment.logoUrl ? environment.logoUrl : url;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageHeaderTools>
|
<Masthead>
|
||||||
<PageHeaderToolsGroup
|
<MastheadToggle>
|
||||||
|
<PageToggleButton variant="plain" aria-label={t("navigation")}>
|
||||||
|
<BarsIcon />
|
||||||
|
</PageToggleButton>
|
||||||
|
</MastheadToggle>
|
||||||
|
<MastheadBrand href={logoUrl}>
|
||||||
|
<img
|
||||||
|
src={environment.resourceUrl + logo}
|
||||||
|
id="masthead-logo"
|
||||||
|
alt={t("logo")}
|
||||||
|
aria-label={t("logo")}
|
||||||
|
className="keycloak__pageheader_brand"
|
||||||
|
/>
|
||||||
|
</MastheadBrand>
|
||||||
|
<MastheadContent>
|
||||||
|
<Toolbar>
|
||||||
|
<ToolbarContent>
|
||||||
|
<ToolbarItem
|
||||||
|
align={{ default: "alignRight" }}
|
||||||
visibility={{
|
visibility={{
|
||||||
default: "hidden",
|
default: "hidden",
|
||||||
md: "visible",
|
md: "visible",
|
||||||
}} /** the settings and help icon buttons are only visible on desktop sizes and replaced by a kebab dropdown for other sizes */
|
}} /** the settings and help icon buttons are only visible on desktop sizes and replaced by a kebab dropdown for other sizes */
|
||||||
>
|
>
|
||||||
<PageHeaderToolsItem>
|
|
||||||
<HelpHeader />
|
<HelpHeader />
|
||||||
</PageHeaderToolsItem>
|
</ToolbarItem>
|
||||||
</PageHeaderToolsGroup>
|
<ToolbarItem
|
||||||
|
align={{ default: "alignLeft" }}
|
||||||
<PageHeaderToolsGroup>
|
|
||||||
<PageHeaderToolsItem
|
|
||||||
visibility={{
|
visibility={{
|
||||||
md: "hidden",
|
md: "hidden",
|
||||||
}} /** this kebab dropdown replaces the icon buttons and is hidden for desktop sizes */
|
}} /** this kebab dropdown replaces the icon buttons and is hidden for desktop sizes */
|
||||||
>
|
>
|
||||||
<KebabDropdown />
|
<KebabDropdown />
|
||||||
</PageHeaderToolsItem>
|
</ToolbarItem>
|
||||||
<PageHeaderToolsItem
|
<ToolbarItem
|
||||||
visibility={{
|
visibility={{
|
||||||
default: "hidden",
|
default: "hidden",
|
||||||
md: "visible",
|
md: "visible",
|
||||||
}} /** this user dropdown is hidden on mobile sizes */
|
}} /** this user dropdown is hidden on mobile sizes */
|
||||||
>
|
>
|
||||||
<UserDropdown />
|
<UserDropdown />
|
||||||
</PageHeaderToolsItem>
|
</ToolbarItem>
|
||||||
</PageHeaderToolsGroup>
|
<ToolbarItem
|
||||||
|
variant="overflow-menu"
|
||||||
|
align={{ default: "alignRight" }}
|
||||||
|
className="pf-v5-u-m-0-on-lg"
|
||||||
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
src={picture || environment.resourceUrl + "/img_avatar.svg"}
|
src={picture || environment.resourceUrl + "/img_avatar.svg"}
|
||||||
alt="Avatar image"
|
alt={t("avatarImage")}
|
||||||
/>
|
aria-label={t("avatarImage")}
|
||||||
</PageHeaderTools>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const logo = environment.logo ? environment.logo : "/logo.svg";
|
|
||||||
const logoUrl = environment.logoUrl
|
|
||||||
? environment.logoUrl
|
|
||||||
: toDashboard({ realm });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageHeader
|
|
||||||
showNavToggle
|
|
||||||
logo={
|
|
||||||
<Link to={logoUrl}>
|
|
||||||
<Brand
|
|
||||||
src={environment.resourceUrl + logo}
|
|
||||||
id="masthead-logo"
|
|
||||||
alt="Logo"
|
|
||||||
className="keycloak__pageheader_brand"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
}
|
|
||||||
logoComponent="div"
|
|
||||||
headerTools={headerTools()}
|
|
||||||
/>
|
/>
|
||||||
|
</ToolbarItem>
|
||||||
|
</ToolbarContent>
|
||||||
|
</Toolbar>
|
||||||
|
</MastheadContent>
|
||||||
|
</Masthead>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue