Skip to content

Commit 736d807

Browse files
committed
set show map for mobile dashboards fixed
1 parent 85d358b commit 736d807

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

layouts/dashboards/actions.js

-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import useRouter from 'utils/router';
55
import { track } from 'analytics';
66

77
import { setDashboardPromptsSettings } from 'components/prompts/dashboard-prompts/actions';
8-
import { setShowMap } from 'components/widgets/actions';
98

109
export const handleCategoryChange = createThunkAction(
1110
'handleCategoryChange',
@@ -118,10 +117,6 @@ export const handleLocationChange = createThunkAction(
118117
}
119118
);
120119

121-
export const closeMobileMap = createThunkAction('closeMobileMap', () => () => {
122-
setShowMap(false);
123-
});
124-
125120
export const clearScrollTo = createThunkAction('clearScrollTo', () => () => {
126121
const { query, pathname, pushQuery } = useRouter();
127122
pushQuery({

layouts/dashboards/component.jsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const isServer = typeof window === 'undefined';
3939
class DashboardsPage extends PureComponent {
4040
static propTypes = {
4141
showMapMobile: PropTypes.bool,
42-
closeMobileMap: PropTypes.func.isRequired,
42+
setShowMap: PropTypes.func.isRequired,
4343
links: PropTypes.array,
4444
widgetAnchor: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
4545
setWidgetsCategory: PropTypes.func,
@@ -108,15 +108,15 @@ class DashboardsPage extends PureComponent {
108108
};
109109

110110
renderMap = () => {
111-
const { showMapMobile, closeMobileMap } = this.props;
111+
const { showMapMobile, setShowMap } = this.props;
112112

113113
return (
114114
<div className="map-container">
115115
{showMapMobile && (
116116
<Button
117117
theme="square theme-button-light"
118118
className="close-map-button"
119-
onClick={closeMobileMap}
119+
onClick={() => setShowMap(false)}
120120
>
121121
<Icon icon={closeIcon} />
122122
</Button>
@@ -196,7 +196,9 @@ class DashboardsPage extends PureComponent {
196196
{this.renderMap()}
197197
</Sticky>
198198
</Media>
199-
<Media lessThan="md">{this.renderMap()}</Media>
199+
<Media lessThan="md" className="mobile-map">
200+
{this.renderMap()}
201+
</Media>
200202
</div>
201203
<MapControls className="map-controls" />
202204
<Share />

layouts/dashboards/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { connect } from 'react-redux';
22

33
import { setMapSettings } from 'components/map/actions';
4-
import { setWidgetsCategory } from 'components/widgets/actions';
4+
import { setWidgetsCategory, setShowMap } from 'components/widgets/actions';
55
import { setDashboardPromptsSettings } from 'components/prompts/dashboard-prompts/actions';
66
import * as ownActions from './actions';
77
import { getDashboardsProps } from './selectors';
@@ -10,6 +10,7 @@ import Component from './component';
1010
export default connect(getDashboardsProps, {
1111
...ownActions,
1212
setMapSettings,
13+
setShowMap,
1314
setDashboardPromptsSettings,
1415
setWidgetsCategory,
1516
})(Component);

layouts/dashboards/selectors.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import {
1414
import CATEGORIES from 'data/categories.json';
1515

1616
// get list data
17-
const selectShowMap = (state) =>
18-
state.location && state.location.query && !!state.location.query.showMap;
17+
const selectShowMap = (state) => state.widgets?.showMap;
1918
const selectLocation = (state) => state.location;
2019
const selectAreaError = (state) => state.areas && state.areas.error;
2120
const selectLocationType = (state) =>

layouts/dashboards/styles.scss

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ $right-panel-width: calc((#{$max-width} * 0.3) + ((100vw - #{$max-width}) / 2));
3030
}
3131
}
3232

33+
.mobile-map {
34+
height: 100%;
35+
}
36+
3337
.map-panel {
3438
height: calc(100% - 56px);
3539
position: fixed;

pages/dashboards/[...location].js

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { setDashboardPrompts } from 'components/prompts/dashboard-prompts/action
1010
import {
1111
setWidgetsSettings,
1212
setWidgetsCategory,
13+
setShowMap,
1314
} from 'components/widgets/actions';
1415
import { setAreaOfInterestModalSettings } from 'components/modals/area-of-interest/actions';
1516

@@ -66,6 +67,7 @@ const DashboardsPage = (props) => {
6667
dashboardPrompts,
6768
category,
6869
areaOfInterestModal,
70+
showMap,
6971
...widgets
7072
} = decodeParamsForState(query) || {};
7173

@@ -92,6 +94,10 @@ const DashboardsPage = (props) => {
9294
if (areaOfInterestModal) {
9395
dispatch(setAreaOfInterestModalSettings(areaOfInterestModal));
9496
}
97+
98+
if (showMap) {
99+
dispatch(setShowMap(showMap));
100+
}
95101
}, [fullPathname]);
96102

97103
// when setting the query params from the URL we need to make sure we don't render the map

providers/dashboards-url-provider/selectors.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const selectDashboardPrompts = (state) =>
77
export const selectWidgetSettings = (state) => state.widgets?.settings;
88
export const selectWidgetsCategory = (state) => state.widgets?.category;
99
export const selectAOIModalSettings = (state) => state.areaOfInterestModal;
10+
export const selectShowMap = (state) => state.widgets?.showMap;
1011

1112
export const getUrlParams = createSelector(
1213
[
@@ -16,14 +17,16 @@ export const getUrlParams = createSelector(
1617
selectWidgetSettings,
1718
selectWidgetsCategory,
1819
selectAOIModalSettings,
20+
selectShowMap,
1921
],
2022
(
2123
map,
2224
modalMeta,
2325
dashboardPrompts,
2426
widgetsSettings,
2527
category,
26-
areaOfInterestModal
28+
areaOfInterestModal,
29+
showMap
2730
) => {
2831
return {
2932
map,
@@ -32,6 +35,7 @@ export const getUrlParams = createSelector(
3235
...widgetsSettings,
3336
category,
3437
areaOfInterestModal,
38+
showMap,
3539
};
3640
}
3741
);

0 commit comments

Comments
 (0)