Skip to content

Commit 505e502

Browse files
Beta button (#112)
1 parent 61065d3 commit 505e502

File tree

3 files changed

+153
-25
lines changed

3 files changed

+153
-25
lines changed

public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"subtitleMessage": "Looks like this page is not opened inside of the Hyperspace Portal. Contact admins for help."
9494
},
9595
"ShellBar": {
96+
"betaButtonDescription": "This web app is currently in Beta, and may not ready for productive use. We're actively improving the experience and would love your feedback — your input helps shape the future of the app!",
9697
"signOutButton": "Sign Out"
9798
},
9899
"CreateProjectDialog": {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.container {
2+
display: flex;
3+
align-items: center;
4+
gap: 0.5rem;
5+
}
6+
7+
.logoWrapper {
8+
display: flex;
9+
align-items: center;
10+
gap: 0.25rem;
11+
}
12+
13+
.logo {
14+
height: 1.5rem;
15+
}
16+
17+
.logoText {
18+
font-weight: bold;
19+
font-size: 1rem;
20+
color: var(--sapTextColor);
21+
}
22+
23+
.betaButton {
24+
background-color: #FFF3CD;
25+
color: #856404;
26+
padding: 4px 10px;
27+
border-radius: 12px;
28+
border: 1px solid #FFEB99;
29+
font-weight: bold;
30+
font-size: 0.75rem;
31+
height: 1.75rem;
32+
line-height: 1;
33+
display: flex;
34+
align-items: center;
35+
justify-content: center;
36+
}
37+
38+
.betaContent {
39+
display: flex;
40+
align-items: center;
41+
gap: 0.25rem;
42+
}
43+
44+
.betaIcon {
45+
font-size: 1rem;
46+
color: #0A6ED1;
47+
}
48+
49+
.betaText {
50+
font-size: 0.875rem;
51+
}

src/components/Core/ShellBar.tsx

Lines changed: 101 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import {
22
Avatar,
3+
Button,
4+
ButtonDomRef,
5+
Icon,
36
List,
47
ListItemStandard,
58
Popover,
@@ -9,16 +12,21 @@ import {
912
Ui5CustomEvent,
1013
} from '@ui5/webcomponents-react';
1114
import { useAuth } from 'react-oidc-context';
12-
import { RefObject, useRef, useState } from 'react';
15+
import { RefObject, useEffect, useRef, useState } from 'react';
1316
import { ShellBarProfileClickEventDetail } from '@ui5/webcomponents-fiori/dist/ShellBar.js';
1417
import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js';
1518
import { useTranslation } from 'react-i18next';
1619
import { generateInitialsForEmail } from '../Helper/GenerateInitialsForEmail';
20+
import styles from './ShellBar.module.css';
21+
import { ThemingParameters } from '@ui5/webcomponents-react-base';
1722

1823
export function ShellBarComponent() {
1924
const auth = useAuth();
2025
const profilePopoverRef = useRef<PopoverDomRef>(null);
26+
const betaPopoverRef = useRef<PopoverDomRef>(null);
2127
const [profilePopoverOpen, setProfilePopoverOpen] = useState(false);
28+
const [betaPopoverOpen, setBetaPopoverOpen] = useState(false);
29+
const betaButtonRef = useRef<ButtonDomRef>(null);
2230

2331
const onProfileClick = (
2432
e: Ui5CustomEvent<ShellBarDomRef, ShellBarProfileClickEventDetail>,
@@ -27,24 +35,65 @@ export function ShellBarComponent() {
2735
setProfilePopoverOpen(!profilePopoverOpen);
2836
};
2937

38+
const onBetaClick = () => {
39+
if (betaButtonRef.current) {
40+
betaPopoverRef.current!.opener = betaButtonRef.current;
41+
setBetaPopoverOpen(!betaPopoverOpen);
42+
}
43+
};
44+
45+
useEffect(() => {
46+
const shellbar = document.querySelector('ui5-shellbar');
47+
const el = shellbar?.shadowRoot?.querySelector(
48+
'.ui5-shellbar-overflow-container-left',
49+
);
50+
51+
if (el) {
52+
(el as HTMLElement).style.backgroundColor = 'red';
53+
}
54+
}, []);
55+
3056
return (
3157
<>
3258
<ShellBar
33-
logo={<img src="/logo.png" alt="MCP" />}
34-
primaryTitle="MCP"
59+
className={styles.TestShellbar}
3560
profile={
3661
<Avatar
3762
initials={generateInitialsForEmail(auth.user?.profile.email)}
3863
size="XS"
3964
/>
4065
}
66+
startButton={
67+
<div className={styles.container}>
68+
<div className={styles.logoWrapper}>
69+
<img src="/logo.png" alt="MCP" className={styles.logo} />
70+
<span className={styles.logoText}>MCP</span>
71+
</div>
72+
<Button
73+
ref={betaButtonRef}
74+
className={styles.betaButton}
75+
onClick={onBetaClick}
76+
>
77+
<span className={styles.betaContent}>
78+
<Icon name="information" className={styles.betaIcon} />
79+
<span className={styles.betaText}>Beta</span>
80+
</span>
81+
</Button>
82+
</div>
83+
}
4184
onProfileClick={onProfileClick}
4285
/>
86+
4387
<ProfilePopover
4488
open={profilePopoverOpen}
45-
setOpen={(b) => setProfilePopoverOpen(b)}
89+
setOpen={setProfilePopoverOpen}
4690
popoverRef={profilePopoverRef}
4791
/>
92+
<BetaPopover
93+
open={betaPopoverOpen}
94+
setOpen={setBetaPopoverOpen}
95+
popoverRef={betaPopoverRef}
96+
/>
4897
</>
4998
);
5099
}
@@ -62,28 +111,55 @@ const ProfilePopover = ({
62111
const { t } = useTranslation();
63112

64113
return (
65-
<>
66-
<Popover
67-
ref={popoverRef}
68-
placement={PopoverPlacement.Bottom}
69-
open={open}
70-
headerText="Profile"
71-
onClose={() => {
72-
setOpen(false);
114+
<Popover
115+
ref={popoverRef}
116+
placement={PopoverPlacement.Bottom}
117+
open={open}
118+
headerText="Profile"
119+
onClose={() => setOpen(false)}
120+
>
121+
<List>
122+
<ListItemStandard
123+
icon="log"
124+
onClick={() => {
125+
setOpen(false);
126+
auth.removeUser();
127+
}}
128+
>
129+
{t('ShellBar.signOutButton')}
130+
</ListItemStandard>
131+
</List>
132+
</Popover>
133+
);
134+
};
135+
136+
const BetaPopover = ({
137+
open,
138+
setOpen,
139+
popoverRef,
140+
}: {
141+
open: boolean;
142+
setOpen: (arg0: boolean) => void;
143+
popoverRef: RefObject<PopoverDomRef | null>;
144+
}) => {
145+
const { t } = useTranslation();
146+
147+
return (
148+
<Popover
149+
ref={popoverRef}
150+
placement={PopoverPlacement.Bottom}
151+
open={open}
152+
onClose={() => setOpen(false)}
153+
>
154+
<div
155+
style={{
156+
padding: '1rem',
157+
maxWidth: '250px',
158+
fontFamily: ThemingParameters.sapFontFamily,
73159
}}
74160
>
75-
<List>
76-
<ListItemStandard
77-
icon="log"
78-
onClick={() => {
79-
setOpen(false);
80-
auth.removeUser();
81-
}}
82-
>
83-
{t('ShellBar.signOutButton')}
84-
</ListItemStandard>
85-
</List>
86-
</Popover>
87-
</>
161+
{t('ShellBar.betaButtonDescription')}
162+
</div>
163+
</Popover>
88164
);
89165
};

0 commit comments

Comments
 (0)