Add href to brand of Masthead (#20597)
This commit is contained in:
parent
9dabbe951e
commit
a58a9a89d6
2 changed files with 8 additions and 10 deletions
|
@ -6,14 +6,14 @@ import {
|
||||||
} from "keycloak-masthead";
|
} from "keycloak-masthead";
|
||||||
import { Suspense, useMemo } from "react";
|
import { Suspense, useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet, useHref } from "react-router-dom";
|
||||||
import { AlertProvider } from "ui-shared";
|
import { AlertProvider } from "ui-shared";
|
||||||
|
|
||||||
|
import { ExternalLinkSquareAltIcon } from "@patternfly/react-icons";
|
||||||
import { environment } from "../environment";
|
import { environment } from "../environment";
|
||||||
import { keycloak } from "../keycloak";
|
import { keycloak } from "../keycloak";
|
||||||
import { joinPath } from "../utils/joinPath";
|
import { joinPath } from "../utils/joinPath";
|
||||||
import { PageNav } from "./PageNav";
|
import { PageNav } from "./PageNav";
|
||||||
import { ExternalLinkSquareAltIcon } from "@patternfly/react-icons";
|
|
||||||
|
|
||||||
import style from "./Root.module.css";
|
import style from "./Root.module.css";
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ const ReferrerLink = () => {
|
||||||
|
|
||||||
export const Root = () => {
|
export const Root = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const indexHref = useHref("/");
|
||||||
|
|
||||||
const translations = useMemo<Translations>(
|
const translations = useMemo<Translations>(
|
||||||
() => ({
|
() => ({
|
||||||
|
@ -57,6 +58,7 @@ export const Root = () => {
|
||||||
features={{ hasManageAccount: false }}
|
features={{ hasManageAccount: false }}
|
||||||
showNavToggle
|
showNavToggle
|
||||||
brand={{
|
brand={{
|
||||||
|
href: indexHref,
|
||||||
src: joinPath(environment.resourceUrl, "logo.svg"),
|
src: joinPath(environment.resourceUrl, "logo.svg"),
|
||||||
alt: t("logo"),
|
alt: t("logo"),
|
||||||
className: style.brand,
|
className: style.brand,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { loggedInUserName } from "./util";
|
||||||
import { DefaultAvatar } from "./DefaultAvatar";
|
import { DefaultAvatar } from "./DefaultAvatar";
|
||||||
|
|
||||||
type BrandLogo = BrandProps & {
|
type BrandLogo = BrandProps & {
|
||||||
onClick?: () => void;
|
href: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type KeycloakMastheadProps = PageHeaderProps & {
|
type KeycloakMastheadProps = PageHeaderProps & {
|
||||||
|
@ -37,7 +37,7 @@ type KeycloakMastheadProps = PageHeaderProps & {
|
||||||
};
|
};
|
||||||
|
|
||||||
const KeycloakMasthead = ({
|
const KeycloakMasthead = ({
|
||||||
brand: { onClick: onBrandLogoClick, ...brandProps },
|
brand: { href: brandHref, ...brandProps },
|
||||||
avatar,
|
avatar,
|
||||||
features: {
|
features: {
|
||||||
hasLogout = true,
|
hasLogout = true,
|
||||||
|
@ -74,12 +74,8 @@ const KeycloakMasthead = ({
|
||||||
return (
|
return (
|
||||||
<PageHeader
|
<PageHeader
|
||||||
{...rest}
|
{...rest}
|
||||||
logo={
|
logo={<Brand {...brandProps} />}
|
||||||
<div onClick={onBrandLogoClick}>
|
logoProps={{ href: brandHref }}
|
||||||
<Brand {...brandProps} />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
logoComponent="div"
|
|
||||||
headerTools={
|
headerTools={
|
||||||
<PageHeaderTools>
|
<PageHeaderTools>
|
||||||
<PageHeaderToolsGroup>
|
<PageHeaderToolsGroup>
|
||||||
|
|
Loading…
Reference in a new issue