mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add core:copy-item-link action and expose in info sidebar
This commit is contained in:
parent
1fa8f30550
commit
0caa308757
@ -683,7 +683,8 @@
|
|||||||
"empty": "empty",
|
"empty": "empty",
|
||||||
"globalConfig": "Global Configuration Nodes",
|
"globalConfig": "Global Configuration Nodes",
|
||||||
"triggerAction": "Trigger action",
|
"triggerAction": "Trigger action",
|
||||||
"find": "Find in workspace"
|
"find": "Find in workspace",
|
||||||
|
"copyItemUrl": "Copy item url"
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"name": "Help",
|
"name": "Help",
|
||||||
|
@ -25,6 +25,7 @@ RED.sidebar.info = (function() {
|
|||||||
var propertiesPanelHeaderLabel;
|
var propertiesPanelHeaderLabel;
|
||||||
var propertiesPanelHeaderReveal;
|
var propertiesPanelHeaderReveal;
|
||||||
var propertiesPanelHeaderHelp;
|
var propertiesPanelHeaderHelp;
|
||||||
|
var propertiesPanelHeaderCopyLink;
|
||||||
|
|
||||||
var selectedObject;
|
var selectedObject;
|
||||||
|
|
||||||
@ -67,10 +68,20 @@ RED.sidebar.info = (function() {
|
|||||||
|
|
||||||
propertiesPanelHeaderIcon = $("<span>").appendTo(propertiesPanelHeader);
|
propertiesPanelHeaderIcon = $("<span>").appendTo(propertiesPanelHeader);
|
||||||
propertiesPanelHeaderLabel = $("<span>").appendTo(propertiesPanelHeader);
|
propertiesPanelHeaderLabel = $("<span>").appendTo(propertiesPanelHeader);
|
||||||
propertiesPanelHeaderHelp = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-book"></button>').css({
|
|
||||||
|
propertiesPanelHeaderCopyLink = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-link"></button>').css({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: '12px',
|
top: '12px',
|
||||||
right: '32px'
|
right: '32px'
|
||||||
|
}).on("click", function(evt) {
|
||||||
|
RED.actions.invoke('core:copy-item-url',selectedObject)
|
||||||
|
}).appendTo(propertiesPanelHeader);
|
||||||
|
RED.popover.tooltip(propertiesPanelHeaderCopyLink,RED._("sidebar.info.copyItemUrl"));
|
||||||
|
|
||||||
|
propertiesPanelHeaderHelp = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-book"></button>').css({
|
||||||
|
position: 'absolute',
|
||||||
|
top: '12px',
|
||||||
|
right: '56px'
|
||||||
}).on("click", function(evt) {
|
}).on("click", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
@ -80,8 +91,7 @@ RED.sidebar.info = (function() {
|
|||||||
}).appendTo(propertiesPanelHeader);
|
}).appendTo(propertiesPanelHeader);
|
||||||
RED.popover.tooltip(propertiesPanelHeaderHelp,RED._("sidebar.help.showHelp"));
|
RED.popover.tooltip(propertiesPanelHeaderHelp,RED._("sidebar.help.showHelp"));
|
||||||
|
|
||||||
|
propertiesPanelHeaderReveal = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-search"></button>').css({
|
||||||
propertiesPanelHeaderReveal = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-search"></button>').css({
|
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: '12px',
|
top: '12px',
|
||||||
right: '8px'
|
right: '8px'
|
||||||
@ -185,6 +195,7 @@ RED.sidebar.info = (function() {
|
|||||||
propertiesPanelHeaderLabel.text("");
|
propertiesPanelHeaderLabel.text("");
|
||||||
propertiesPanelHeaderReveal.hide();
|
propertiesPanelHeaderReveal.hide();
|
||||||
propertiesPanelHeaderHelp.hide();
|
propertiesPanelHeaderHelp.hide();
|
||||||
|
propertiesPanelHeaderCopyLink.hide();
|
||||||
return;
|
return;
|
||||||
} else if (Array.isArray(node)) {
|
} else if (Array.isArray(node)) {
|
||||||
// Multiple things selected
|
// Multiple things selected
|
||||||
@ -196,6 +207,7 @@ RED.sidebar.info = (function() {
|
|||||||
propertiesPanelHeaderLabel.text("Selection");
|
propertiesPanelHeaderLabel.text("Selection");
|
||||||
propertiesPanelHeaderReveal.hide();
|
propertiesPanelHeaderReveal.hide();
|
||||||
propertiesPanelHeaderHelp.hide();
|
propertiesPanelHeaderHelp.hide();
|
||||||
|
propertiesPanelHeaderCopyLink.hide();
|
||||||
selectedObject = null;
|
selectedObject = null;
|
||||||
|
|
||||||
var types = {
|
var types = {
|
||||||
@ -277,9 +289,11 @@ RED.sidebar.info = (function() {
|
|||||||
if (node.type === "tab" || node.type === "subflow") {
|
if (node.type === "tab" || node.type === "subflow") {
|
||||||
// If nothing is selected, but we're on a flow or subflow tab.
|
// If nothing is selected, but we're on a flow or subflow tab.
|
||||||
propertiesPanelHeaderHelp.hide();
|
propertiesPanelHeaderHelp.hide();
|
||||||
|
propertiesPanelHeaderCopyLink.show();
|
||||||
|
|
||||||
} else if (node.type === "group") {
|
} else if (node.type === "group") {
|
||||||
propertiesPanelHeaderHelp.hide();
|
propertiesPanelHeaderHelp.hide();
|
||||||
|
propertiesPanelHeaderCopyLink.show();
|
||||||
|
|
||||||
propRow = $('<tr class="red-ui-help-info-row"><td> </td><td></td></tr>').appendTo(tableBody);
|
propRow = $('<tr class="red-ui-help-info-row"><td> </td><td></td></tr>').appendTo(tableBody);
|
||||||
|
|
||||||
@ -304,8 +318,10 @@ RED.sidebar.info = (function() {
|
|||||||
}
|
}
|
||||||
} else if (node.type === 'junction') {
|
} else if (node.type === 'junction') {
|
||||||
propertiesPanelHeaderHelp.hide();
|
propertiesPanelHeaderHelp.hide();
|
||||||
|
propertiesPanelHeaderCopyLink.hide();
|
||||||
} else {
|
} else {
|
||||||
propertiesPanelHeaderHelp.show();
|
propertiesPanelHeaderHelp.show();
|
||||||
|
propertiesPanelHeaderCopyLink.show();
|
||||||
|
|
||||||
if (!subflowRegex) {
|
if (!subflowRegex) {
|
||||||
propRow = $('<tr class="red-ui-help-info-row"><td>'+RED._("sidebar.info.type")+'</td><td></td></tr>').appendTo(tableBody);
|
propRow = $('<tr class="red-ui-help-info-row"><td>'+RED._("sidebar.info.type")+'</td><td></td></tr>').appendTo(tableBody);
|
||||||
|
@ -1192,6 +1192,30 @@ RED.view.tools = (function() {
|
|||||||
RED.view.redraw(true);
|
RED.view.redraw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyItemUrl(node, isEdit) {
|
||||||
|
if (!node) {
|
||||||
|
const selection = RED.view.selection();
|
||||||
|
if (selection.nodes && selection.nodes.length > 0) {
|
||||||
|
node = selection.nodes[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node) {
|
||||||
|
let thingType = 'node'
|
||||||
|
if (node.type === 'group') {
|
||||||
|
thingType = 'group'
|
||||||
|
} else if (node.type === 'tab' || node.type === 'subflow') {
|
||||||
|
thingType = 'flow'
|
||||||
|
}
|
||||||
|
let url = `${window.location.origin}${window.location.pathname}#${thingType}/${node.id}`
|
||||||
|
if (isEdit) {
|
||||||
|
url += '/edit'
|
||||||
|
}
|
||||||
|
if (RED.clipboard.copyText(url)) {
|
||||||
|
RED.notify('Copied url to clipboard', { timeout: 2000 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: function() {
|
init: function() {
|
||||||
RED.actions.add("core:show-selected-node-labels", function() { setSelectedNodeLabelState(true); })
|
RED.actions.add("core:show-selected-node-labels", function() { setSelectedNodeLabelState(true); })
|
||||||
@ -1258,6 +1282,9 @@ RED.view.tools = (function() {
|
|||||||
|
|
||||||
RED.actions.add("core:generate-node-names", generateNodeNames )
|
RED.actions.add("core:generate-node-names", generateNodeNames )
|
||||||
|
|
||||||
|
RED.actions.add("core:copy-item-url", function (node) { copyItemUrl(node) })
|
||||||
|
RED.actions.add("core:copy-item-edit-url", function (node) { copyItemUrl(node, true) })
|
||||||
|
|
||||||
// RED.actions.add("core:add-node", function() { addNode() })
|
// RED.actions.add("core:add-node", function() { addNode() })
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user