Skip to content

Commit ed898a5

Browse files
committed
gbfa validator header nav
1 parent 9e20e1e commit ed898a5

3 files changed

Lines changed: 97 additions & 3 deletions

File tree

web-app/public/locales/en/common.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@
9292
"description": "Railway in which the track consists of a single rail or a beam."
9393
}
9494
}
95-
}
95+
},
96+
"validators": "Validators",
97+
"gbfsValidator": "GBFS Validator",
98+
"gtfsValidator": "GTFS Validator"
9699
}

web-app/src/app/components/Header.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { defaultRemoteConfigValues } from '../interface/RemoteConfig';
3939
import { animatedButtonStyling } from './Header.style';
4040
import DrawerContent from './HeaderMobileDrawer';
4141
import ThemeToggle from './ThemeToggle';
42+
import { useTranslation } from 'react-i18next';
4243

4344
export default function DrawerAppBar(): React.ReactElement {
4445
const theme = useTheme();
@@ -53,6 +54,7 @@ export default function DrawerAppBar(): React.ReactElement {
5354
string | undefined
5455
>(i18n.language);
5556
const { config } = useRemoteConfig();
57+
const { t } = useTranslation('common');
5658

5759
i18n.on('languageChanged', (lang) => {
5860
setCurrentLanguage(i18n.language);
@@ -200,6 +202,62 @@ export default function DrawerAppBar(): React.ReactElement {
200202
{item.title}
201203
</Button>
202204
))}
205+
{config.gbfsValidator && (
206+
<>
207+
<Button
208+
aria-controls='validator-menu'
209+
aria-haspopup='true'
210+
endIcon={<ArrowDropDownIcon />}
211+
onClick={handleMenuOpen}
212+
sx={(theme) => ({
213+
...animatedButtonStyling(theme),
214+
color: theme.palette.text.primary,
215+
})}
216+
id='validator-button-menu'
217+
className={
218+
activeTab.includes('validator') ? 'active short' : ''
219+
}
220+
>
221+
{t('validators')}
222+
</Button>
223+
<Menu
224+
id='validator-menu'
225+
anchorEl={anchorEl}
226+
open={
227+
anchorEl !== null && anchorEl.id === 'validator-button-menu'
228+
}
229+
onClose={handleMenuClose}
230+
>
231+
<MenuItem
232+
key={'gbfs-validator'}
233+
onClick={() => {
234+
handleMenuItemClick('gbfs-validator');
235+
}}
236+
sx={{display: 'flex', gap: 1}}
237+
>
238+
<BikeScooterOutlined
239+
fontSize='small'
240+
sx={{ color: theme.palette.text.primary }}
241+
/>
242+
{t('gbfsValidator')}
243+
</MenuItem>
244+
<MenuItem
245+
key={'gtfs-validator'}
246+
onClick={() => {
247+
handleMenuItemClick('gtfs-validator');
248+
}}
249+
sx={{display: 'flex', gap: 1}}
250+
disabled={true}
251+
>
252+
<DirectionsBusIcon
253+
fontSize='small'
254+
sx={{ color: theme.palette.text.primary }}
255+
/>
256+
{t('gtfsValidator')}
257+
</MenuItem>
258+
</Menu>
259+
</>
260+
)}
203261
{/* Allow users with mobilitydata.org email to access metrics */}
204262
{metricsOptionsEnabled && (
205263
<>

web-app/src/app/components/HeaderMobileDrawer.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { selectIsAuthenticated } from '../store/profile-selectors';
2323
import { fontFamily } from '../Theme';
2424
import { mobileNavElementStyle } from './Header.style';
2525
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
26+
import { useRemoteConfig } from '../context/RemoteConfigProvider';
27+
import { useTranslation } from 'react-i18next';
2628

2729
const websiteTile = 'Mobility Database';
2830

@@ -39,6 +41,8 @@ export default function DrawerContent({
3941
}: DrawerContentProps): JSX.Element {
4042
const isAuthenticated = useSelector(selectIsAuthenticated);
4143
const navigateTo = useNavigate();
44+
const { config } = useRemoteConfig();
45+
const { t } = useTranslation('common');
4246
const theme = useTheme();
4347

4448
return (
@@ -95,7 +99,36 @@ export default function DrawerContent({
9599
{item.title}
96100
</Button>
97101
))}
102+
98103
<Divider sx={{ mt: 2 }} />
104+
{config.gbfsValidator && (
105+
<Accordion disableGutters={true} sx={{ boxShadow: 'none' }}>
106+
<AccordionSummary
107+
expandIcon={<ExpandMoreIcon />}
108+
aria-controls='validators-content'
109+
id='validators-content'
110+
>
111+
<Typography
112+
variant={'subtitle1'}
113+
sx={{ fontFamily: fontFamily.secondary }}
114+
>
115+
{t('validators')}
116+
</Typography>
117+
</AccordionSummary>
118+
<AccordionDetails>
119+
<Button
120+
variant='text'
121+
sx={mobileNavElementStyle}
122+
href={'gbfs-validator'}
123+
>
124+
{t('gbfsValidator')}
125+
</Button>
126+
<Button variant='text' sx={mobileNavElementStyle} disabled={true}>
127+
{t('gtfsValidator')}
128+
</Button>
129+
</AccordionDetails>
130+
</Accordion>
131+
)}
99132
{metricsOptionsEnabled && (
100133
<>
101134
<Accordion disableGutters={true} sx={{ boxShadow: 'none' }}>
@@ -186,8 +219,8 @@ export default function DrawerContent({
186219
</Accordion>
187220
) : (
188221
<Button
189-
variant='text'
190-
sx={mobileNavElementStyle}
222+
variant='contained'
223+
sx={{ml:2}}
191224
href={SIGN_IN_TARGET}
192225
>
193226
Login

0 commit comments

Comments
 (0)