mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Remember last sidebar tab between editor sessions
This commit is contained in:
		@@ -556,8 +556,7 @@ var RED = (function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $(".red-ui-header-toolbar").show();
 | 
					        $(".red-ui-header-toolbar").show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RED.sidebar.show(":first", true);
 | 
				
			||||||
        RED.sidebar.show(":first");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        setTimeout(function() {
 | 
					        setTimeout(function() {
 | 
				
			||||||
            loader.end();
 | 
					            loader.end();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,15 @@ RED.sidebar = (function() {
 | 
				
			|||||||
    var sidebar_tabs;
 | 
					    var sidebar_tabs;
 | 
				
			||||||
    var knownTabs = {};
 | 
					    var knownTabs = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // We store the current sidebar tab id in localStorage as 'last-sidebar-tab'
 | 
				
			||||||
 | 
					    // This is restored when the editor is reloaded.
 | 
				
			||||||
 | 
					    // We use sidebar_tabs.onchange to update localStorage. However that will
 | 
				
			||||||
 | 
					    // also get triggered when the first tab gets added to the tabs - typically
 | 
				
			||||||
 | 
					    // the 'info' tab. So we use the following variable to store the retrieved
 | 
				
			||||||
 | 
					    // value from localStorage before we start adding the actual tabs
 | 
				
			||||||
 | 
					    var lastSessionSelectedTab = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function addTab(title,content,closeable,visible) {
 | 
					    function addTab(title,content,closeable,visible) {
 | 
				
			||||||
        var options;
 | 
					        var options;
 | 
				
			||||||
        if (typeof title === "string") {
 | 
					        if (typeof title === "string") {
 | 
				
			||||||
@@ -194,16 +203,16 @@ RED.sidebar = (function() {
 | 
				
			|||||||
        RED.events.emit("sidebar:resize");
 | 
					        RED.events.emit("sidebar:resize");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function showSidebar(id) {
 | 
					    function showSidebar(id, skipShowSidebar) {
 | 
				
			||||||
        if (id === ":first") {
 | 
					        if (id === ":first") {
 | 
				
			||||||
            id = RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0]
 | 
					            id = lastSessionSelectedTab || RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (id) {
 | 
					        if (id) {
 | 
				
			||||||
            if (!containsTab(id) && knownTabs[id]) {
 | 
					            if (!containsTab(id) && knownTabs[id]) {
 | 
				
			||||||
                sidebar_tabs.addTab(knownTabs[id]);
 | 
					                sidebar_tabs.addTab(knownTabs[id]);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            sidebar_tabs.activateTab(id);
 | 
					            sidebar_tabs.activateTab(id);
 | 
				
			||||||
            if (!RED.menu.isSelected("menu-item-sidebar")) {
 | 
					            if (!skipShowSidebar && !RED.menu.isSelected("menu-item-sidebar")) {
 | 
				
			||||||
                RED.menu.setSelected("menu-item-sidebar",true);
 | 
					                RED.menu.setSelected("menu-item-sidebar",true);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -227,6 +236,7 @@ RED.sidebar = (function() {
 | 
				
			|||||||
                if (tab.toolbar) {
 | 
					                if (tab.toolbar) {
 | 
				
			||||||
                    $(tab.toolbar).show();
 | 
					                    $(tab.toolbar).show();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                RED.settings.setLocal("last-sidebar-tab", tab.id)
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            onremove: function(tab) {
 | 
					            onremove: function(tab) {
 | 
				
			||||||
                $(tab.wrapper).hide();
 | 
					                $(tab.wrapper).hide();
 | 
				
			||||||
@@ -255,7 +265,9 @@ RED.sidebar = (function() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        RED.popover.tooltip($("#red-ui-sidebar-separator").find(".red-ui-sidebar-control-right"),RED._("keyboard.toggleSidebar"),"core:toggle-sidebar");
 | 
					        RED.popover.tooltip($("#red-ui-sidebar-separator").find(".red-ui-sidebar-control-right"),RED._("keyboard.toggleSidebar"),"core:toggle-sidebar");
 | 
				
			||||||
        showSidebar();
 | 
					
 | 
				
			||||||
 | 
					        lastSessionSelectedTab = RED.settings.getLocal("last-sidebar-tab")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        RED.sidebar.info.init();
 | 
					        RED.sidebar.info.init();
 | 
				
			||||||
        RED.sidebar.help.init();
 | 
					        RED.sidebar.help.init();
 | 
				
			||||||
        RED.sidebar.config.init();
 | 
					        RED.sidebar.config.init();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user