mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
fix context menu insert junc/links enabled state
This commit is contained in:
parent
e2f42fddb5
commit
c648e1e8d6
@ -30,11 +30,14 @@ RED.contextMenu = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selection = RED.view.selection()
|
const selection = RED.view.selection()
|
||||||
|
const noSelection = !selection || Object.keys(selection).length === 0
|
||||||
const hasSelection = (selection.nodes && selection.nodes.length > 0);
|
const hasSelection = (selection.nodes && selection.nodes.length > 0);
|
||||||
const hasMultipleSelection = hasSelection && selection.nodes.length > 1;
|
const hasMultipleSelection = hasSelection && selection.nodes.length > 1;
|
||||||
const hasLinks = selection.links && selection.links.length > 0;
|
const virtulLinks = (selection.links && selection.links.filter(e => !!e.link)) || [];
|
||||||
const isSingleLink = !hasSelection && hasLinks && selection.links.length === 1
|
const wireLinks = (selection.links && selection.links.filter(e => !e.link)) || [];
|
||||||
const isMultipleLinks = !hasSelection && hasLinks && selection.links.length > 1
|
const hasLinks = wireLinks.length > 0;
|
||||||
|
const isSingleLink = !hasSelection && hasLinks && wireLinks.length === 1
|
||||||
|
const isMultipleLinks = !hasSelection && hasLinks && wireLinks.length > 1
|
||||||
const canDelete = hasSelection || hasLinks
|
const canDelete = hasSelection || hasLinks
|
||||||
const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group'
|
const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group'
|
||||||
|
|
||||||
@ -66,12 +69,13 @@ RED.contextMenu = (function () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(hasSelection || hasLinks) ? {
|
(hasSelection || hasLinks) ? { // has nodes or at least 1 wire selected
|
||||||
label: RED._("contextMenu.junction"),
|
label: RED._("contextMenu.junction"),
|
||||||
onselect: 'core:split-wires-with-junctions',
|
onselect: 'core:split-wires-with-junctions',
|
||||||
disabled: !hasLinks
|
disabled: !hasLinks
|
||||||
} : {
|
} : {
|
||||||
label: RED._("contextMenu.junction"),
|
label: RED._("contextMenu.junction"),
|
||||||
|
disabled: !noSelection, // has 0 nodes, 0 links selected (i.e. workspace right click)
|
||||||
onselect: function () {
|
onselect: function () {
|
||||||
const nn = {
|
const nn = {
|
||||||
_def: { defaults: {} },
|
_def: { defaults: {} },
|
||||||
|
Loading…
Reference in New Issue
Block a user