Skip to content

Commit 0730aec

Browse files
Fix geosolutions-it#11794 Layout issue for the floating containers (geosolutions-it#11927)
* Fix the layout issue for the floating containers * Fix the test case
1 parent 96d59b7 commit 0730aec

7 files changed

Lines changed: 45 additions & 12 deletions

File tree

web/client/plugins/BackgroundSelector.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
allowBackgroundsDeletionSelector
4040
} from '../selectors/backgroundselector';
4141

42-
import { mapLayoutValuesSelector } from '../selectors/maplayout';
42+
import { boundingMapRectLayoutValuesSelector, mapLayoutValuesSelector } from '../selectors/maplayout';
4343
import thumbs from './background/DefaultThumbs';
4444
import { createPlugin } from '../utils/PluginsUtils';
4545

@@ -60,7 +60,11 @@ const backgroundSelector = createSelector([
6060
mapIsEditableSelector,
6161
backgroundLayersSelector,
6262
backgroundControlsSelector,
63-
state => mapLayoutValuesSelector(state, {left: true, bottom: true}),
63+
state => {
64+
const mapLayoutStyle = mapLayoutValuesSelector(state, { bottom: true });
65+
const boundingMapRectStyle = boundingMapRectLayoutValuesSelector(state, {left: true});
66+
return { ...boundingMapRectStyle, ...mapLayoutStyle };
67+
},
6468
state => state.browser && state.browser.mobile ? 'mobile' : 'desktop',
6569
confirmDeleteBackgroundModalSelector,
6670
allowBackgroundsDeletionSelector, isCesium],

web/client/plugins/Search.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {mapSelector, mapSizeValuesSelector, projectionSelector} from '../selecto
5252
import ConfigUtils from '../utils/ConfigUtils';
5353
import { defaultIconStyle } from '../utils/SearchUtils';
5454
import ToggleButton from './searchbar/ToggleButton';
55-
import {mapLayoutValuesSelector} from "../selectors/maplayout";
55+
import {boundingMapRectLayoutValuesSelector} from "../selectors/maplayout";
5656
import {sidebarIsActiveSelector} from "../selectors/sidebarmenu";
5757
import classnames from "classnames";
5858

@@ -414,8 +414,8 @@ const SearchPlugin = connect((state) => ({
414414
export default {
415415
SearchPlugin: Object.assign(
416416
connect(createStructuredSelector({
417-
style: state => mapLayoutValuesSelector(state, { right: true }),
418-
offsets: state => mapLayoutValuesSelector(state, { right: true, left: true }),
417+
style: state => boundingMapRectLayoutValuesSelector(state, { right: true }),
418+
offsets: state => boundingMapRectLayoutValuesSelector(state, { right: true, left: true }),
419419
mapSize: state => mapSizeValuesSelector({ width: true })(state),
420420
sidebarIsActive: state => sidebarIsActiveSelector(state)
421421
}), {})(SearchPlugin), {

web/client/plugins/Timeline.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import withResizeSpy from '../components/misc/enhancers/withResizeSpy';
3939
import Toolbar from '../components/misc/toolbar/Toolbar';
4040
import InlineDateTimeSelector from '../components/time/InlineDateTimeSelector';
4141
import { currentTimeSelector, offsetEnabledSelector } from '../selectors/dimension';
42-
import { mapLayoutValuesSelector } from '../selectors/maplayout';
42+
import { boundingMapRectLayoutValuesSelector, mapLayoutValuesSelector } from '../selectors/maplayout';
4343
import { playbackRangeSelector, statusSelector } from '../selectors/playback';
4444
import {
4545
currentTimeRangeSelector,
@@ -162,8 +162,9 @@ const TimelinePlugin = compose(
162162
}),
163163
// get info about expand, collapse panel
164164
connect( createSelector(
165-
state => mapLayoutValuesSelector(state, { right: true, bottom: true, left: true }),
166-
mapLayoutStyle => ({mapLayoutStyle}))),
165+
state => boundingMapRectLayoutValuesSelector(state, { right: true, left: true }),
166+
state => mapLayoutValuesSelector(state, { bottom: true }),
167+
(boundingMapRectStyle, mapLayoutStyle) => ({mapLayoutStyle: {...boundingMapRectStyle, ...mapLayoutStyle}}))),
167168
// guess when to hide
168169
withProps(
169170
({containerWidth, style, mapLayoutStyle}) => {

web/client/plugins/featuregrid/__tests__/FeatureEditor-test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('FeatureEditor plugin component', () => {
5151
pagination: { startIndex: undefined, maxFeatures: undefined, resultSize: undefined, totalFeatures: undefined },
5252
pages: undefined,
5353
size: 20,
54-
hasNoGeometry: true
54+
hasNoGeometry: false
5555
};
5656
it('base state', () => {
5757
expect(BASE_EXPECTED).toEqual(BASE_EXPECTED);

web/client/plugins/featuregrid/hoc/withResize.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import './style.less';
77
* @returns {React.Component} A component wrapped in a resizable div
88
*
99
* Props:
10-
* @prop {boolean} hasNoGeometry - When true, disables resize functionality (default: false).
10+
* @prop {boolean} hasNoGeometry - When true, disables resize functionality.
1111
* If true, the wrapped component is rendered to fill the available height without resize functionality.
1212
* @prop {number} defaultHeight - Initial height in pixels (default: 300)
1313
* @prop {number} minHeight - Minimum height in pixels (default: 75)
1414
* @prop {number} maxHeight - Maximum height in pixels (default: 70% of the window inner height)
1515
*/
1616
const withResize = (Component) => {
1717
return (props) => {
18-
const { hasNoGeometry = false, defaultHeight = 300, minHeight = 75, maxHeight = '70%' } = props;
18+
const { hasNoGeometry, defaultHeight = 300, minHeight = 75, maxHeight = '70%' } = props;
1919
const [height, setHeight] = useState(defaultHeight);
2020
const [isResizing, setIsResizing] = useState(false);
2121
const containerRef = useRef(null);
@@ -59,7 +59,7 @@ const withResize = (Component) => {
5959
};
6060

6161
// If hasNoGeometry is true, render the component without the resize container
62-
if (hasNoGeometry) {
62+
if (hasNoGeometry && typeof hasNoGeometry === 'boolean') {
6363
return (
6464
<div className="ms-featuregrid-fill">
6565
<Component {...props} />

web/client/selectors/featuregrid.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,8 @@ export const hasNoGeometry = (state) => {
245245
return false;
246246
}
247247
const features = get(state, "featuregrid.features", []);
248+
if (features.length === 0) {
249+
return false;
250+
}
248251
return !(features || []).some(({ geometry }) => geometry);
249252
};

web/client/selectors/maplayout.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ export const dockPanelsSelector = (state) => state?.maplayout?.dockPanels ?? { l
147147

148148
export const dockStyleSelector = state => mapLayoutValuesSelector(state, { height: true, right: true }, true);
149149
export const helpStyleSelector = state => mapLayoutValuesSelector(state, { right: true }, true);
150+
151+
/**
152+
* Retrieve only specific attribute from bounding map rect layout
153+
* @function
154+
* @memberof selectors.mapLayout
155+
* @param {object} state the state
156+
* @param {object} attributes attributes to retrieve, bool {left: true}
157+
* @param {boolean} isDock flag to use dock paddings instead of toolbar paddings
158+
* @return {object} selected attributes of layout of the map
159+
*/
160+
export const boundingMapRectLayoutValuesSelector = memoize((state, attributes = {}, isDock = false) => {
161+
const layout = boundingMapRectSelector(state);
162+
const boundingSidebarRect = boundingSidebarRectSelector(state);
163+
return layout && Object.keys(layout).filter(key =>
164+
attributes[key]).reduce((a, key) => {
165+
if (isDock) {
166+
return ({...a, [key]: (boundingSidebarRect[key] ?? layout[key])});
167+
}
168+
return ({...a, [key]: layout[key]});
169+
},
170+
{}) || {};
171+
}, (state, attributes, isDock) =>
172+
JSON.stringify(boundingMapRectSelector(state)) +
173+
JSON.stringify(boundingSidebarRectSelector(state)) +
174+
JSON.stringify(attributes) + (isDock ? '_isDock' : ''));

0 commit comments

Comments
 (0)