-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathAppHeader.tsx
54 lines (50 loc) · 1.4 KB
/
AppHeader.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { PageMasthead } from "@ansible/ansible-ui-framework";
import { useTranslation } from "react-i18next";
import {
Brand,
DropdownItem,
ToolbarGroup,
ToolbarItem,
} from "@patternfly/react-core";
import { UserCircleIcon } from "@patternfly/react-icons";
import { PageMastheadDropdown } from "./PageMastheadDropdown";
import RedHatLogo from "./redhat-logo.svg";
export interface AppHeaderProps {
readonly userName: string;
}
export function AppHeader(props: AppHeaderProps) {
const { t } = useTranslation();
const { userName } = props;
const logout = () => {
window.location.assign("/logout");
};
return (
<PageMasthead
brand={
<Brand alt="" widths={{ default: "125px", md: "125px" }}>
<source media="(min-width: 125px)" srcSet={RedHatLogo} />
</Brand>
}
>
<ToolbarItem style={{ flexGrow: 1 }} />
<ToolbarGroup variant="icon-button-group">
<ToolbarItem>
<PageMastheadDropdown
id="account-menu"
icon={<UserCircleIcon/>}
userName={userName}
>
<DropdownItem
id="logout"
label={t("Logout")}
onClick={logout}
data-testid="app-header__logout"
>
{t("Logout")}
</DropdownItem>
</PageMastheadDropdown>
</ToolbarItem>
</ToolbarGroup>
</PageMasthead>
);
}