Skip to content

Commit

Permalink
Add click on top-level to get back to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfranklin committed Nov 20, 2024
1 parent 8587705 commit fba63d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
16 changes: 8 additions & 8 deletions react/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
Navigate,
useLocation,
} from 'react-router-dom';
import * as ROUTES from './constants/routes';
import MapProject from './pages/MapProject';
import MainMenu from './pages/MainMenu';
import Logout from './pages/Logout/Logout';
import Login from './pages/Login/Login';
import Callback from './pages/Callback/Callback';
import StreetviewCallback from './pages/StreetviewCallback/StreetviewCallback';
import { RootState } from './redux/store';
import * as ROUTES from '@hazmapper/constants/routes';
import MapProject from '@hazmapper/pages/MapProject';
import MainMenu from '@hazmapper/pages/MainMenu';
import Logout from '@hazmapper/pages/Logout/Logout';
import Login from '@hazmapper/pages/Login/Login';
import Callback from '@hazmapper/pages/Callback/Callback';
import StreetviewCallback from '@hazmapper/pages/StreetviewCallback/StreetviewCallback';
import { RootState } from '@hazmapper/redux/store';
import { isTokenValid } from '@hazmapper/utils/authUtils';
import { useBasePath } from '@hazmapper/hooks/environment';

Expand Down
25 changes: 22 additions & 3 deletions react/src/pages/MapProject/MapProject.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import Map from '@hazmapper/components/Map';
import AssetsPanel from '@hazmapper/components/AssetsPanel';
import ManageMapProjectModal from '@hazmapper/components/ManageMapProjectModal';
Expand All @@ -13,6 +13,7 @@ import Filters from '@hazmapper/components/FiltersPanel/Filter';
import { assetTypeOptions } from '@hazmapper/components/FiltersPanel/Filter';
import { Project } from '@hazmapper/types';
import { Message, LoadingSpinner } from '@tacc/core-components';
import * as ROUTES from '@hazmapper/constants/routes';

interface MapProjectProps {
/**
Expand Down Expand Up @@ -131,6 +132,7 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
});

const location = useLocation();
const navigate = useNavigate();

const queryParams = new URLSearchParams(location.search);
const activePanel = queryParams.get(queryPanelKey);
Expand All @@ -149,11 +151,28 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
features: [],
};

const handleKeyDown = (event: React.KeyboardEvent) => {
/* TODO https://tacc-main.atlassian.net/browse/WG-207 */
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
navigate(ROUTES.MAIN);
}
};

return (
<div className={styles.root}>
<div className={styles.topNavbar}>MapTopNavBar</div>
<div
className={styles.topNavbar}
onKeyDown={handleKeyDown}
onClick={() => navigate(ROUTES.MAIN)}
role="button"
tabIndex={0}
style={{ cursor: 'pointer' }}
>
MapTopNavBar TODO https://tacc-main.atlassian.net/browse/WG-207
</div>
<div className={styles.mapControlBar}>
MapTopControlBar
MapTopControlBar TODO https://tacc-main.atlassian.net/browse/WG-260
{loading && <div> loading</div>}
</div>
<div className={styles.container}>
Expand Down

0 comments on commit fba63d7

Please sign in to comment.