call the right callbacks and show in the right context
This commit is contained in:
parent
da9e44afa0
commit
a04cd0d395
2 changed files with 39 additions and 23 deletions
frontend/src
|
@ -167,7 +167,6 @@ const ReactApp = {
|
||||||
contextFetchingSiblingsData: ContextMenu.fetchingSiblingsData,
|
contextFetchingSiblingsData: ContextMenu.fetchingSiblingsData,
|
||||||
contextSiblingsData: ContextMenu.siblingsData,
|
contextSiblingsData: ContextMenu.siblingsData,
|
||||||
// functions
|
// functions
|
||||||
contextReset: ContextMenu.reset,
|
|
||||||
contextDelete: ContextMenu.delete,
|
contextDelete: ContextMenu.delete,
|
||||||
contextRemove: ContextMenu.remove,
|
contextRemove: ContextMenu.remove,
|
||||||
contextHide: ContextMenu.hide,
|
contextHide: ContextMenu.hide,
|
||||||
|
|
|
@ -6,13 +6,15 @@ import MetacodeSelect from '../MetacodeSelect'
|
||||||
class ContextMenu extends Component {
|
class ContextMenu extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
topicId: PropTypes.string,
|
topicId: PropTypes.string,
|
||||||
|
mapId: PropTypes.string,
|
||||||
|
currentUser: PropTypes.object,
|
||||||
|
map: PropTypes.object,
|
||||||
contextNode: PropTypes.object,
|
contextNode: PropTypes.object,
|
||||||
contextEdge: PropTypes.object,
|
contextEdge: PropTypes.object,
|
||||||
contextPos: PropTypes.object,
|
contextPos: PropTypes.object,
|
||||||
contextFetchingSiblingsData: PropTypes.bool,
|
contextFetchingSiblingsData: PropTypes.bool,
|
||||||
contextSiblingsData: PropTypes.object,
|
contextSiblingsData: PropTypes.object,
|
||||||
metacodeSets: PropTypes.array,
|
metacodeSets: PropTypes.array,
|
||||||
contextReset: PropTypes.func,
|
|
||||||
contextDelete: PropTypes.func,
|
contextDelete: PropTypes.func,
|
||||||
contextRemove: PropTypes.func,
|
contextRemove: PropTypes.func,
|
||||||
contextHide: PropTypes.func,
|
contextHide: PropTypes.func,
|
||||||
|
@ -33,9 +35,12 @@ class ContextMenu extends Component {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { contextNode, contextPos, contextOnMetacodeSelect, metacodeSets,
|
const { contextNode, contextPos, contextOnMetacodeSelect, metacodeSets,
|
||||||
contextSiblingsData, contextFetchSiblings,
|
contextDelete, contextHide, contextRemove, contextCenterOn,
|
||||||
contextPopulateSiblings, contextFetchingSiblingsData,
|
contextPopoutTopic, contextSiblingsData, contextFetchSiblings,
|
||||||
topicId } = this.props
|
currentUser, contextPopulateSiblings, contextFetchingSiblingsData,
|
||||||
|
topicId, map, mapId, contextUpdatePermissions } = this.props
|
||||||
|
|
||||||
|
const canEditMap = map && map.authorizeToEdit(currentUser)
|
||||||
const style = {
|
const style = {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: contextPos.y + 'px',
|
top: contextPos.y + 'px',
|
||||||
|
@ -49,48 +54,60 @@ class ContextMenu extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add checks for logged in and other context
|
|
||||||
return <div className="rightclickmenu" style={style}>
|
return <div className="rightclickmenu" style={style}>
|
||||||
<ul>
|
<ul>
|
||||||
<li className="rc-hide">
|
<li className="rc-hide" onClick={contextHide}>
|
||||||
<div className="rc-icon" />Hide until refresh
|
<div className="rc-icon" />Hide until refresh
|
||||||
<div className="rc-keyboard">Ctrl+H</div>
|
<div className="rc-keyboard">Ctrl+H</div>
|
||||||
</li>
|
</li>
|
||||||
<li className="rc-remove ">
|
{canEditMap && <li className="rc-remove" onClick={contextRemove}>
|
||||||
<div className="rc-icon" />Remove from map
|
<div className="rc-icon" />Remove from map
|
||||||
<div className="rc-keyboard">Ctrl+M</div>
|
<div className="rc-keyboard">Ctrl+M</div>
|
||||||
</li>
|
</li>}
|
||||||
<li className="rc-delete ">
|
{canEditMap && <li className="rc-delete" onClick={contextDelete}>
|
||||||
<div className="rc-icon" />Delete
|
<div className="rc-icon" />Delete
|
||||||
<div className="rc-keyboard">Ctrl+D</div>
|
<div className="rc-keyboard">Ctrl+D</div>
|
||||||
</li>
|
</li>}
|
||||||
<li className="rc-popout">
|
{contextNode && topicId && <li className="rc-center"
|
||||||
|
onClick={() => contextCenterOn(contextNode.id)}>
|
||||||
|
<div className="rc-icon" />Center this topic
|
||||||
|
<div className="rc-keyboard">Alt+E</div>
|
||||||
|
</li>}
|
||||||
|
{contextNode && <li className="rc-popout"
|
||||||
|
onClick={() => contextPopoutTopic(contextNode.id)}>
|
||||||
<div className="rc-icon" />Open in new tab
|
<div className="rc-icon" />Open in new tab
|
||||||
</li>
|
</li>}
|
||||||
<li className="rc-spacer"></li>
|
{(currentUser || (contextNode && topicId)) && <li className="rc-spacer">
|
||||||
<li className="rc-permission">
|
</li>}
|
||||||
|
{currentUser && <li className="rc-permission">
|
||||||
<div className="rc-icon" />Change permissions
|
<div className="rc-icon" />Change permissions
|
||||||
<ul>
|
<ul>
|
||||||
<li className="changeP toCommons">
|
<li className="changeP toCommons"
|
||||||
|
onClick={() => contextUpdatePermissions('commons')}>
|
||||||
<div className="rc-perm-icon" />commons
|
<div className="rc-perm-icon" />commons
|
||||||
</li>
|
</li>
|
||||||
<li className="changeP toPublic">
|
<li className="changeP toPublic"
|
||||||
|
onClick={() => contextUpdatePermissions('public')}>
|
||||||
<div className="rc-perm-icon" />public
|
<div className="rc-perm-icon" />public
|
||||||
</li>
|
</li>
|
||||||
<li className="changeP toPrivate">
|
<li className="changeP toPrivate"
|
||||||
|
onClick={() => contextUpdatePermissions('private')}>
|
||||||
<div className="rc-perm-icon" />private
|
<div className="rc-perm-icon" />private
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="expandLi" />
|
<div className="expandLi" />
|
||||||
</li>
|
</li>}
|
||||||
<li className="rc-metacode">
|
{currentUser && <li className="rc-metacode">
|
||||||
<div className="rc-icon" />Change metacode
|
<div className="rc-icon" />Change metacode
|
||||||
<div id="metacodeOptionsWrapper">
|
<div id="metacodeOptionsWrapper">
|
||||||
<MetacodeSelect onMetacodeSelect={contextOnMetacodeSelect}
|
<MetacodeSelect
|
||||||
|
onMetacodeSelect={id => {
|
||||||
|
contextOnMetacodeSelect(contextNode && contextNode.id, id)
|
||||||
|
}}
|
||||||
metacodeSets={metacodeSets} />
|
metacodeSets={metacodeSets} />
|
||||||
</div>
|
</div>
|
||||||
<div className="expandLi" />
|
<div className="expandLi" />
|
||||||
</li>
|
</li>}
|
||||||
{contextNode && topicId && <li className="rc-siblings"
|
{contextNode && topicId && <li className="rc-siblings"
|
||||||
onMouseOver={populateSiblings}>
|
onMouseOver={populateSiblings}>
|
||||||
<div className="rc-icon" />Reveal siblings
|
<div className="rc-icon" />Reveal siblings
|
||||||
|
@ -105,7 +122,7 @@ class ContextMenu extends Component {
|
||||||
{contextSiblingsData[key]}
|
{contextSiblingsData[key]}
|
||||||
</li>
|
</li>
|
||||||
})}
|
})}
|
||||||
{contextFetchingSiblingsData && <li id="loadingSiblings">loading</li>}
|
{contextFetchingSiblingsData && <li id="loadingSiblings">loading...</li>}
|
||||||
</ul>
|
</ul>
|
||||||
<div className="expandLi" />
|
<div className="expandLi" />
|
||||||
</li>}
|
</li>}
|
||||||
|
|
Loading…
Reference in a new issue