Skip to content

Commit 0604b26

Browse files
committed
Vincent-Hackathon: Frontend: Sidebar: Add tutorial tooltip for closed sidebar add cluster
1 parent 4470fb1 commit 0604b26

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

frontend/src/components/Sidebar/Sidebar.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { createRouteURL } from '../../lib/router/createRouteURL';
3030
import { useTypedSelector } from '../../redux/hooks';
3131
import ActionButton from '../common/ActionButton';
3232
import CreateButton from '../common/Resource/CreateButton';
33+
import { TutorialToolTip } from '../common/Tutorial/TutorialToolTip';
3334
import NavigationTabs from './NavigationTabs';
3435
import SidebarItem, { SidebarItemProps } from './SidebarItem';
3536
import { DefaultSidebars, setSidebarSelected, setWhetherSidebarOpen } from './sidebarSlice';
@@ -73,6 +74,28 @@ function AddClusterButton() {
7374
const { t } = useTranslation(['translation']);
7475
const { isOpen } = useSidebarInfo();
7576

77+
const [AddClusterButtonDescription, setAddClusterButtonDescription] = React.useState<
78+
string | React.ReactNode
79+
>('loading..');
80+
81+
// since we can use this as part of the tutorial mode we grab the tutorialEnabled from local storage
82+
83+
// set it with a useEffect for now, we can always change it latter in the settings to have that refresh thing to set the local storage
84+
// localStorage.setItem('tutorialMode', 'true');
85+
console.log('current tutorial mode', localStorage.getItem('tutorialMode'));
86+
const isTutorialMode = localStorage.getItem('tutorialMode') === 'true';
87+
88+
React.useEffect(() => {
89+
if (isTutorialMode) {
90+
// setAddClusterButtonDescription("tutorial");
91+
setAddClusterButtonDescription(
92+
<TutorialToolTip context="AddClusterButton" labelText={t('translation|Add Cluster')} />
93+
);
94+
} else {
95+
setAddClusterButtonDescription(t('translation|Add Cluster'));
96+
}
97+
}, [isTutorialMode, AddClusterButtonDescription, t]);
98+
7699
return (
77100
<Box pb={2}>
78101
{isOpen ? (
@@ -81,13 +104,13 @@ function AddClusterButton() {
81104
startIcon={<InlineIcon icon="mdi:plus-box-outline" />}
82105
sx={{ color: theme => theme.palette.sidebar.color }}
83106
>
84-
{t('translation|Add Cluster')}
107+
{AddClusterButtonDescription}
85108
</Button>
86109
) : (
87110
<ActionButton
88111
onClick={() => history.push(createRouteURL('addCluster'))}
89112
icon="mdi:plus-box-outline"
90-
description={t('translation|Add Cluster')}
113+
description={AddClusterButtonDescription}
91114
color="#adadad"
92115
width={38}
93116
/>

0 commit comments

Comments
 (0)