import React, { useContext, useState } from "react"; import { useTranslation } from "react-i18next"; import { Avatar, Brand, Dropdown, DropdownItem, DropdownSeparator, DropdownToggle, KebabToggle, PageHeader, PageHeaderTools, PageHeaderToolsItem, PageHeaderToolsGroup, } from "@patternfly/react-core"; import { HelpIcon } from "@patternfly/react-icons"; import { WhoAmIContext } from "./context/whoami/WhoAmI"; import { HelpContext, HelpHeader } from "./components/help-enabler/HelpHeader"; import { Link, useHistory } from "react-router-dom"; import { useAdminClient } from "./context/auth/AdminClient"; import { useRealm } from "./context/realm-context/RealmContext"; export const Header = () => { 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 { t } = useTranslation(); const history = useHistory(); const { setRealm } = useRealm(); return ( { history.push("/master/"); setRealm("master"); }} > {t("realmInfo")} ); }; const HelpDropdownItem = () => { const { t } = useTranslation(); const { enabled, toggleHelp } = useContext(HelpContext); 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 } = useContext(WhoAmIContext); const [isDropdownOpen, setDropdownOpen] = useState(false); const onDropdownToggle = () => { setDropdownOpen(!isDropdownOpen); }; return ( {whoAmI.getDisplayName()} } dropdownItems={userDropdownItems} /> ); }; return (