|
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'; |
2 | 11 | import { BreadcrumbsItem } from '@ui5/webcomponents-react/wrappers'; |
3 | 12 | import { NavigateOptions, useParams } from 'react-router-dom'; |
4 | 13 | import useLuigiNavigate from '../Shared/useLuigiNavigate.tsx'; |
5 | 14 | import LandscapeLabel from './LandscapeLabel.tsx'; |
6 | 15 | import { useTranslation } from 'react-i18next'; |
7 | 16 | import { FeedbackButton } from './FeedbackButton.tsx'; |
8 | 17 | 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'; |
9 | 21 |
|
10 | 22 | const PREFIX = '/mcp'; |
11 | 23 |
|
@@ -67,6 +79,50 @@ export function BreadCrumbFeedbackHeader() { |
67 | 79 | <IntelligentBreadcrumbs /> |
68 | 80 | <BetaButton /> |
69 | 81 | <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> |
70 | 91 | </FlexBox> |
71 | 92 | ); |
72 | 93 | } |
| 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