Skip to content

Commit 23a3850

Browse files
moved beta button
1 parent c38a9be commit 23a3850

File tree

3 files changed

+63
-47
lines changed

3 files changed

+63
-47
lines changed

src/components/Core/BetaButton.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { ButtonDomRef, Button, Icon, PopoverDomRef, Popover, Text } from "@ui5/webcomponents-react";
2+
import { useState, useRef, RefObject } from "react";
3+
import styles from './ShellBar.module.css';
4+
import { useTranslation } from "react-i18next";
5+
import PopoverPlacement from "@ui5/webcomponents/dist/types/PopoverPlacement.js";
6+
import { ThemingParameters } from '@ui5/webcomponents-react-base';
7+
8+
9+
export function BetaButton() {
10+
const [betaPopoverOpen, setBetaPopoverOpen] = useState(false);
11+
const betaButtonRef = useRef<ButtonDomRef>(null);
12+
const betaPopoverRef = useRef<PopoverDomRef>(null);
13+
const { t } = useTranslation();
14+
15+
16+
const onBetaClick = () => {
17+
if (betaButtonRef.current) {
18+
betaPopoverRef.current!.opener = betaButtonRef.current;
19+
setBetaPopoverOpen(!betaPopoverOpen);
20+
}
21+
};
22+
23+
return (
24+
<>
25+
<Button ref={betaButtonRef} className={styles.betaButton} onClick={onBetaClick}>
26+
<span className={styles.betaContent}>
27+
<Icon name="information" className={styles.betaIcon} />
28+
<span className={styles.betaText}>{t('ShellBar.betaButton')}</span>
29+
</span>
30+
<BetaPopover open={betaPopoverOpen} setOpen={setBetaPopoverOpen} popoverRef={betaPopoverRef} />
31+
</Button>
32+
</>
33+
)
34+
}
35+
36+
const BetaPopover = ({
37+
open,
38+
setOpen,
39+
popoverRef,
40+
}: {
41+
open: boolean;
42+
setOpen: (arg0: boolean) => void;
43+
popoverRef: RefObject<PopoverDomRef | null>;
44+
}) => {
45+
const { t } = useTranslation();
46+
47+
return (
48+
<Popover ref={popoverRef} placement={PopoverPlacement.Bottom} open={open} onClose={() => setOpen(false)}>
49+
<Text
50+
style={{
51+
padding: '1rem',
52+
maxWidth: '250px',
53+
fontFamily: ThemingParameters.sapFontFamily,
54+
}}
55+
>
56+
{t('ShellBar.betaButtonDescription')}
57+
</Text>
58+
</Popover>
59+
);
60+
};
61+

src/components/Core/IntelligentBreadcrumbs.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import useLuigiNavigate from '../Shared/useLuigiNavigate.tsx';
55
import LandscapeLabel from './LandscapeLabel.tsx';
66
import { useTranslation } from 'react-i18next';
77
import { FeedbackButton } from './FeedbackButton.tsx';
8+
import { BetaButton } from './BetaButton.tsx';
89

910
const PREFIX = '/mcp';
1011

@@ -67,6 +68,7 @@ export function BreadCrumbFeedbackHeader() {
6768
alignItems={FlexBoxAlignItems.Center}
6869
>
6970
<IntelligentBreadcrumbs />
71+
<BetaButton />
7072
<FeedbackButton />
7173
</FlexBox>
7274
)

src/components/Core/ShellBar.tsx

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import {
22
Avatar,
3-
Button,
4-
ButtonDomRef,
5-
Icon,
63
List,
74
ListItemStandard,
85
Popover,
@@ -18,30 +15,19 @@ import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js'
1815
import { useTranslation } from 'react-i18next';
1916
import { generateInitialsForEmail } from '../Helper/generateInitialsForEmail.ts';
2017
import styles from './ShellBar.module.css';
21-
import { ThemingParameters } from '@ui5/webcomponents-react-base';
2218

2319

2420
export function ShellBarComponent() {
2521
const auth = useAuthOnboarding();
2622
const profilePopoverRef = useRef<PopoverDomRef>(null);
27-
const betaPopoverRef = useRef<PopoverDomRef>(null);
2823
const [profilePopoverOpen, setProfilePopoverOpen] = useState(false);
29-
const [betaPopoverOpen, setBetaPopoverOpen] = useState(false);
30-
const betaButtonRef = useRef<ButtonDomRef>(null);
3124

32-
const { t } = useTranslation();
3325

3426
const onProfileClick = (e: Ui5CustomEvent<ShellBarDomRef, ShellBarProfileClickEventDetail>) => {
3527
profilePopoverRef.current!.opener = e.detail.targetRef;
3628
setProfilePopoverOpen(!profilePopoverOpen);
3729
};
3830

39-
const onBetaClick = () => {
40-
if (betaButtonRef.current) {
41-
betaPopoverRef.current!.opener = betaButtonRef.current;
42-
setBetaPopoverOpen(!betaPopoverOpen);
43-
}
44-
};
4531

4632
useEffect(() => {
4733
const shellbar = document.querySelector('ui5-shellbar');
@@ -64,20 +50,13 @@ export function ShellBarComponent() {
6450
<img src="/logo.png" alt="MCP" className={styles.logo} />
6551
<span className={styles.logoText}>MCP</span>
6652
</div>
67-
<Button ref={betaButtonRef} className={styles.betaButton} onClick={onBetaClick}>
68-
<span className={styles.betaContent}>
69-
<Icon name="information" className={styles.betaIcon} />
70-
<span className={styles.betaText}>{t('ShellBar.betaButton')}</span>
71-
</span>
72-
</Button>
7353
</div>
7454
}
7555
onProfileClick={onProfileClick}
7656
>
7757
</ShellBar>
7858

7959
<ProfilePopover open={profilePopoverOpen} setOpen={setProfilePopoverOpen} popoverRef={profilePopoverRef} />
80-
<BetaPopover open={betaPopoverOpen} setOpen={setBetaPopoverOpen} popoverRef={betaPopoverRef} />
8160

8261
</>
8362
);
@@ -118,29 +97,3 @@ const ProfilePopover = ({
11897
);
11998
};
12099

121-
const BetaPopover = ({
122-
open,
123-
setOpen,
124-
popoverRef,
125-
}: {
126-
open: boolean;
127-
setOpen: (arg0: boolean) => void;
128-
popoverRef: RefObject<PopoverDomRef | null>;
129-
}) => {
130-
const { t } = useTranslation();
131-
132-
return (
133-
<Popover ref={popoverRef} placement={PopoverPlacement.Bottom} open={open} onClose={() => setOpen(false)}>
134-
<div
135-
style={{
136-
padding: '1rem',
137-
maxWidth: '250px',
138-
fontFamily: ThemingParameters.sapFontFamily,
139-
}}
140-
>
141-
{t('ShellBar.betaButtonDescription')}
142-
</div>
143-
</Popover>
144-
);
145-
};
146-

0 commit comments

Comments
 (0)