Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion js/apps/account-ui/src/root/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const Header = () => {
data-testid="page-header"
keycloak={keycloak}
features={{ hasManageAccount: false }}
showNavToggle
brand={{
href: indexHref,
src: joinPath(environment.resourceUrl, brandImage),
Expand Down
112 changes: 64 additions & 48 deletions js/libs/ui-shared/src/masthead/Masthead.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {
Avatar,
AvatarProps,
Brand,
BrandProps,
DropdownItem,
Masthead,
MastheadBrand,
MastheadBrandProps,
MastheadContent,
MastheadMainProps,
MastheadToggle,
PageToggleButton,
Toolbar,
ToolbarContent,
ToolbarItem,
} from "@patternfly/react-core";
import {
PageHeader,
PageHeaderProps,
PageHeaderTools,
PageHeaderToolsGroup,
PageHeaderToolsItem,
} from "@patternfly/react-core/deprecated";
import { BarsIcon } from "@patternfly/react-icons";
import { TFunction } from "i18next";
import Keycloak, { type KeycloakTokenParsed } from "keycloak-js";
import { ReactNode } from "react";
Expand All @@ -38,11 +40,9 @@ function loggedInUserName(
return givenName || familyName || preferredUsername || t("unknownUser");
}

type BrandLogo = BrandProps & {
href: string;
};
type BrandLogo = MastheadBrandProps;

type KeycloakMastheadProps = PageHeaderProps & {
type KeycloakMastheadProps = MastheadMainProps & {
keycloak: Keycloak;
brand: BrandLogo;
avatar?: AvatarProps;
Expand All @@ -58,7 +58,7 @@ type KeycloakMastheadProps = PageHeaderProps & {

const KeycloakMasthead = ({
keycloak,
brand: { href: brandHref, ...brandProps },
brand: { src, alt, className, ...brandProps },
avatar,
features: {
hasLogout = true,
Expand Down Expand Up @@ -92,33 +92,28 @@ const KeycloakMasthead = ({

const picture = keycloak.idTokenParsed?.picture;
return (
<PageHeader
{...rest}
logo={<Brand {...brandProps} />}
logoProps={{ href: brandHref }}
headerTools={
<PageHeaderTools>
<PageHeaderToolsGroup>
<PageHeaderToolsItem
visibility={{
md: "hidden",
}}
>
<KeycloakDropdown
data-testid="options-kebab"
isKebab
dropDownItems={[
...(kebabDropdownItems || dropdownItems),
extraItems,
]}
/>
</PageHeaderToolsItem>
<PageHeaderToolsItem>{toolbarItems}</PageHeaderToolsItem>
<PageHeaderToolsItem
<Masthead {...rest}>
<MastheadToggle>
<PageToggleButton variant="plain" aria-label={t("navigation")}>
<BarsIcon />
</PageToggleButton>
</MastheadToggle>
<MastheadBrand {...brandProps}>
<img src={src} alt={alt} className={className} />
</MastheadBrand>
<MastheadContent>
<Toolbar>
<ToolbarContent>
{toolbarItems?.map((item, index) => (
<ToolbarItem key={index} align={{ default: "alignRight" }}>
{item}
</ToolbarItem>
))}
<ToolbarItem
visibility={{
default: "hidden",
md: "visible",
}}
}} /** this user dropdown is hidden on mobile sizes */
>
<KeycloakDropdown
data-testid="options"
Expand All @@ -129,16 +124,37 @@ const KeycloakMasthead = ({
: undefined
}
/>
</PageHeaderToolsItem>
</PageHeaderToolsGroup>
{picture || avatar?.src ? (
<Avatar {...{ src: picture, alt: t("avatar"), ...avatar }} />
) : (
<DefaultAvatar {...avatar} />
)}
</PageHeaderTools>
}
/>
</ToolbarItem>
<ToolbarItem
align={{ default: "alignLeft" }}
visibility={{
md: "hidden",
}}
>
<KeycloakDropdown
data-testid="options-kebab"
isKebab
dropDownItems={[
...(kebabDropdownItems || dropdownItems),
extraItems,
]}
/>
</ToolbarItem>
<ToolbarItem
variant="overflow-menu"
align={{ default: "alignRight" }}
className="pf-v5-u-m-0-on-lg"
>
{picture || avatar?.src ? (
<Avatar {...{ src: picture, alt: t("avatar"), ...avatar }} />
) : (
<DefaultAvatar {...avatar} />
)}
</ToolbarItem>
</ToolbarContent>
</Toolbar>
</MastheadContent>
</Masthead>
);
};

Expand Down