in public/apps/account/account-nav-button.tsx [39:104]
export function AccountNavButton(props: {
coreStart: CoreStart;
isInternalUser: boolean;
username: string;
tenant?: string;
config: ClientConfigType;
}) {
const [isPopoverOpen, setPopoverOpen] = React.useState<boolean>(false);
const [modal, setModal] = React.useState<React.ReactNode>(null);
const horizontalRule = <EuiHorizontalRule margin="xs" />;
const username = props.username;
const showTenantSwitchPanel = useCallback(
() =>
setModal(
<TenantSwitchPanel
coreStart={props.coreStart}
config={props.config}
handleClose={() => {
setModal(null);
}}
handleSwitchAndClose={() => {
setModal(null);
window.location.reload();
}}
/>
),
[props.config, props.coreStart]
);
if (getShouldShowTenantPopup()) {
setShouldShowTenantPopup(false);
showTenantSwitchPanel();
}
const contextMenuPanel = (
<div style={{ maxWidth: '256px' }}>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem grow={null}>
<EuiAvatar name={username} />
</EuiFlexItem>
<EuiFlexItem>
<EuiListGroup gutterSize="none">
<EuiListGroupItem
key="username"
wrapText
label={
<EuiText size="s">
<h5>{username}</h5>
</EuiText>
}
/>
</EuiListGroup>
<EuiListGroupItem
color="subdued"
key="tenant"
label={<EuiText size="xs">{resolveTenantName(props.tenant || '', username)}</EuiText>}
/>
</EuiFlexItem>
</EuiFlexGroup>
{horizontalRule}
<EuiButtonEmpty
data-test-subj="view-roles-and-identities"
size="xs"
onClick={() => setModal(<RoleInfoPanel {...props} handleClose={() => setModal(null)} />)}