Skip to content

Commit

Permalink
Merge branch 'main' into 7713-project-types
Browse files Browse the repository at this point in the history
  • Loading branch information
chiaberry committed Dec 3, 2021
2 parents 9ef8cd0 + dcb36af commit 8f09c36
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 22 deletions.
72 changes: 55 additions & 17 deletions moped-editor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ProjectSummaryProjectDescription from "./ProjectSummaryProjectDescription
import ProjectSummaryProjectECapris from "./ProjectSummaryProjectECapris";
import ProjectSummaryProjectTypes from "./ProjectSummaryProjectTypes";

import { countFeatures } from "../../../../utils/mapHelpers";

const useStyles = makeStyles(theme => ({
fieldGridItem: {
margin: theme.spacing(2),
Expand Down Expand Up @@ -105,6 +107,22 @@ const ProjectSummary = ({ loading, error, data, refetch }) => {
if (projectFeatureRecords.length === 0 && !makeSureRefresh)
setMakeSureRefresh(true);

const renderMap = () => {
if (countFeatures(projectFeatureCollection) < 1) {
return (
<ProjectSummaryMapFallback
projectId={projectId}
refetchProjectDetails={refetch}
mapData={projectFeatureCollection}
/>
);
} else {
return (
<ProjectSummaryMap projectExtentGeoJSON={projectFeatureCollection} />
);
}
};

return (
<ApolloErrorHandler errors={error}>
<ProjectSummarySnackbar
Expand Down Expand Up @@ -198,9 +216,7 @@ const ProjectSummary = ({ loading, error, data, refetch }) => {
onReset={() => setMapError(false)}
resetKeys={[mapError]}
>
<ProjectSummaryMap
projectExtentGeoJSON={projectFeatureCollection}
/>
{renderMap()}
</ErrorBoundary>
)}
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ReactMapGL, { NavigationControl } from "react-map-gl";
import { Box, makeStyles } from "@material-ui/core";
import "mapbox-gl/dist/mapbox-gl.css";
import "react-map-gl-geocoder/dist/mapbox-gl-geocoder.css";
import { stopReportingRuntimeErrors } from "react-error-overlay";

import {
createSummaryMapLayers,
Expand Down Expand Up @@ -60,7 +59,7 @@ const ProjectSummaryMap = ({ projectExtentGeoJSON }) => {
* Let's throw an error intentionally if there are no features for a project.
*/
if (featureCount < 1) {
stopReportingRuntimeErrors();
// Throw an error if this component was called without features to render.
throw Error("Map error: Cannot render or edit maps with no features");
}

Expand Down

0 comments on commit 8f09c36

Please sign in to comment.