From 48d0ee3b6dc5719fdd85b3b99c52aea7fd05c345 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 14 Oct 2021 10:17:27 +0100 Subject: [PATCH] Do not show projects-wecome dialog until welcome tour completes Fixes #3193 --- .../@node-red/editor-client/src/js/red.js | 19 +++++++++++++------ .../src/js/ui/projects/projects.js | 1 + .../editor-client/src/js/ui/tab-help.js | 10 +++++++++- .../editor-client/src/sass/projects.scss | 8 ++++---- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/red.js b/packages/node_modules/@node-red/editor-client/src/js/red.js index d9ef01021..be6c5472c 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/red.js +++ b/packages/node_modules/@node-red/editor-client/src/js/red.js @@ -201,6 +201,7 @@ var RED = (function() { RED.projects.refresh(function(activeProject) { loadFlows(function() { RED.sidebar.info.refresh() + var showProjectWelcome = false; if (!activeProject) { // Projects enabled but no active project RED.menu.setDisabled('menu-item-projects-open',true); @@ -208,10 +209,10 @@ var RED = (function() { if (activeProject === false) { // User previously decline the migration to projects. } else { // null/undefined - RED.projects.showStartup(); + showProjectWelcome = true; } } - completeLoad(); + completeLoad(showProjectWelcome); }); }); } else { @@ -267,7 +268,7 @@ var RED = (function() { }); } - function completeLoad() { + function completeLoad(showProjectWelcome) { var persistentNotifications = {}; RED.comms.subscribe("notification/#",function(topic,msg) { var parts = topic.split("/"); @@ -535,18 +536,24 @@ var RED = (function() { setTimeout(function() { loader.end(); - checkFirstRun(); + checkFirstRun(function() { + if (showProjectWelcome) { + RED.projects.showStartup(); + } + }); },100); } - function checkFirstRun() { + function checkFirstRun(done) { if (RED.settings.theme("tours") === false) { + done(); return; } if (!RED.settings.get("editor.view.view-show-welcome-tours", true)) { + done(); return; } - RED.actions.invoke("core:show-welcome-tour", RED.settings.get("editor.tours.welcome")); + RED.actions.invoke("core:show-welcome-tour", RED.settings.get("editor.tours.welcome"), done); } function buildMainMenu() { diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/projects/projects.js b/packages/node_modules/@node-red/editor-client/src/js/ui/projects/projects.js index 232984246..c9143ae1c 100755 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/projects/projects.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/projects/projects.js @@ -2387,6 +2387,7 @@ RED.projects = (function() { return { init: init, showStartup: function() { + console.warn("showStartup") if (!RED.user.hasPermission("projects.write")) { RED.notify(RED._("user.errors.notAuthorized"),"error"); return; diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js index fc87fcd39..66fdbeb2d 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-help.js @@ -393,10 +393,12 @@ RED.sidebar.help = (function() { treeList.treeList("select","changelog"); show(); } - function showWelcomeTour(lastSeenVersion) { + function showWelcomeTour(lastSeenVersion, done) { + done = done || function() {}; RED.tourGuide.load("./tours/welcome.js", function(err, tour) { if (err) { console.warn("Failed to load welcome tour",err); + done() return; } var currentVersionParts = RED.settings.version.split("."); @@ -405,6 +407,7 @@ RED.sidebar.help = (function() { // Only display the tour if its MAJ.MIN versions the current version // This means if we update MAJ/MIN without updating the tour, the old tour won't get shown if (tourVersionParts[0] !== currentVersionParts[0] || tourVersionParts[1] !== currentVersionParts[1]) { + done() return; } @@ -412,26 +415,31 @@ RED.sidebar.help = (function() { // Previously displayed a welcome tour. if (lastSeenVersion === RED.settings.version) { // Exact match - don't show the tour + done() return; } var lastSeenParts = lastSeenVersion.split("."); if (currentVersionParts[0] < lastSeenParts[0] || (currentVersionParts[0] === lastSeenParts[0] && currentVersionParts[1] < lastSeenParts[1])) { // Running an *older* version than last displayed tour. + done() return; } if (currentVersionParts[0] === lastSeenParts[0] && currentVersionParts[1] === lastSeenParts[1]) { if (lastSeenParts.length === 3 && currentVersionParts.length === 3) { // Matching non-beta MAJ.MIN - don't repeat tour + done() return; } if (currentVersionParts.length === 4 && (lastSeenParts.length === 3 || currentVersionParts[3] < lastSeenParts[3])) { // Running an *older* beta than last displayed tour. + done() return } } } RED.tourGuide.run("./tours/welcome.js", function(err) { RED.settings.set("editor.tours.welcome", RED.settings.version) + done() }) }) diff --git a/packages/node_modules/@node-red/editor-client/src/sass/projects.scss b/packages/node_modules/@node-red/editor-client/src/sass/projects.scss index 4c0e503c2..681e7b3f9 100644 --- a/packages/node_modules/@node-red/editor-client/src/sass/projects.scss +++ b/packages/node_modules/@node-red/editor-client/src/sass/projects.scss @@ -73,13 +73,13 @@ .red-ui-projects-dialog-screen-start { .red-ui-projects-dialog-screen-start-hero { text-align: center; - font-size: 2em; + font-size: 1.4em; padding: 10px; - min-height: 60px; + min-height: 40px; color: $primary-text-color; } .red-ui-projects-dialog-screen-start-body { - min-height: 400px; + min-height: 300px; line-height: 1.6em; p { font-size: 1.1em; @@ -92,7 +92,7 @@ } button.red-ui-button.red-ui-projects-dialog-button { width: calc(50% - 80px); - margin: 20px; + margin: 10px 20px; height: auto; line-height: 2em; padding: 10px;