-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathStdcmHeader.tsx
77 lines (70 loc) · 2.1 KB
/
StdcmHeader.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { Bug } from '@osrd-project/ui-icons';
import cx from 'classnames';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { getIsSuperUser } from 'reducers/user/userSelectors';
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';
const LogoSTDCM = () => {
const deploymentSettings = useDeploymentSettings();
if (deploymentSettings) {
return deploymentSettings.stdcmLogo ? (
<img
src={deploymentSettings.stdcmLogo}
data-testid="lmr-logo"
alt="LMR Logo"
className="stdcm-header__logo"
/>
) : (
<span className="stdcm-header__title pl-5">STDCM</span>
);
}
return null;
};
type StdcmHeaderProps = {
isDebugMode: boolean;
onDebugModeToggle: React.Dispatch<React.SetStateAction<boolean>>;
toggleHelpModule: () => void;
showHelpModule: boolean;
};
const StdcmHeader = ({
isDebugMode,
onDebugModeToggle,
toggleHelpModule,
showHelpModule,
}: StdcmHeaderProps) => {
const { t } = useTranslation(['stdcm', 'translation']);
const isSuperUser = useSelector(getIsSuperUser);
return (
<div className="stdcm-header d-flex">
<LogoSTDCM />
<div className="flex-grow-1 d-flex justify-content-center">
<span className="stdcm-header__notification " id="notification">
{t('stdcm:notificationTitle')}
</span>
</div>
<div className="stdcm-header__debug">
{isSuperUser && (
<button
data-testid="stdcm-debug-button"
type="button"
aria-label="stdcm-debug"
className={cx('debug', { selected: isDebugMode })}
onClick={() => onDebugModeToggle(!isDebugMode)}
>
<Bug />
</button>
)}
<button
type="button"
data-testid="stdcm-help-button"
aria-label="stdcm-help"
className={cx('ml-4 px-3', { selected: showHelpModule })}
onClick={() => toggleHelpModule()}
>
{t('translation:common.help')}
</button>
</div>
</div>
);
};
export default StdcmHeader;