|
1 | 1 | import PropTypes from "prop-types"; |
2 | | -import React, { Suspense } from "react"; |
3 | | -import { useSyncExternalStore } from "react"; |
4 | | -import "./global.scss"; |
5 | | -import { Loader } from "./Loader"; |
6 | | -import { terriaStore } from "./terriaStore"; |
| 2 | +import RelatedMaps from "terriajs/lib/ReactViews/RelatedMaps/RelatedMaps"; |
| 3 | +import { MenuLeft } from "terriajs/lib/ReactViews/StandardUserInterface/customizable/Groups"; |
| 4 | +import MenuItem from "terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuItem"; |
| 5 | +import StandardUserInterface from "terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface"; |
| 6 | +import version from "../../version"; |
7 | 7 |
|
8 | | -// Lazy load the entire TerriaUserInterface component |
9 | | -const LazyTerriaUserInterface = React.lazy(() => |
10 | | - import("./TerriaUserInterface").then((module) => ({ |
11 | | - default: module.TerriaUserInterface |
12 | | - })) |
13 | | -); |
14 | | - |
15 | | -export const UserInterface = ({ themeOverrides }) => { |
16 | | - const { terria, viewState, status } = useSyncExternalStore( |
17 | | - terriaStore.subscribe, |
18 | | - terriaStore.getSnapshot |
19 | | - ); |
20 | | - |
21 | | - if (status === "loading") { |
22 | | - return <Loader />; |
23 | | - } |
| 8 | +export const TerriaUserInterface = ({ terria, viewState, themeOverrides }) => { |
| 9 | + const relatedMaps = viewState.terria.configParameters.relatedMaps; |
| 10 | + const aboutButtonHrefUrl = |
| 11 | + viewState.terria.configParameters.aboutButtonHrefUrl; |
24 | 12 |
|
25 | 13 | return ( |
26 | | - <Suspense fallback={<Loader />}> |
27 | | - <LazyTerriaUserInterface |
28 | | - terria={terria} |
29 | | - viewState={viewState} |
30 | | - themeOverrides={themeOverrides} |
31 | | - /> |
32 | | - </Suspense> |
| 14 | + <StandardUserInterface |
| 15 | + terria={terria} |
| 16 | + viewState={viewState} |
| 17 | + themeOverrides={themeOverrides} |
| 18 | + version={version} |
| 19 | + > |
| 20 | + <MenuLeft> |
| 21 | + {aboutButtonHrefUrl ? ( |
| 22 | + <MenuItem |
| 23 | + caption="About" |
| 24 | + href={aboutButtonHrefUrl} |
| 25 | + key="about-link" |
| 26 | + /> |
| 27 | + ) : null} |
| 28 | + {relatedMaps && relatedMaps.length > 0 ? ( |
| 29 | + <RelatedMaps relatedMaps={relatedMaps} /> |
| 30 | + ) : null} |
| 31 | + </MenuLeft> |
| 32 | + </StandardUserInterface> |
33 | 33 | ); |
34 | 34 | }; |
35 | 35 |
|
36 | | -UserInterface.propTypes = { |
| 36 | +TerriaUserInterface.propTypes = { |
| 37 | + terria: PropTypes.object.isRequired, |
| 38 | + viewState: PropTypes.object.isRequired, |
37 | 39 | themeOverrides: PropTypes.object |
38 | 40 | }; |
0 commit comments