Skip to content

Commit

Permalink
Changes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenandres committed Feb 21, 2024
1 parent bc27264 commit f75338e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 42 deletions.
8 changes: 0 additions & 8 deletions actions/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const CHANGE_ROTATION = 'CHANGE_ROTATION';
export const TOGGLE_MAPTIPS = 'TOGGLE_MAPTIPS';
export const SET_TOPBAR_HEIGHT = 'SET_TOPBAR_HEIGHT';
export const SET_BOTTOMBAR_HEIGHT = 'SET_BOTTOMBAR_HEIGHT';
export const SET_RIGHT_MARGIN = 'SET_RIGHT_MARGIN';
export const SET_SNAPPING_CONFIG = 'SET_SNAPPING_CONFIG';

export function changeMapView(center, zoom, bbox, size, mapStateSource, projection) {
Expand Down Expand Up @@ -123,13 +122,6 @@ export function setBottombarHeight(height) {
};
}

export function setRightMargin(right) {
return {
type: SET_RIGHT_MARGIN,
right
};
}

export function setSnappingConfig(enabled, active) {
return {
type: SET_SNAPPING_CONFIG,
Expand Down
14 changes: 12 additions & 2 deletions actions/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const CLOSE_ALL_WINDOWS = 'CLOSE_ALL_WINDOWS';
export const REGISTER_WINDOW = 'REGISTER_WINDOW';
export const UNREGISTER_WINDOW = 'UNREGISTER_WINDOW';
export const RAISE_WINDOW = 'RAISE_WINDOW';
export const SET_MENU_MARGIN = 'SET_MENU_MARGIN';
export const SET_SPLIT_SCREEN = 'SET_SPLIT_SCREEN';

export const NotificationType = {
Expand Down Expand Up @@ -78,11 +79,20 @@ export function raiseWindow(id) {
};
}

export function setSplitScreen(windowId, side, size) {
export function setSplitScreen(windowId, side, size, menuMargins) {
return {
type: SET_SPLIT_SCREEN,
windowId: windowId,
side: side,
size: size
size: size,
menuMargins: menuMargins
};
}

export function setMenuMargin(right, left) {
return {
type: SET_MENU_MARGIN,
right: right,
left: left
};
}
8 changes: 4 additions & 4 deletions components/AppMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import mousetrap from 'mousetrap';
import {remove as removeDiacritics} from 'diacritics';
import isEmpty from 'lodash.isempty';
import classnames from 'classnames';
import {setRightMargin} from '../actions/map';
import {setMenuMargin} from '../actions/windows';
import {setCurrentTask} from '../actions/task';
import InputContainer from '../components/InputContainer';
import LocaleUtils from '../utils/LocaleUtils';
Expand All @@ -38,7 +38,7 @@ class AppMenu extends React.Component {
onMenuToggled: PropTypes.func,
openExternalUrl: PropTypes.func,
setCurrentTask: PropTypes.func,
setRightMargin: PropTypes.func,
setMenuMargin: PropTypes.func,
showFilterField: PropTypes.bool,
showOnStartup: PropTypes.bool
};
Expand Down Expand Up @@ -312,7 +312,7 @@ class AppMenu extends React.Component {
storeRigthMargin = (el) => {
if (this.props.menuCompact && el?.clientWidth > 0) {
const rightmargin = el.clientWidth - MiscUtils.convertEmToPx(11.5);
this.props.setRightMargin(rightmargin);
this.props.setMenuMargin(rightmargin, 0);
}
};
itemAllowed = (item) => {
Expand All @@ -337,5 +337,5 @@ export default connect((state) => ({
currentTheme: state.theme.current || {}
}), {
setCurrentTask: setCurrentTask,
setRightMargin: setRightMargin
setMenuMargin: setMenuMargin
})(AppMenu);
14 changes: 7 additions & 7 deletions components/ResizeableWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class ResizeableWindow extends React.Component {
maxHeight: PropTypes.number,
maxWidth: PropTypes.number,
maximizeable: PropTypes.bool,
menuMargins: PropTypes.object,
minHeight: PropTypes.number,
minWidth: PropTypes.number,
minimizeable: PropTypes.bool,
onClose: PropTypes.func,
onGeometryChanged: PropTypes.func,
raiseWindow: PropTypes.func,
registerWindow: PropTypes.func,
rightMargin: PropTypes.number,
scrollable: PropTypes.bool,
setSplitScreen: PropTypes.func,
splitScreenWhenDocked: PropTypes.bool,
Expand Down Expand Up @@ -101,7 +101,7 @@ class ResizeableWindow extends React.Component {
if (props.splitScreenWhenDocked && this.state.geometry.docked) {
const dockSide = props.dockable === true ? "left" : props.dockable;
const dockSize = ["left", "right"].includes(dockSide) ? this.state.geometry.width : this.state.geometry.height;
props.setSplitScreen(this.id, dockSide, dockSize);
props.setSplitScreen(this.id, dockSide, dockSize, this.props.menuMargins);
}
}
computeInitialX = (x) => {
Expand All @@ -118,7 +118,7 @@ class ResizeableWindow extends React.Component {
componentWillUnmount() {
this.props.unregisterWindow(this.id);
if (this.props.splitScreenWhenDocked) {
this.props.setSplitScreen(this.id, null);
this.props.setSplitScreen(this.id, null, null, this.props.menuMargins);
}
}
componentDidUpdate(prevProps, prevState) {
Expand All @@ -136,11 +136,11 @@ class ResizeableWindow extends React.Component {
(!this.props.visible && prevProps.visible) ||
(this.state.geometry.docked === false && prevState.geometry.docked !== false)
) {
this.props.setSplitScreen(this.id, null);
this.props.setSplitScreen(this.id, null, null, this.props.menuMargins);
} else if (this.props.visible && this.state.geometry.docked) {
const dockSide = this.props.dockable === true ? "left" : this.props.dockable;
const dockSize = ["left", "right"].includes(dockSide) ? this.state.geometry.width : this.state.geometry.height;
this.props.setSplitScreen(this.id, dockSide, dockSize);
this.props.setSplitScreen(this.id, dockSide, dockSize, this.props.menuMargins);
}
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ class ResizeableWindow extends React.Component {
});
const style = {
display: this.props.visible ? 'initial' : 'none',
right: 'calc(0.25em + ' + this.props.rightMargin + 'px)'
right: 'calc(0.25em + ' + this.props.menuMargins.right + 'px)'
};
const maximized = this.state.geometry.maximized ? true : false;
const minimized = this.state.geometry.minimized ? true : false;
Expand Down Expand Up @@ -332,7 +332,7 @@ export default connect((state) => ({
windowStacking: state.windows.stacking,
topbarHeight: state.map.topbarHeight,
bottombarHeight: state.map.bottombarHeight,
rightMargin: state.map.rightMargin
menuMargins: state.windows.menuMargins
}), {
raiseWindow: raiseWindow,
registerWindow: registerWindow,
Expand Down
6 changes: 3 additions & 3 deletions components/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class SideBar extends React.Component {
heightResizeable: PropTypes.bool,
icon: PropTypes.string,
id: PropTypes.string.isRequired,
menuMargins: PropTypes.object,
minWidth: PropTypes.string,
onHide: PropTypes.func,
onShow: PropTypes.func,
renderWhenHidden: PropTypes.bool,
rightMargin: PropTypes.number,
setCurrentTask: PropTypes.func,
side: PropTypes.string,
title: PropTypes.string,
Expand Down Expand Up @@ -81,7 +81,7 @@ class SideBar extends React.Component {
const render = visible || this.state.render || this.props.renderWhenHidden;
const style = {
width: this.props.width,
right: 'calc(0.25em + ' + this.props.rightMargin + 'px)',
right: visible ? 'calc(0.25em + ' + this.props.menuMargins.right + 'px)' : 0,
minWidth: this.props.minWidth,
zIndex: visible ? 5 : 4
};
Expand Down Expand Up @@ -169,7 +169,7 @@ class SideBar extends React.Component {

const selector = (state) => ({
currentTask: state.task,
rightMargin: state.map.rightMargin
menuMargins: state.windows.menuMargins
});

export default connect(selector, {
Expand Down
9 changes: 3 additions & 6 deletions plugins/LoginUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import './style/LoginUser.css';
*/
class LoginUser extends React.Component {
static propTypes = {
rightMargin: PropTypes.string,
splitScreen: PropTypes.object
mapMargins: PropTypes.object
};
render() {
const username = ConfigUtils.getConfigProp("username");
const splitWindows = Object.values(this.props.splitScreen);
const right = splitWindows.filter(entry => entry.side === 'right').reduce((res, e) => Math.max(e.size, res), 0) + this.props.rightMargin;
const right = this.props.mapMargins.right;
const style = {
right: 'calc(0.25em + ' + right + 'px)'
};
Expand All @@ -42,7 +40,6 @@ class LoginUser extends React.Component {
}

export default connect((state) => ({
rightMargin: state.map.rightMargin,
splitScreen: state.windows.splitScreen
mapMargins: state.windows.mapMargins
}))(LoginUser);

5 changes: 0 additions & 5 deletions plugins/ZoomButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class ZoomButton extends React.Component {
maxZoom: PropTypes.number,
/** The position slot index of the map button, from the bottom (0: bottom slot). */
position: PropTypes.number,
<<<<<<< HEAD
=======
rightMargin: PropTypes.number,
splitScreen: PropTypes.object,
>>>>>>> 390fa289 (Use setRightMargin action)
theme: PropTypes.object,
/** Omit the button in themes matching one of these flags. */
themeFlagBlacklist: PropTypes.arrayOf(PropTypes.string),
Expand Down
5 changes: 1 addition & 4 deletions reducers/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import {
CHANGE_MAP_VIEW, CONFIGURE_MAP, CHANGE_ZOOM_LVL, ZOOM_TO_EXTENT, ZOOM_TO_POINT,
PAN_TO, CHANGE_ROTATION, CLICK_ON_MAP, TOGGLE_MAPTIPS, SET_TOPBAR_HEIGHT, SET_BOTTOMBAR_HEIGHT, SET_RIGHT_MARGIN, SET_SNAPPING_CONFIG
PAN_TO, CHANGE_ROTATION, CLICK_ON_MAP, TOGGLE_MAPTIPS, SET_TOPBAR_HEIGHT, SET_BOTTOMBAR_HEIGHT, SET_SNAPPING_CONFIG
} from '../actions/map';
import isEmpty from 'lodash.isempty';
import MapUtils from '../utils/MapUtils';
Expand Down Expand Up @@ -141,9 +141,6 @@ export default function map(state = defaultState, action) {
case SET_BOTTOMBAR_HEIGHT: {
return {...state, bottombarHeight: action.height};
}
case SET_RIGHT_MARGIN: {
return {...state, rightMargin: action.right};
}
case SET_SNAPPING_CONFIG: {
return {...state, snapping: {enabled: action.enabled, active: action.active}};
}
Expand Down
23 changes: 20 additions & 3 deletions reducers/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
REGISTER_WINDOW,
UNREGISTER_WINDOW,
RAISE_WINDOW,
SET_SPLIT_SCREEN
SET_SPLIT_SCREEN,
SET_MENU_MARGIN
} from '../actions/windows';

const defaultState = {
Expand All @@ -23,6 +24,9 @@ const defaultState = {
mapMargins: {
left: 0, top: 0, right: 0, bottom: 0
},
menuMargins: {
left: 0, right: 0
},
entries: {}
};

Expand Down Expand Up @@ -95,9 +99,9 @@ export default function windows(state = defaultState, action) {
}
const splitWindows = Object.values(newSplitScreen);
const mapMargins = {
right: splitWindows.filter(entry => entry.side === 'right').reduce((res, e) => Math.max(e.size, res), 0),
right: splitWindows.filter(entry => entry.side === 'right').reduce((res, e) => Math.max(e.size, res), 0) + action.menuMargins.right,
bottom: splitWindows.filter(entry => entry.side === 'bottom').reduce((res, e) => Math.max(e.size, res), 0),
left: splitWindows.filter(entry => entry.side === 'left').reduce((res, e) => Math.max(e.size, res), 0),
left: splitWindows.filter(entry => entry.side === 'left').reduce((res, e) => Math.max(e.size, res), 0) + action.menuMargins.left,
top: splitWindows.filter(entry => entry.side === 'top').reduce((res, e) => Math.max(e.size, res), 0)
};
return {
Expand All @@ -106,6 +110,19 @@ export default function windows(state = defaultState, action) {
mapMargins: mapMargins
};
}
case SET_MENU_MARGIN: {
const menuMargins = {
right: action.right,
left: action.left
};
const mapMargins = {
right: action.right,
bottom: 0,
left: action.left,
top: 0
};
return {...state, menuMargins: menuMargins, mapMargins: mapMargins};
}
default:
return state;
}
Expand Down

0 comments on commit f75338e

Please sign in to comment.