1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add list-flows action and button

This commit is contained in:
Nick O'Leary 2019-03-04 22:37:51 +00:00
parent b27da3d1a0
commit 43f21fc7aa
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 55 additions and 6 deletions

View File

@ -24,6 +24,7 @@
"delete": "Are you sure you want to delete '__label__'?", "delete": "Are you sure you want to delete '__label__'?",
"dropFlowHere": "Drop the flow here", "dropFlowHere": "Drop the flow here",
"addFlow": "Add Flow", "addFlow": "Add Flow",
"listFlows": "List Flows",
"status": "Status", "status": "Status",
"enabled": "Enabled", "enabled": "Enabled",
"disabled":"Disabled", "disabled":"Disabled",

View File

@ -2,6 +2,7 @@
"*": { "*": {
"ctrl-shift-p":"core:manage-palette", "ctrl-shift-p":"core:manage-palette",
"ctrl-f": "core:search", "ctrl-f": "core:search",
"ctrl-shift-f": "core:list-flows",
"ctrl-=": "core:zoom-in", "ctrl-=": "core:zoom-in",
"ctrl--": "core:zoom-out", "ctrl--": "core:zoom-out",
"ctrl-0": "core:zoom-reset", "ctrl-0": "core:zoom-reset",

View File

@ -36,7 +36,7 @@ RED.tabs = (function() {
} }
if (options.addButton) { if (options.addButton) {
wrapper.addClass("red-ui-tabs-add"); wrapper.addClass("red-ui-tabs-add");
var addButton = $('<div class="red-ui-tab-button"><a href="#"><i class="fa fa-plus"></i></a></div>').appendTo(wrapper); var addButton = $('<div class="red-ui-tab-button red-ui-tabs-add"><a href="#"><i class="fa fa-plus"></i></a></div>').appendTo(wrapper);
addButton.find('a').click(function(evt) { addButton.find('a').click(function(evt) {
evt.preventDefault(); evt.preventDefault();
if (typeof options.addButton === 'function') { if (typeof options.addButton === 'function') {
@ -69,7 +69,25 @@ RED.tabs = (function() {
RED.actions.invoke(options.addButton,{index:targetIndex}); RED.actions.invoke(options.addButton,{index:targetIndex});
} }
}); });
}
if (options.searchButton) {
wrapper.addClass("red-ui-tabs-search");
var searchButton = $('<div class="red-ui-tab-button red-ui-tabs-search"><a href="#"><i class="fa fa-list-ul"></i></a></div>').appendTo(wrapper);
searchButton.find('a').click(function(evt) {
evt.preventDefault();
if (typeof options.searchButton === 'function') {
options.searchButton()
} else if (typeof options.searchButton === 'string') {
RED.actions.invoke(options.searchButton);
}
})
if (typeof options.searchButton === 'string') {
var l = options.searchButton;
if (options.searchButtonCaption) {
l = options.searchButtonCaption
}
RED.popover.tooltip(searchButton,l,options.searchButton);
}
} }
var scrollLeft; var scrollLeft;

View File

@ -82,9 +82,18 @@ RED.search = (function() {
function search(val) { function search(val) {
searchResults.editableList('empty'); searchResults.editableList('empty');
var typeFilter;
var m = /(?:^| )type:([^ ]+)/.exec(val);
if (m) {
val = val.replace(/(?:^| )type:[^ ]+/,"");
typeFilter = m[1];
}
val = val.trim();
selected = -1; selected = -1;
results = []; results = [];
if (val.length > 0) { if (val.length > 0 || typeFilter) {
val = val.toLowerCase(); val = val.toLowerCase();
var i; var i;
var j; var j;
@ -96,8 +105,10 @@ RED.search = (function() {
if (kpos > -1) { if (kpos > -1) {
for (j=0;j<index[key].length;j++) { for (j=0;j<index[key].length;j++) {
var node = index[key][j]; var node = index[key][j];
nodes[node.node.id] = nodes[node.node.id] = node; if (!typeFilter || node.node.type === typeFilter) {
nodes[node.node.id].index = Math.min(nodes[node.node.id].index||Infinity,kpos); nodes[node.node.id] = nodes[node.node.id] = node;
nodes[node.node.id].index = Math.min(nodes[node.node.id].index||Infinity,kpos);
}
} }
} }
} }

View File

@ -309,7 +309,9 @@ RED.workspaces = (function() {
minimumActiveTabWidth: 150, minimumActiveTabWidth: 150,
scrollable: true, scrollable: true,
addButton: "core:add-flow", addButton: "core:add-flow",
addButtonCaption: RED._("workspace.addFlow") addButtonCaption: RED._("workspace.addFlow"),
searchButton: "core:list-flows",
searchButtonCaption: RED._("workspace.listFlows")
}); });
workspaceTabCount = 0; workspaceTabCount = 0;
} }
@ -343,6 +345,10 @@ RED.workspaces = (function() {
RED.actions.add("core:edit-flow",editWorkspace); RED.actions.add("core:edit-flow",editWorkspace);
RED.actions.add("core:remove-flow",removeWorkspace); RED.actions.add("core:remove-flow",removeWorkspace);
RED.actions.add("core:list-flows",function() {
RED.actions.invoke("core:search","type:tab ");
})
hideWorkspace(); hideWorkspace();
} }

View File

@ -133,6 +133,10 @@
&.red-ui-tabs-add.red-ui-tabs-scrollable { &.red-ui-tabs-add.red-ui-tabs-scrollable {
padding-right: 59px; padding-right: 59px;
} }
&.red-ui-tabs-add.red-ui-tabs-search.red-ui-tabs-scrollable {
padding-right: 95px;
}
&.red-ui-tabs-collapsible { &.red-ui-tabs-collapsible {
li:not(.active) { li:not(.active) {
display: none; display: none;
@ -285,6 +289,14 @@
right: 38px; right: 38px;
} }
.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-search .red-ui-tab-scroll-right {
right: 76px;
}
.red-ui-tabs.red-ui-tabs-add.red-ui-tabs-search .red-ui-tabs-add {
right: 38px;
}
img.red-ui-tab-icon { img.red-ui-tab-icon {
margin-left: -8px; margin-left: -8px;
margin-right: 3px; margin-right: 3px;