import {
Avatar,
Brand,
Dropdown,
DropdownItem,
DropdownSeparator,
DropdownToggle,
KebabToggle,
PageHeader,
PageHeaderTools,
PageHeaderToolsGroup,
PageHeaderToolsItem,
} from "@patternfly/react-core";
import { HelpIcon } from "@patternfly/react-icons";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { HelpHeader, useHelp } from "./components/help-enabler/HelpHeader";
import { useAdminClient } from "./context/auth/AdminClient";
import { useRealm } from "./context/realm-context/RealmContext";
import { useWhoAmI } from "./context/whoami/WhoAmI";
import { toDashboard } from "./dashboard/routes/Dashboard";
import environment from "./environment";
export const Header = () => {
const { realm } = useRealm();
const adminClient = useAdminClient();
const { t } = useTranslation();
const ManageAccountDropdownItem = () => {
return (
<>
{adminClient.keycloak && (
adminClient.keycloak.accountManagement()}
>
{t("manageAccount")}
)}
>
);
};
const SignOutDropdownItem = () => {
return (
<>
{adminClient.keycloak && (
adminClient.keycloak.logout({ redirectUri: "" })}
>
{t("signOut")}
)}
>
);
};
const ServerInfoDropdownItem = () => {
const { realm } = useRealm();
const { t } = useTranslation();
return (
{t("realmInfo")}
);
};
const HelpDropdownItem = () => {
const { t } = useTranslation();
const { enabled, toggleHelp } = useHelp();
return (
} onClick={toggleHelp}>
{enabled ? t("helpEnabled") : t("helpDisabled")}
);
};
const kebabDropdownItems = [
,
,
,
,
,
];
const userDropdownItems = [
,
,
,
,
];
const headerTools = () => {
return (
);
};
const KebabDropdown = () => {
const [isDropdownOpen, setDropdownOpen] = useState(false);
const onDropdownToggle = () => {
setDropdownOpen(!isDropdownOpen);
};
return (
}
isOpen={isDropdownOpen}
dropdownItems={kebabDropdownItems}
/>
);
};
const UserDropdown = () => {
const { whoAmI } = useWhoAmI();
const [isDropdownOpen, setDropdownOpen] = useState(false);
const onDropdownToggle = () => {
setDropdownOpen(!isDropdownOpen);
};
return (
{whoAmI.getDisplayName()}
}
dropdownItems={userDropdownItems}
/>
);
};
return (
}
logoComponent="div"
headerTools={headerTools()}
/>
);
};