Skip to content

Commit ee7ac56

Browse files
logout button back
1 parent 6b35546 commit ee7ac56

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

src/components/Core/IntelligentBreadcrumbs.tsx

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
import { Breadcrumbs, BreadcrumbsDomRef, FlexBox, FlexBoxAlignItems, Ui5CustomEvent } from '@ui5/webcomponents-react';
1+
import {
2+
Breadcrumbs,
3+
BreadcrumbsDomRef,
4+
Button,
5+
FlexBox,
6+
FlexBoxAlignItems,
7+
Menu,
8+
MenuItem,
9+
Ui5CustomEvent,
10+
} from '@ui5/webcomponents-react';
211
import { BreadcrumbsItem } from '@ui5/webcomponents-react/wrappers';
312
import { NavigateOptions, useParams } from 'react-router-dom';
413
import useLuigiNavigate from '../Shared/useLuigiNavigate.tsx';
514
import LandscapeLabel from './LandscapeLabel.tsx';
615
import { useTranslation } from 'react-i18next';
716
import { FeedbackButton } from './FeedbackButton.tsx';
817
import { BetaButton } from './BetaButton.tsx';
18+
import { useRef, useState } from 'react';
19+
import { useAuthOnboarding } from '../../spaces/onboarding/auth/AuthContextOnboarding.tsx';
20+
import { SearchParamToggleVisibility } from '../Helper/FeatureToggleExistance.tsx';
921

1022
const PREFIX = '/mcp';
1123

@@ -67,6 +79,50 @@ export function BreadCrumbFeedbackHeader() {
6779
<IntelligentBreadcrumbs />
6880
<BetaButton />
6981
<FeedbackButton />
82+
<SearchParamToggleVisibility
83+
shouldBeVisible={(params) => {
84+
if (params === undefined) return false;
85+
if (params.get('showHeaderBar') === null) return false;
86+
return params?.get('showHeaderBar') === 'false';
87+
}}
88+
>
89+
<LogoutMenu />
90+
</SearchParamToggleVisibility>
7091
</FlexBox>
7192
);
7293
}
94+
95+
function LogoutMenu() {
96+
const auth = useAuthOnboarding();
97+
const { t } = useTranslation();
98+
99+
const buttonRef = useRef(null);
100+
const [menuIsOpen, setMenuIsOpen] = useState(false);
101+
return (
102+
<>
103+
<Button
104+
ref={buttonRef}
105+
icon="menu2"
106+
onClick={() => {
107+
setMenuIsOpen(true);
108+
}}
109+
/>
110+
<Menu
111+
opener={buttonRef.current}
112+
open={menuIsOpen}
113+
onClose={() => {
114+
setMenuIsOpen(false);
115+
}}
116+
>
117+
<MenuItem
118+
icon="log"
119+
text={t('ShellBar.signOutButton')}
120+
onClick={async () => {
121+
setMenuIsOpen(false);
122+
await auth.logout();
123+
}}
124+
/>
125+
</Menu>
126+
</>
127+
);
128+
}

0 commit comments

Comments
 (0)