diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 63ea0efe9..2a1e16f1d 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -53,8 +53,15 @@ "confirmDelete": "Confirm delete", "delete": "Are you sure you want to delete '__label__'?", "dropFlowHere": "Drop the flow here", - "addFlow": "Add Flow", - "listFlows": "List Flows", + "addFlow": "Add flow", + "addFlowToRight": "Add flow to the right", + "hideFlow": "Hide flow", + "hideOtherFlows": "Hide other flows", + "showAllFlows": "Show all flows", + "hideAllFlows": "Hide all flows", + "showLastHiddenFlow": "Show last hidden flow", + "listFlows": "List flows", + "listSubflows": "List subflows", "status": "Status", "enabled": "Enabled", "disabled":"Disabled", diff --git a/packages/node_modules/@node-red/editor-client/src/js/keymap.json b/packages/node_modules/@node-red/editor-client/src/js/keymap.json index c50508389..766f6bd9f 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/keymap.json +++ b/packages/node_modules/@node-red/editor-client/src/js/keymap.json @@ -25,7 +25,9 @@ "ctrl-alt-o": "core:open-project", "ctrl-g v": "core:show-version-control-tab", "ctrl-shift-l": "core:show-event-log", - "ctrl-shift-p":"core:show-action-list" + "ctrl-shift-p":"core:show-action-list", + "alt-w": "core:hide-flow", + "alt-shift-w": "core:show-last-hidden-flow" }, "red-ui-sidebar-node-config": { "backspace": "core:delete-config-selection", diff --git a/packages/node_modules/@node-red/editor-client/src/js/settings.js b/packages/node_modules/@node-red/editor-client/src/js/settings.js index 39f372974..467c5b569 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/settings.js +++ b/packages/node_modules/@node-red/editor-client/src/js/settings.js @@ -220,6 +220,16 @@ RED.settings = (function () { return defaultValue; } } + function getLocal(key) { + return localStorage.getItem(key) + } + function setLocal(key, value) { + localStorage.setItem(key, value); + } + function removeLocal(key) { + localStorage.removeItem(key) + } + return { init: init, @@ -228,6 +238,9 @@ RED.settings = (function () { set: set, get: get, remove: remove, - theme: theme + theme: theme, + setLocal: setLocal, + getLocal: getLocal, + removeLocal: removeLocal } })(); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js index 485b43d98..b38017c60 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js @@ -498,6 +498,13 @@ RED.clipboard = (function() { $("#red-ui-clipboard-dialog-import-text").on("keyup", validateImport); $("#red-ui-clipboard-dialog-import-text").on('paste',function() { setTimeout(validateImport,10)}); + if (RED.workspaces.active() === 0) { + $("#red-ui-clipboard-dialog-import-opt-current").addClass('disabled').removeClass("selected"); + $("#red-ui-clipboard-dialog-import-opt-new").addClass("selected"); + } else { + $("#red-ui-clipboard-dialog-import-opt-current").removeClass('disabled').addClass("selected"); + $("#red-ui-clipboard-dialog-import-opt-new").removeClass("selected"); + } $("#red-ui-clipboard-dialog-import-opt > a").on("click", function(evt) { evt.preventDefault(); if ($(this).hasClass('disabled') || $(this).hasClass('selected')) { @@ -611,9 +618,6 @@ RED.clipboard = (function() { activeLibraries[tabId] = browser; }) - - - $("#red-ui-clipboard-dialog-tab-library-name").on("keyup", validateExportFilename); $("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)}); $("#red-ui-clipboard-dialog-export").button("enable"); @@ -636,7 +640,6 @@ RED.clipboard = (function() { label: RED._("editor.types.json") }); - var previewList = $("#red-ui-clipboard-dialog-export-tab-clipboard-preview-list").css({position:"absolute",top:0,right:0,bottom:0,left:0}).treeList({ data: [] }) @@ -738,16 +741,22 @@ RED.clipboard = (function() { $("#red-ui-clipboard-dialog-export").hide(); $("#red-ui-clipboard-dialog-import-conflict").hide(); - var selection = RED.workspaces.selection(); - if (selection.length > 0) { - $("#red-ui-clipboard-dialog-export-rng-selected").trigger("click"); + if (RED.workspaces.active() === 0) { + $("#red-ui-clipboard-dialog-export-rng-selected").addClass('disabled').removeClass('selected'); + $("#red-ui-clipboard-dialog-export-rng-flow").addClass('disabled').removeClass('selected'); + $("#red-ui-clipboard-dialog-export-rng-full").trigger("click"); } else { - selection = RED.view.selection(); - if (selection.nodes) { + var selection = RED.workspaces.selection(); + if (selection.length > 0) { $("#red-ui-clipboard-dialog-export-rng-selected").trigger("click"); } else { - $("#red-ui-clipboard-dialog-export-rng-selected").addClass('disabled').removeClass('selected'); - $("#red-ui-clipboard-dialog-export-rng-flow").trigger("click"); + selection = RED.view.selection(); + if (selection.nodes) { + $("#red-ui-clipboard-dialog-export-rng-selected").trigger("click"); + } else { + $("#red-ui-clipboard-dialog-export-rng-selected").addClass('disabled').removeClass('selected'); + $("#red-ui-clipboard-dialog-export-rng-flow").trigger("click"); + } } } if (format === "red-ui-clipboard-dialog-export-fmt-full") { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js index e8c678333..f1239edef 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js @@ -82,7 +82,7 @@ RED.menu = (function() { linkContent += ''+RED.keyboard.formatKey(shortcut.key, true)+'').appendTo(link); + opt.shortcutSpan = $(''+RED.keyboard.formatKey(shortcut.key, true)+'').appendTo(link.find(".red-ui-menu-label")); } } diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js index 41c6e704c..9bc52d5fc 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js @@ -38,6 +38,7 @@ RED.tabs = (function() { if (options.vertical) { wrapper.addClass("red-ui-tabs-vertical"); } + if (options.addButton) { wrapper.addClass("red-ui-tabs-add"); var addButton = $('
' } else { - linkContent += ' ' + linkContent += ' ' } linkContent += ''; @@ -92,7 +92,7 @@ RED.menu = (function() { if (typeof opt.onselect === 'string') { var shortcut = RED.keyboard.getShortcut(opt.onselect); if (shortcut && shortcut.key) { - opt.shortcutSpan = $(' ').appendTo(wrapper); @@ -75,6 +76,8 @@ RED.tabs = (function() { }); } if (options.searchButton) { + // This is soft-deprecated as we don't use this in the core anymore + // We no use the `menu` option to provide a drop-down list of actions wrapper.addClass("red-ui-tabs-search"); var searchButton = $(' ').appendTo(wrapper); searchButton.find('a').on("click", function(evt) { @@ -94,6 +97,48 @@ RED.tabs = (function() { } } + if (options.menu) { + wrapper.addClass("red-ui-tabs-menu"); + var menuButton = $(' ').appendTo(wrapper); + var menuButtonLink = menuButton.find('a') + var menuOpen = false; + menuButtonLink.on("click", function(evt) { + evt.stopPropagation(); + evt.preventDefault(); + if (menuOpen) { + menu.remove(); + menuOpen = false; + return; + } + menuOpen = true; + var menuOptions = []; + if (typeof options.searchButton === 'function') { + menuOptions = options.menu() + } else if (Array.isArray(options.menu)) { + menuOptions = options.menu; + } + var menu = RED.menu.init({options: menuOptions}); + menu.css({ + position: "absolute" + }) + menu.appendTo("body"); + var elementPos = menuButton.offset(); + menu.css({ + top: (elementPos.top+menuButton.height()-2)+"px", + left: (elementPos.left - menu.width() + menuButton.width())+"px" + }) + $(".red-ui-menu.red-ui-menu-dropdown").hide(); + $(document).on("click.red-ui-tabmenu", function(evt) { + $(document).off("click.red-ui-tabmenu"); + menuOpen = false; + menu.remove(); + }); + menu.show(); + }) + } + + + var scrollLeft; var scrollRight; @@ -337,6 +382,12 @@ RED.tabs = (function() { if (link.length === 0) { return; } + if (link.parent().hasClass("hide-tab")) { + link.parent().removeClass("hide-tab").removeClass("hide"); + if (options.onshow) { + options.onshow(tabs[link.attr('href').slice(1)]) + } + } if (!link.parent().hasClass("active")) { ul.children().removeClass("active"); ul.children().css({"transition": "width 100ms"}); @@ -362,13 +413,13 @@ RED.tabs = (function() { } } function activatePreviousTab() { - var previous = ul.find("li.active").prev(); + var previous = findPreviousVisibleTab(); if (previous.length > 0) { activateTab(previous.find("a")); } } function activateNextTab() { - var next = ul.find("li.active").next(); + var next = findNextVisibleTab(); if (next.length > 0) { activateTab(next.find("a")); } @@ -378,7 +429,9 @@ RED.tabs = (function() { if (options.vertical) { return; } - var tabs = ul.find("li.red-ui-tab"); + var allTabs = ul.find("li.red-ui-tab"); + var tabs = allTabs.filter(":not(.hide-tab)"); + var hiddenTabs = allTabs.filter(".hide-tab"); var width = wrapper.width(); var tabCount = tabs.length; var tabWidth; @@ -446,6 +499,7 @@ RED.tabs = (function() { // } tabs.css({width:currentTabWidth}); + hiddenTabs.css({width:"0px"}); if (tabWidth < 50) { // ul.find(".red-ui-tab-close").hide(); ul.find(".red-ui-tab-icon").hide(); @@ -486,24 +540,101 @@ RED.tabs = (function() { } var li = ul.find("a[href='#"+id+"']").parent(); if (li.hasClass("active")) { - var tab = li.prev(); + var tab = findPreviousVisibleTab(li); if (tab.length === 0) { - tab = li.next(); + tab = findNextVisibleTab(li); + } + if (tab.length > 0) { + activateTab(tab.find("a")); + } else { + if (options.onchange) { + options.onchange(null); + } } - activateTab(tab.find("a")); } - li.remove(); - if (tabs[id].pinned) { - pinnedTabsCount--; + + li.one("transitionend", function(evt) { + li.remove(); + if (tabs[id].pinned) { + pinnedTabsCount--; + } + if (options.onremove) { + options.onremove(tabs[id]); + } + delete tabs[id]; + updateTabWidths(); + if (collapsibleMenu) { + collapsibleMenu.remove(); + collapsibleMenu = null; + } + }) + li.addClass("hide-tab"); + li.width(0); + } + + function findPreviousVisibleTab(li) { + if (!li) { + li = ul.find("li.active").parent(); } - if (options.onremove) { - options.onremove(tabs[id]); + var previous = li.prev(); + while(previous.length > 0 && previous.hasClass("hide-tab")) { + previous = previous.prev(); } - delete tabs[id]; - updateTabWidths(); - if (collapsibleMenu) { - collapsibleMenu.remove(); - collapsibleMenu = null; + return previous; + } + function findNextVisibleTab(li) { + if (!li) { + li = ul.find("li.active").parent(); + } + var next = ul.find("li.active").next(); + while(next.length > 0 && next.hasClass("hide-tab")) { + next = next.next(); + } + return next; + } + function showTab(id) { + if (tabs[id]) { + var li = ul.find("a[href='#"+id+"']").parent(); + if (li.hasClass("hide-tab")) { + li.removeClass("hide-tab").removeClass("hide"); + if (ul.find("li.red-ui-tab:not(.hide-tab)").length === 1) { + activateTab(li.find("a")) + } + updateTabWidths(); + if (options.onshow) { + options.onshow(tabs[id]) + } + } + } + } + function hideTab(id) { + if (tabs[id]) { + var li = ul.find("a[href='#"+id+"']").parent(); + if (!li.hasClass("hide-tab")) { + if (li.hasClass("active")) { + var tab = findPreviousVisibleTab(li); + if (tab.length === 0) { + tab = findNextVisibleTab(li); + } + if (tab.length > 0) { + activateTab(tab.find("a")); + } else { + if (options.onchange) { + options.onchange(null); + } + } + } + li.removeClass("active"); + li.one("transitionend", function(evt) { + li.addClass("hide"); + updateTabWidths(); + if (options.onhide) { + options.onhide(tabs[id]) + } + }) + li.addClass("hide-tab"); + li.css({width:0}) + } } } @@ -663,7 +794,6 @@ RED.tabs = (function() { link.on("click", function(evt) { evt.preventDefault(); }) link.on("dblclick", function(evt) { evt.stopPropagation(); evt.preventDefault(); }) - $('').appendTo(li); if (tab.closeable) { @@ -675,6 +805,15 @@ RED.tabs = (function() { removeTab(tab.id); }); } + if (tab.hideable) { + li.addClass("red-ui-tabs-closeable") + var closeLink = $("",{href:"#",class:"red-ui-tab-close"}).appendTo(li); + closeLink.append(''); + closeLink.on("click",function(event) { + event.preventDefault(); + hideTab(tab.id); + }); + } var badges = $('').appendTo(li); if (options.onselect) { @@ -682,11 +821,11 @@ RED.tabs = (function() { $('').appendTo(badges); } + link.attr("title",tab.label); if (options.onadd) { options.onadd(tab); } - link.attr("title",tab.label); if (ul.find("li.red-ui-tab").length == 1) { activateTab(link); } @@ -787,7 +926,7 @@ RED.tabs = (function() { previousTab: activatePreviousTab, resize: updateTabWidths, count: function() { - return ul.find("li.red-ui-tab").length; + return ul.find("li.red-ui-tab:not(.hide)").length; }, activeIndex: function() { return ul.find("li.active").index() @@ -795,6 +934,9 @@ RED.tabs = (function() { contains: function(id) { return ul.find("a[href='#"+id+"']").length > 0; }, + showTab: showTab, + hideTab: hideTab, + renameTab: function(id,label) { tabs[id].label = label; var tab = ul.find("a[href='#"+id+"']"); @@ -802,7 +944,20 @@ RED.tabs = (function() { tab.find("span.red-ui-text-bidi-aware").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label)); updateTabWidths(); }, + listTabs: function() { + return $.makeArray(ul.children().map(function() { return $(this).data('tabId');})); + }, selection: getSelection, + clearSelection: function() { + if (options.onselect) { + var selection = ul.find("li.red-ui-tab.selected"); + if (selection.length > 0) { + selection.removeClass("selected"); + selectionChanged(); + } + } + + }, order: function(order) { preferredOrder = order; var existingTabOrder = $.makeArray(ul.children().map(function() { return $(this).data('tabId');})); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js index 6619ad76e..19d65c591 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/treeList.js @@ -532,8 +532,8 @@ }).appendTo(label) } - var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(depth*20); - // var labelPaddingWidth = (item.gutter ? item.gutter[0].offsetWidth + 2 : 0) + (depth * 20) + // var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(depth*20); + var labelPaddingWidth = (item.gutter ? item.gutter[0].offsetWidth + 2 : 0) + (depth * 20) item.treeList.labelPadding = $('').css({ display: "inline-block", width: labelPaddingWidth+'px' diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js index c16be54e2..492600f91 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js @@ -229,7 +229,7 @@ RED.sidebar.config = (function() { var globalConfigNodes = []; var configList = {}; RED.nodes.eachConfig(function(cn) { - if (cn.z) {//} == RED.workspaces.active()) { + if (cn.z) { configList[cn.z.replace(/\./g,"-")] = configList[cn.z.replace(/\./g,"-")]||[]; configList[cn.z.replace(/\./g,"-")].push(cn); } else if (!cn.z) { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js index f77b5f010..52606cd88 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js @@ -122,11 +122,20 @@ RED.sidebar.info.outliner = (function() { }) RED.popover.tooltip(triggerButton,RED._("sidebar.info.triggerAction")); } - // $('').appendTo(controls).on("click",function(evt) { - // evt.preventDefault(); - // evt.stopPropagation(); - // RED.view.reveal(n.id); - // }) + + if (n.type === "tab") { + var toggleVisibleButton = $('').appendTo(controls).on("click",function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + var isHidden = !div.hasClass("red-ui-info-outline-item-hidden"); + div.toggleClass("red-ui-info-outline-item-hidden",isHidden); + if (isHidden) { + RED.workspaces.hide(n.id); + } else { + RED.workspaces.show(n.id, null, true); + } + }); + } if (n.type !== 'subflow') { var toggleButton = $('').appendTo(controls).on("click",function(evt) { evt.preventDefault(); @@ -317,13 +326,27 @@ RED.sidebar.info.outliner = (function() { RED.events.on("groups:remove",onObjectRemove); RED.events.on("groups:change",onNodeChange); - RED.events.on("workspace:clear", onWorkspaceClear) + RED.events.on("workspace:show", onWorkspaceShow); + RED.events.on("workspace:hide", onWorkspaceHide); + RED.events.on("workspace:clear", onWorkspaceClear); return container; } function onWorkspaceClear() { treeList.treeList('data',getFlowData()); } + function onWorkspaceShow(event) { + var existingObject = objects[event.workspace]; + if (existingObject) { + existingObject.element.removeClass("red-ui-info-outline-item-hidden") + } + } + function onWorkspaceHide(event) { + var existingObject = objects[event.workspace]; + if (existingObject) { + existingObject.element.addClass("red-ui-info-outline-item-hidden") + } + } function onFlowAdd(ws) { objects[ws.id] = { id: ws.id, diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js index 15b705448..017172a23 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js @@ -180,6 +180,10 @@ RED.sidebar.info = (function() { if (node === null) { RED.sidebar.info.outliner.select(null); + propertiesPanelHeaderIcon.empty(); + propertiesPanelHeaderLabel.text(""); + propertiesPanelHeaderReveal.hide(); + propertiesPanelHeaderHelp.hide(); return; } else if (Array.isArray(node)) { // Multiple things selected diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index d154fe865..8ccbf6fe4 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -345,8 +345,8 @@ RED.view = (function() { activeSubflow = RED.nodes.subflow(event.workspace); - RED.menu.setDisabled("menu-item-workspace-edit", activeSubflow); - RED.menu.setDisabled("menu-item-workspace-delete",RED.workspaces.count() == 1 || activeSubflow); + RED.menu.setDisabled("menu-item-workspace-edit", activeSubflow || event.workspace === 0); + RED.menu.setDisabled("menu-item-workspace-delete",event.workspace === 0 || RED.workspaces.count() == 1 || activeSubflow); if (workspaceScrollPositions[event.workspace]) { chart.scrollLeft(workspaceScrollPositions[event.workspace].left); @@ -675,27 +675,33 @@ RED.view = (function() { function updateActiveNodes() { var activeWorkspace = RED.workspaces.active(); + if (activeWorkspace !== 0) { + activeNodes = RED.nodes.filterNodes({z:activeWorkspace}); + activeNodes.forEach(function(n,i) { + n._index = i; + }) + activeLinks = RED.nodes.filterLinks({ + source:{z:activeWorkspace}, + target:{z:activeWorkspace} + }); - activeNodes = RED.nodes.filterNodes({z:activeWorkspace}); - activeNodes.forEach(function(n,i) { - n._index = i; - }) - activeLinks = RED.nodes.filterLinks({ - source:{z:activeWorkspace}, - target:{z:activeWorkspace} - }); + activeGroups = RED.nodes.groups(activeWorkspace)||[]; + activeGroups.forEach(function(g, i) { + g._index = i; + if (g.g) { + g._root = g.g; + g._depth = 1; + } else { + g._root = g.id; + g._depth = 0; + } + }); + } else { + activeNodes = []; + activeLinks = []; + activeGroups = []; + } - activeGroups = RED.nodes.groups(activeWorkspace)||[]; - activeGroups.forEach(function(g,i) { - g._index = i; - if (g.g) { - g._root = g.g; - g._depth = 1; - } else { - g._root = g.id; - g._depth = 0; - } - }); var changed = false; do { changed = false; @@ -1966,93 +1972,94 @@ RED.view = (function() { function updateSelection() { var selection = {}; var activeWorkspace = RED.workspaces.active(); - var workspaceSelection = RED.workspaces.selection(); - if (workspaceSelection.length === 0) { - selection = getSelection(); - activeLinks = RED.nodes.filterLinks({ - source:{z:activeWorkspace}, - target:{z:activeWorkspace} - }); - var tabOrder = RED.nodes.getWorkspaceOrder(); - var currentLinks = activeLinks; - var addedLinkLinks = {}; - activeFlowLinks = []; - var activeLinkNodeIds = Object.keys(activeLinkNodes); - activeLinkNodeIds.forEach(function(n) { - activeLinkNodes[n].dirty = true; - }) - activeLinkNodes = {}; - for (var i=0;i