forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix geosolutions-it#9638 ui issue with context when adding all plugins
- Loading branch information
Showing
4 changed files
with
149 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
web/client/plugins/longitudinalProfile/MenuForBurger.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright 2023, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import React, { useState, useCallback } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {Glyphicon, MenuItem} from 'react-bootstrap'; | ||
import {connect} from "react-redux"; | ||
|
||
import Message from '../../components/I18N/Message'; | ||
import { setControlProperty } from "../../actions/controls"; | ||
import { | ||
toggleMode | ||
} from "../../actions/longitudinalProfile"; | ||
import { | ||
dataSourceModeSelector, | ||
isActiveMenuSelector, | ||
isInitializedSelector, | ||
isParametersOpenSelector | ||
} from "../../selectors/longitudinalProfile"; | ||
import { isCesium } from '../../selectors/maptype'; | ||
|
||
/** | ||
* A DropDown menu for longitudinal profile | ||
*/ | ||
const UserMenu = ({ | ||
dataSourceMode, | ||
initialized, | ||
isParametersOpen, | ||
menuIsActive, | ||
showDrawOption, | ||
onActivateTool, | ||
onToggleParameters, | ||
onToggleSourceMode | ||
}) => { | ||
const onToggleTool = useCallback((toolName) => () => { | ||
onActivateTool(); | ||
onToggleSourceMode(toolName); | ||
}, []); | ||
const [open, setMenuOpen ] = useState(false); | ||
const body = (<> | ||
{showDrawOption ? <MenuItem active={dataSourceMode === 'draw'} key="draw" onClick={onToggleTool('draw')}> | ||
<Glyphicon glyph="pencil"/><Message msgId="longitudinalProfile.draw"/> | ||
</MenuItem> : null} | ||
<MenuItem active={dataSourceMode === 'import'} key="import" onClick={onToggleTool('import')}> | ||
<Glyphicon glyph="upload"/> <Message msgId="longitudinalProfile.import"/> | ||
</MenuItem> | ||
<MenuItem active={dataSourceMode === 'select'} key="select" onClick={onToggleTool('select')}> | ||
<Glyphicon glyph="1-layer"/> <Message msgId="longitudinalProfile.select"/> | ||
</MenuItem> | ||
<MenuItem key="divider" divider/> | ||
<MenuItem active={isParametersOpen} key="parameters" onClick={onToggleParameters}> | ||
<Glyphicon glyph="cog"/> <Message msgId="longitudinalProfile.parameters"/> | ||
</MenuItem> | ||
</>); | ||
|
||
// inside extra tools | ||
const Menu = (<> { | ||
open ? <> | ||
<div className="open dropup btn-group btn-group-tray" style={{ position: "absolute", display: "inline"}}> | ||
<ul role="menu" className="dropdown-menu dropdown-menu-right" aria-labelledby="longitudinal-tool"> | ||
{body} | ||
</ul> | ||
</div> | ||
<MenuItem active={menuIsActive || open} key="menu" onClick={() => setMenuOpen(!open)}> | ||
<Glyphicon glyph="1-line"/> | ||
<Message msgId="longitudinalProfile.title"/> | ||
</MenuItem></> : | ||
<MenuItem active={menuIsActive || open} key="menu" onClick={() => setMenuOpen(!open)}> | ||
<Glyphicon glyph="1-line"/> | ||
<Message msgId="longitudinalProfile.title"/> | ||
</MenuItem> } | ||
</>); | ||
|
||
return initialized ? Menu : false; | ||
}; | ||
|
||
UserMenu.propTypes = { | ||
className: PropTypes.string, | ||
dataSourceMode: PropTypes.string, | ||
initialized: PropTypes.bool, | ||
isParametersOpen: PropTypes.bool, | ||
menuIsActive: PropTypes.bool, | ||
menuItem: PropTypes.bool, | ||
nav: PropTypes.bool, | ||
showDrawOption: PropTypes.bool, | ||
tooltipPosition: PropTypes.string, | ||
onActivateTool: PropTypes.func, | ||
onToggleParameters: PropTypes.func, | ||
onToggleSourceMode: PropTypes.func | ||
}; | ||
|
||
UserMenu.defaultProps = { | ||
className: "square-button", | ||
menuIsActive: false, | ||
nav: false, | ||
showDrawOption: true, | ||
onActivateTool: () => {}, | ||
onToggleParameters: () => {}, | ||
onToggleSourceMode: () => {}, | ||
tooltipPosition: 'left' | ||
}; | ||
|
||
const MenuForBurger = connect((state) => ({ | ||
menuIsActive: isActiveMenuSelector(state), | ||
dataSourceMode: dataSourceModeSelector(state), | ||
isParametersOpen: isParametersOpenSelector(state), | ||
showDrawOption: !isCesium(state), | ||
initialized: isInitializedSelector(state) | ||
}), { | ||
onActivateTool: setControlProperty.bind(null, "longitudinalProfileTool", "enabled", true), | ||
onToggleSourceMode: toggleMode, | ||
onToggleParameters: setControlProperty.bind(null, "LongitudinalProfileToolParameters", "enabled", true, true) | ||
})(UserMenu); | ||
|
||
export default MenuForBurger; |