Skip to content

Commit 52d5933

Browse files
authored
fix: gh-982 - add tooltips (#3417)
Time to clean the backlog :) Taking the oldest issue :) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added hover tooltips to multiple UI buttons (language selection, notifications, user profile menu, quick start guide, and prepared language actions) with full localization support. * **Documentation** * Added translation entries for button tooltip text. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a33e1d0 commit 52d5933

8 files changed

Lines changed: 159 additions & 90 deletions

File tree

webapp/src/component/languages/PreparedLanguage.tsx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Box, IconButton, styled } from '@mui/material';
1+
import { Box, IconButton, styled, Tooltip } from '@mui/material';
22
import { XClose, Edit02 } from '@untitled-ui/icons-react';
33

44
import { components } from 'tg.service/apiSchema.generated';
55

66
import { FlagImage } from '@tginternal/library/components/languages/FlagImage';
7+
import { useTranslate } from '@tolgee/react';
78

89
const StyledContainer = styled('div')`
910
background: ${({ theme }) => theme.palette.languageChips.background};
@@ -35,6 +36,7 @@ export const PreparedLanguage: React.FC<
3536
onEdit: () => void;
3637
}
3738
> = (props) => {
39+
const { t } = useTranslate();
3840
return (
3941
<>
4042
<StyledContainer data-cy="languages-prepared-language-box">
@@ -43,21 +45,35 @@ export const PreparedLanguage: React.FC<
4345
{props.name} | {props.originalName} ({props.tag})
4446
</Box>
4547
<Box display="flex" alignItems="center">
46-
<StyledIconButton
47-
data-cy="languages-create-customize-button"
48-
size="small"
49-
className="editButton"
50-
onClick={props.onEdit}
48+
<Tooltip
49+
title={t('create_project_edit_prepared_languages')}
50+
placement="bottom-end"
51+
classes={{ tooltip: 'tooltip' }}
52+
disableInteractive
5153
>
52-
<Edit02 />
53-
</StyledIconButton>
54-
<StyledIconButton
55-
size="small"
56-
onClick={props.onReset}
57-
data-cy="languages-create-cancel-prepared-button"
54+
<StyledIconButton
55+
data-cy="languages-create-customize-button"
56+
size="small"
57+
className="editButton"
58+
onClick={props.onEdit}
59+
>
60+
<Edit02 />
61+
</StyledIconButton>
62+
</Tooltip>
63+
<Tooltip
64+
title={t('create_project_remove_prepared_languages')}
65+
placement="bottom-end"
66+
classes={{ tooltip: 'tooltip' }}
67+
disableInteractive
5868
>
59-
<XClose />
60-
</StyledIconButton>
69+
<StyledIconButton
70+
size="small"
71+
onClick={props.onReset}
72+
data-cy="languages-create-cancel-prepared-button"
73+
>
74+
<XClose />
75+
</StyledIconButton>
76+
</Tooltip>
6177
</Box>
6278
</StyledContainer>
6379
</>

webapp/src/component/layout/Notifications/NotificationsTopBarButton.tsx

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { default as React, useState } from 'react';
2-
import { Badge, IconButton, styled } from '@mui/material';
2+
import { Badge, IconButton, styled, Tooltip } from '@mui/material';
33
import { useApiQuery } from 'tg.service/http/useQueryApi';
44
import { Bell01 } from '@untitled-ui/icons-react';
55
import { NotificationsPopup } from 'tg.component/layout/Notifications/NotificationsPopup';
66
import { NotificationsChanged } from 'tg.websocket-client/WebsocketClient';
77
import { PopoverProps } from '@mui/material/Popover';
8+
import { useTranslate } from '@tolgee/react';
89

910
const StyledIconButton = styled(IconButton)`
1011
width: 40px;
@@ -16,6 +17,7 @@ const StyledIconButton = styled(IconButton)`
1617
`;
1718

