From 13356047dc019ee770b9bbfb42537f6291cf6771 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 9 Jan 2018 15:06:05 +0000 Subject: [PATCH] Better handling of empty projects and lifecycle --- editor/js/main.js | 5 +- editor/js/ui/notifications.js | 18 ++++++- editor/js/ui/projects/projects.js | 3 +- editor/js/ui/tab-info.js | 2 +- editor/sass/notifications.scss | 4 ++ editor/sass/projects.scss | 4 +- red/api/editor/locales/en-US/editor.json | 6 +-- .../localfilesystem/projects/Project.js | 43 ++++++++++++---- .../localfilesystem/projects/git/index.js | 51 +++++++++++-------- 9 files changed, 96 insertions(+), 40 deletions(-) diff --git a/editor/js/main.js b/editor/js/main.js index 09750b85e..9352cd18d 100644 --- a/editor/js/main.js +++ b/editor/js/main.js @@ -118,6 +118,7 @@ text: "Setup project files", click: function() { persistentNotifications[notificationId].close(); + delete persistentNotifications[notificationId]; RED.projects.showFilesPrompt(); } } @@ -128,11 +129,13 @@ text: "No thanks", click: function() { persistentNotifications[notificationId].close(); + delete persistentNotifications[notificationId]; } }, { text: "Create default project files", click: function() { persistentNotifications[notificationId].close(); + delete persistentNotifications[notificationId]; RED.projects.createDefaultFileSet(); } } @@ -142,7 +145,7 @@ if (!persistentNotifications.hasOwnProperty(notificationId)) { persistentNotifications[notificationId] = RED.notify(text,options); } else { - persistentNotifications[notificationId].update(text,msg.timeout); + persistentNotifications[notificationId].update(text,options); } } else if (persistentNotifications.hasOwnProperty(notificationId)) { persistentNotifications[notificationId].close(); diff --git a/editor/js/ui/notifications.js b/editor/js/ui/notifications.js index 1e2a50d53..e09c1f22d 100644 --- a/editor/js/ui/notifications.js +++ b/editor/js/ui/notifications.js @@ -85,18 +85,34 @@ RED.notify = (function() { n.update = (function() { var nn = n; - return function(msg,timeout) { + return function(msg,options) { if (typeof msg === "string") { nn.innerHTML = msg; } else { $(nn).empty().append(msg); } + var timeout; + if (typeof options === 'number') { + timeout = options; + } else if (options !== undefined) { + timeout = options.timeout; + if (options.buttons) { + var buttonSet = $('
').appendTo(nn) + options.buttons.forEach(function(buttonDef) { + var b = $('