Skip to content

Commit 73484ee

Browse files
authored
Merge branch 'master' into spring7
2 parents 295ddcb + 43e2ead commit 73484ee

11 files changed

Lines changed: 113 additions & 18 deletions

File tree

web/client/epics/__tests__/geoProcessing-test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,13 +1049,20 @@ describe('geoProcessing epics', () => {
10491049
});
10501050
it('LPlongitudinalMapLayoutGPTEpic', (done) => {
10511051
const NUM_ACTIONS = 1;
1052-
const startActions = [updateMapLayout("test")];
1052+
const startActions = [updateMapLayout({
1053+
right: 300,
1054+
boundingSidebarRect: { right: 50 },
1055+
boundingMapRect: { right: 300 }
1056+
})];
10531057
testEpic(LPlongitudinalMapLayoutGPTEpic, NUM_ACTIONS, startActions, actions => {
10541058
expect(actions.length).toBe(NUM_ACTIONS);
10551059
const [
10561060
action1
10571061
] = actions;
10581062
expect(action1.type).toEqual(updateMapLayout().type);
1063+
expect(action1.layout.right).toBe(470);
1064+
expect(action1.layout.boundingMapRect.right).toBe(470);
1065+
expect(action1.layout.boundingSidebarRect.right).toBe(50);
10591066
done();
10601067
}, {
10611068
controls: {

web/client/epics/geoProcessing.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ import {getFeatureInfo} from "../api/identify";
145145
import {getFeatureSimple} from '../api/WFS';
146146
import {findNonGeometryProperty, findGeometryProperty} from '../utils/ogc/WFS/base';
147147
import toWKT from '../utils/ogc/WKT/toWKT';
148-
import { DEFAULT_PANEL_WIDTH } from '../utils/LayoutUtils';
148+
import { DEFAULT_PANEL_WIDTH, getBoundingSidebarRect } from '../utils/LayoutUtils';
149149

150150
const OFFSET = DEFAULT_PANEL_WIDTH;
151151
const DEACTIVATE_ACTIONS = [
@@ -1059,13 +1059,15 @@ export const LPlongitudinalMapLayoutGPTEpic = (action$, store) =>
10591059
action$.ofType(UPDATE_MAP_LAYOUT)
10601060
.filter(({source}) => isGeoProcessingEnabledSelector(store.getState()) && source !== GPT_CONTROL_NAME)
10611061
.map(({layout}) => {
1062+
const boundingSidebarRect = getBoundingSidebarRect(layout);
10621063
const action = updateMapLayout({
10631064
...layout,
1064-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0),
1065+
right: OFFSET + boundingSidebarRect.right,
10651066
boundingMapRect: {
10661067
...(layout.boundingMapRect || {}),
1067-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0)
1068+
right: OFFSET + boundingSidebarRect.right
10681069
},
1070+
boundingSidebarRect,
10691071
rightPanel: true
10701072
});
10711073
return { ...action, source: GPT_CONTROL_NAME }; // add an argument to avoid infinite loop.

web/client/epics/longitudinalProfile.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import {selectLineFeature} from "../utils/LongitudinalProfileUtils";
8989
import {buildIdentifyRequest} from "../utils/MapInfoUtils";
9090
import {getFeatureInfo} from "../api/identify";
9191
import { drawerOwnerSelector } from "../selectors/draw";
92-
import { DEFAULT_PANEL_WIDTH } from '../utils/LayoutUtils';
92+
import { DEFAULT_PANEL_WIDTH, getBoundingSidebarRect } from '../utils/LayoutUtils';
9393

9494
const OFFSET = DEFAULT_PANEL_WIDTH;
9595

@@ -369,13 +369,15 @@ export const LPlongitudinalMapLayoutEpic = (action$, store) =>
369369
action$.ofType(UPDATE_MAP_LAYOUT)
370370
.filter(({source}) => isDockOpenSelector(store.getState()) && source !== CONTROL_NAME)
371371
.map(({layout}) => {
372+
const boundingSidebarRect = getBoundingSidebarRect(layout);
372373
const action = updateMapLayout({
373374
...layout,
374-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0),
375+
right: OFFSET + boundingSidebarRect.right,
375376
boundingMapRect: {
376377
...(layout.boundingMapRect || {}),
377-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0)
378+
right: OFFSET + boundingSidebarRect.right
378379
},
380+
boundingSidebarRect,
379381
rightPanel: true
380382
});
381383
return { ...action, source: CONTROL_NAME }; // add an argument to avoid infinite loop.

web/client/plugins/DynamicLegend/epics/__tests__/dynamiclegend-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('dynamiclegend epics', () => {
3131
expect(actions[0].source).toBe(CONTROL_NAME);
3232
expect(actions[0].layout.right).toBe(DEFAULT_PANEL_WIDTH + (layout?.boundingSidebarRect?.right ?? 0));
3333
expect(actions[0].layout.rightPanel).toBe(true);
34-
expect(actions[0].layout.boundingMapRect.right).toBe(DEFAULT_PANEL_WIDTH);
34+
expect(actions[0].layout.boundingMapRect.right).toBe(DEFAULT_PANEL_WIDTH + (layout?.boundingSidebarRect?.right ?? 0));
3535
expect(actions[0].layout.boundingSidebarRect.right).toBe(200);
3636
done();
3737
},

web/client/plugins/DynamicLegend/epics/dynamiclegend.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import isNil from 'lodash/isNil';
1010
import { UPDATE_MAP_LAYOUT, updateMapLayout } from '../../../actions/maplayout';
11-
import { DEFAULT_PANEL_WIDTH } from '../../../utils/LayoutUtils';
11+
import { DEFAULT_PANEL_WIDTH, getBoundingSidebarRect } from '../../../utils/LayoutUtils';
1212
import { CONTROL_NAME } from '../constants';
1313
import { enabledSelector, isFloatingSelector } from '../selectors/dynamiclegend';
1414
const OFFSET = DEFAULT_PANEL_WIDTH;
@@ -25,13 +25,15 @@ export const dynamicLegendMapLayoutEpic = (action$, store) =>
2525
return !isFloatingSelector(store.getState()) && enabledSelector(store.getState()) && isNil(source);
2626
})
2727
.map(({layout}) => {
28+
const boundingSidebarRect = getBoundingSidebarRect(layout);
2829
const newLayout = {
2930
...layout,
30-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0),
31+
right: OFFSET + boundingSidebarRect.right,
3132
boundingMapRect: {
3233
...(layout.boundingMapRect || {}),
33-
right: OFFSET
34+
right: OFFSET + boundingSidebarRect.right
3435
},
36+
boundingSidebarRect,
3537
rightPanel: true
3638
};
3739
const action = updateMapLayout(newLayout);

web/client/plugins/Isochrone/epics/__tests__/isochrone-test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,27 @@ describe('Isochrone Epics', () => {
142142
mockStore.getState()
143143
);
144144
});
145+
146+
it('should default missing boundingSidebarRect right to 40', (done) => {
147+
const layout = {
148+
right: 300,
149+
boundingMapRect: { right: 300 }
150+
};
151+
152+
testEpic(
153+
addTimeoutEpic(isochroneMapLayoutEpic, 10),
154+
1,
155+
updateMapLayout(layout),
156+
actions => {
157+
expect(actions[0].type).toBe(UPDATE_MAP_LAYOUT);
158+
expect(actions[0].layout.right).toBe(460);
159+
expect(actions[0].layout.boundingMapRect.right).toBe(460);
160+
expect(actions[0].layout.boundingSidebarRect.right).toBe(40);
161+
done();
162+
},
163+
mockStore.getState()
164+
);
165+
});
145166
});
146167

147168
describe('isochroneSearchByLocationNameEpic', () => {

web/client/plugins/Isochrone/epics/isochrone.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { changeMapInfoState, purgeMapInfoResults } from '../../../actions/mapInf
3636
import { removeAdditionalLayer, removeAllAdditionalLayers, updateAdditionalLayer } from '../../../actions/additionallayers';
3737
import { SET_CONTROL_PROPERTY, setControlProperty, TOGGLE_CONTROL } from '../../../actions/controls';
3838
import { addLayer } from '../../../actions/layers';
39-
import { DEFAULT_PANEL_WIDTH, parseLayoutValue } from '../../../utils/LayoutUtils';
39+
import { DEFAULT_PANEL_WIDTH, getBoundingSidebarRect, parseLayoutValue } from '../../../utils/LayoutUtils';
4040
import { drawerEnabledControlSelector } from '../../../selectors/controls';
4141
import { info } from '../../../actions/notifications';
4242
import { getMarkerLayerIdentifier } from '../utils/IsochroneUtils';
@@ -58,13 +58,15 @@ export const isochroneMapLayoutEpic = (action$, store) =>
5858
action$.ofType(UPDATE_MAP_LAYOUT)
5959
.filter(({source}) => enabledSelector(store.getState()) && isNil(source))
6060
.map(({layout}) => {
61+
const boundingSidebarRect = getBoundingSidebarRect(layout);
6162
const action = updateMapLayout({
6263
...layout,
63-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0),
64+
right: OFFSET + boundingSidebarRect.right,
6465
boundingMapRect: {
6566
...(layout.boundingMapRect || {}),
66-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0)
67+
right: OFFSET + boundingSidebarRect.right
6768
},
69+
boundingSidebarRect,
6870
rightPanel: true
6971
});
7072
return { ...action, source: CONTROL_NAME };

web/client/plugins/Itinerary/epics/__tests__/itinerary-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ describe('Itinerary Epics', () => {
230230

231231
testEpic(itineraryMapLayoutEpic, 1, action, (actions) => {
232232
expect(actions[0].type).toBe(UPDATE_MAP_LAYOUT);
233-
expect(actions[0].layout.right).toBe(420);
233+
expect(actions[0].layout.right).toBe(460);
234234
}, state, done);
235235
});
236236

web/client/plugins/Itinerary/epics/itinerary.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { UPDATE_MAP_LAYOUT, updateMapLayout } from '../../../actions/maplayout';
3232
import { changeMousePointer, CLICK_ON_MAP, zoomToExtent } from '../../../actions/map';
3333
import { CONTROL_NAME, DEFAULT_SEARCH_CONFIG, ITINERARY_ROUTE_LAYER } from '../constants';
3434
import { enabledSelector, itinerarySearchConfigSelector, locationsSelector } from '../selectors/itinerary';
35-
import { DEFAULT_PANEL_WIDTH } from '../../../utils/LayoutUtils';
35+
import { DEFAULT_PANEL_WIDTH, getBoundingSidebarRect } from '../../../utils/LayoutUtils';
3636
import { changeMapInfoState, purgeMapInfoResults } from '../../../actions/mapInfo';
3737
import { removeAdditionalLayer, removeAllAdditionalLayers, updateAdditionalLayer } from '../../../actions/additionallayers';
3838
import { SET_CONTROL_PROPERTY, setControlProperty, TOGGLE_CONTROL } from '../../../actions/controls';
@@ -54,13 +54,15 @@ export const itineraryMapLayoutEpic = (action$, store) =>
5454
action$.ofType(UPDATE_MAP_LAYOUT)
5555
.filter(({source}) => enabledSelector(store.getState()) && isNil(source))
5656
.map(({layout}) => {
57+
const boundingSidebarRect = getBoundingSidebarRect(layout);
5758
const action = updateMapLayout({
5859
...layout,
59-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0),
60+
right: OFFSET + boundingSidebarRect.right,
6061
boundingMapRect: {
6162
...(layout.boundingMapRect || {}),
62-
right: OFFSET + (layout?.boundingSidebarRect?.right ?? 0)
63+
right: OFFSET + boundingSidebarRect.right
6364
},
65+
boundingSidebarRect,
6466
rightPanel: true
6567
});
6668
return { ...action, source: CONTROL_NAME };

web/client/utils/LayoutUtils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ import {
1313
} from 'lodash';
1414

1515
export const DEFAULT_PANEL_WIDTH = 420;
16+
export const DEFAULT_BOUNDING_SIDEBAR_RIGHT = 40;
1617

1718
export const DEFAULT_MAP_LAYOUT = {left: {sm: 300, md: 500, lg: 600}, right: { md: DEFAULT_PANEL_WIDTH }, bottom: {sm: 0}};
1819

20+
export const getBoundingSidebarRect = (layout) => ({
21+
...(layout?.boundingSidebarRect || {}),
22+
right: layout?.boundingSidebarRect?.right ?? DEFAULT_BOUNDING_SIDEBAR_RIGHT
23+
});
24+
1925
/**
2026
* Return parsed number from layout value
2127
* if percentage returns percentage of second argument that should be a number

0 commit comments

Comments
 (0)