1819
export const NotificationsTopBarButton: React.FC = () => {
20+
const { t } = useTranslate();
1921
const [anchorEl, setAnchorEl] = useState<PopoverProps['anchorEl']>(null);
2022
const [unseenCount, setUnseenCount] = useState<number>();
2123

@@ -51,29 +53,37 @@ export const NotificationsTopBarButton: React.FC = () => {
5153

5254
return (
5355
<>
54-
<StyledIconButton
55-
color="inherit"
56-
aria-controls="notifications-button"
57-
aria-haspopup="true"
58-
data-cy="notifications-button"
59-
onClick={handleOpen}
60-
size="large"
56+
<Tooltip
57+
title={t('notifications-header')}
58+
placement="bottom-end"
59+
classes={{ tooltip: 'tooltip' }}
60+
disableInteractive
6161
>
62-
<Badge
63-
badgeContent={
64-
unseenNotificationsLoadable.data?.page?.totalElements || unseenCount
65-
}
66-
color="secondary"
67-
slotProps={{
68-
badge: {
69-
//@ts-ignore
70-
'data-cy': 'notifications-count',
71-
},
72-
}}
62+
<StyledIconButton
63+
color="inherit"
64+
aria-controls="notifications-button"
65+
aria-haspopup="true"
66+
data-cy="notifications-button"
67+
onClick={handleOpen}
68+
size="large"
7369
>
74-
<Bell01 />
75-
</Badge>
76-
</StyledIconButton>
70+
<Badge
71+
badgeContent={
72+
unseenNotificationsLoadable.data?.page?.totalElements ||
73+
unseenCount
74+
}
75+
color="secondary"
76+
slotProps={{
77+
badge: {
78+
//@ts-ignore
79+
'data-cy': 'notifications-count',
80+
},
81+
}}
82+
>
83+
<Bell01 />
84+
</Badge>
85+
</StyledIconButton>
86+
</Tooltip>
7787
<NotificationsPopup
7888
onClose={handleClose}
7989
onNotificationsChanged={onNotificationsChanged}

webapp/src/component/layout/QuickStartGuide/QuickStartTopBarButton.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Box, Button, styled } from '@mui/material';
1+
import { Box, Button, styled, Tooltip } from '@mui/material';
22
import {
33
useGlobalActions,
44
useGlobalContext,
55
} from 'tg.globalContext/GlobalContext';
66
import { RocketFilled } from 'tg.component/CustomIcons';
77
import { items } from './quickStartConfig';
88
import { QuickStartProgress } from './QuickStartProgress';
9+
import { useTranslate } from '@tolgee/react';
910

1011
const StyledContainer = styled(Box)`
1112
position: relative;
@@ -17,6 +18,7 @@ const StyledButton = styled(Button)`
1718
`;
1819

1920
export const QuickStartTopBarButton = () => {
21+
const { t } = useTranslate();
2022
const guideEnabled = useGlobalContext((c) => c.quickStartGuide.enabled);
2123
const guideOpen = useGlobalContext((c) => c.quickStartGuide.open);
2224
const guideFloatingOpen = useGlobalContext(
@@ -41,12 +43,19 @@ export const QuickStartTopBarButton = () => {
4143
<>
4244
{guideEnabled && (
4345
<StyledContainer>
44-
<StyledButton onClick={handleClick} color="inherit">
45-
<Box display="flex" gap={1} alignItems="center">
46-
<RocketFilled width={20} height={20} />
47-
<QuickStartProgress percent={completedSteps / allSteps} />
48-
</Box>
49-
</StyledButton>
46+
<Tooltip
47+
title={t('guide_title')}
48+
placement="bottom-end"
49+
classes={{ tooltip: 'tooltip' }}
50+
disableInteractive
51+
>
52+
<StyledButton onClick={handleClick} color="inherit">
53+
<Box display="flex" gap={1} alignItems="center">
54+
<RocketFilled width={20} height={20} />
55+
<QuickStartProgress percent={completedSteps / allSteps} />
56+
</Box>
57+
</StyledButton>
58+
</Tooltip>
5059
</StyledContainer>
5160
)}
5261
</>

webapp/src/component/layout/TopBar/LanguageMenu.tsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { default as React, FunctionComponent, useState } from 'react';
2-
import { Box, IconButton, styled } from '@mui/material';
2+
import { Box, IconButton, styled, Tooltip } from '@mui/material';
33
import Menu from '@mui/material/Menu';
44
import MenuItem from '@mui/material/MenuItem';
55
import { CircledLanguageIcon } from '../../languages/CircledLanguageIcon';
66
import { locales } from '@tginternal/library/constants/locales';
77
import { useCurrentLanguage } from '@tginternal/library/hooks/useCurrentLanguage';
8-
import { useTolgee } from '@tolgee/react';
8+
import { useTolgee, useTranslate } from '@tolgee/react';
99

1010
const StyledMenu = styled(Menu)`
1111
.MuiPaper-root {
@@ -22,6 +22,7 @@ const StyledIconButton = styled(IconButton)`
2222
`;
2323

2424
export const LanguageMenu: FunctionComponent<{ className?: string }> = () => {
25+
const { t } = useTranslate();
2526
const tolgee = useTolgee();
2627
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
2728
// @ts-ignore
@@ -39,20 +40,27 @@ export const LanguageMenu: FunctionComponent<{ className?: string }> = () => {
3940
return (
4041
<>
4142
<div>
42-
<StyledIconButton
43-
color="inherit"
44-
aria-controls="language-menu"
45-
aria-haspopup="true"
46-
data-cy="global-language-menu"
47-
onClick={handleOpen}
48-
size="large"
43+
<Tooltip
44+
title={t('language_menu_title')}
45+
placement="bottom-end"
46+
classes={{ tooltip: 'tooltip' }}
47+
disableInteractive
4948
>
50-
<CircledLanguageIcon
51-
flag={language ? locales[language].flag : undefined}
52-
size={24}
53-
draggable="false"
54-
/>
55-
</StyledIconButton>
49+
<StyledIconButton
50+
color="inherit"
51+
aria-controls="language-menu"
52+
aria-haspopup="true"
53+
data-cy="global-language-menu"
54+
onClick={handleOpen}
55+
size="large"
56+
>
57+
<CircledLanguageIcon
58+
flag={language ? locales[language].flag : undefined}
59+
size={24}
60+
draggable="false"
61+
/>
62+
</StyledIconButton>
63+
</Tooltip>
5664
<StyledMenu
5765
id="language-menu"
5866
keepMounted

webapp/src/component/security/UserMenu/UserMissingAvatarMenu.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { useState } from 'react';
2-
import { IconButton, Popover, styled } from '@mui/material';
2+
import { IconButton, Popover, styled, Tooltip } from '@mui/material';
33

44
import { UserAvatar } from 'tg.component/common/avatar/UserAvatar';
55

66
import { ThemeItem } from './ThemeItem';
77
import { LanguageItem } from './LanguageItem';
88
import { UserMenuItems } from './UserMenuItems';
9+
import { useTranslate } from '@tolgee/react';
910

1011
const StyledIconButton = styled(IconButton)`
1112
width: 40px;
@@ -28,6 +29,7 @@ const StyledDivider = styled('div')`
2829
`;
2930

3031
export const UserMissingAvatarMenu: React.FC = () => {
32+
const { t } = useTranslate();
3133
const [anchorEl, setAnchorEl] = useState(null);
3234

3335
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
@@ -41,16 +43,23 @@ export const UserMissingAvatarMenu: React.FC = () => {
4143

4244
return (
4345
<div>
44-
<StyledIconButton
45-
color="inherit"
46-
data-cy="global-user-menu-button"
47-
aria-controls="user-menu"
48-
aria-haspopup="true"
49-
onClick={handleOpen}
50-
size="large"
46+
<Tooltip
47+
title={t('user_profile_title')}
48+
placement="bottom-end"
49+
classes={{ tooltip: 'tooltip' }}
50+
disableInteractive
5151
>
52-
<UserAvatar />
53-
</StyledIconButton>
52+
<StyledIconButton
53+
color="inherit"
54+
data-cy="global-user-menu-button"
55+
aria-controls="user-menu"
56+
aria-haspopup="true"
57+
onClick={handleOpen}
58+
size="large"
59+
>
60+
<UserAvatar />
61+
</StyledIconButton>
62+
</Tooltip>
5463
<StyledPopover
5564
id="user-menu"
5665
keepMounted

webapp/src/component/security/UserMenu/UserPresentAvatarMenu.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { IconButton, MenuItem, Popover, styled } from '@mui/material';
2+
import { IconButton, MenuItem, Popover, styled, Tooltip } from '@mui/material';
33
import { T, useTranslate } from '@tolgee/react';
44
import { Link, useHistory, useLocation } from 'react-router-dom';
55

@@ -91,16 +91,23 @@ export const UserPresentAvatarMenu: React.FC = () => {
9191

9292
return (
9393
<div>
94-
<StyledIconButton
95-
color="inherit"
96-
data-cy="global-user-menu-button"
97-
aria-controls="user-menu"
98-
aria-haspopup="true"
99-
onClick={handleOpen}
100-
size="large"
94+
<Tooltip
95+
title={t('user_profile_title')}
96+
placement="bottom-end"
97+
classes={{ tooltip: 'tooltip' }}
98+
disableInteractive
10199
>
102-
<UserAvatar />
103-
</StyledIconButton>
100+
<StyledIconButton
101+
color="inherit"
102+
data-cy="global-user-menu-button"
103+
aria-controls="user-menu"
104+
aria-haspopup="true"
105+
onClick={handleOpen}
106+
size="large"
107+
>
108+
<UserAvatar />
109+
</StyledIconButton>
110+
</Tooltip>
104111
<StyledPopover
105112
id="user-menu"
106113
keepMounted

0 commit comments

Comments
 (0)