From 9edfc97c4f671e4d13d636e42ec815f2253d2b73 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Mon, 3 Dec 2018 17:37:34 +0800 Subject: [PATCH 01/22] Change default login popup to our own panel variant --- src/botPage/view/View.js | 17 +++++++++++------ templates/bot.mustache | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/botPage/view/View.js b/src/botPage/view/View.js index 60ab200186..e23c6db128 100644 --- a/src/botPage/view/View.js +++ b/src/botPage/view/View.js @@ -226,10 +226,10 @@ const applyToolboxPermissions = () => { } }; -const showReloadPopup = () => +const showPopup = selector => new Promise((resolve, reject) => { setBeforeUnload(true); - $('#reloadPanel').dialog({ + $(selector).dialog({ height: 'auto', width : 600, modal : true, @@ -258,7 +258,7 @@ const showReloadPopup = () => }, ], }); - $('#reloadPanel').dialog('open'); + $(selector).dialog('open'); }); export default class View { @@ -373,7 +373,7 @@ export default class View { }); }; const logout = () => { - showReloadPopup() + showPopup('#reloadPanel') .then(() => { removeTokens(); }) @@ -539,7 +539,7 @@ export default class View { }); $('.login-id-list').on('click', 'a', e => { - showReloadPopup() + showPopup('#reloadPanel') .then(() => { const activeToken = $(e.currentTarget).attr('value'); const tokenList = getTokenList(); @@ -554,7 +554,12 @@ export default class View { $('#login') .bind('click.login', () => { - document.location = getOAuthURL(); + const test = showPopup('#loginPanel'); + test + .then(() => { + document.location = getOAuthURL(); + }) + .catch(() => {}); }) .text('Log in'); diff --git a/templates/bot.mustache b/templates/bot.mustache index 048877836d..b95f2f54fe 100644 --- a/templates/bot.mustache +++ b/templates/bot.mustache @@ -25,6 +25,9 @@

+
+

+
From a4d439e3e85aef823a53fedf512866d5ac1964c5 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Mon, 3 Dec 2018 17:46:14 +0800 Subject: [PATCH 02/22] Update 'Reset'-button location and behaviour --- src/botPage/view/View.js | 8 ++++++-- templates/bot.mustache | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/botPage/view/View.js b/src/botPage/view/View.js index e23c6db128..1a7072a660 100644 --- a/src/botPage/view/View.js +++ b/src/botPage/view/View.js @@ -534,8 +534,12 @@ export default class View { .hide(); $('#resetButton').click(() => { - this.blockly.resetWorkspace(); - setTimeout(() => this.blockly.cleanUp(), 0); + showPopup('#reloadPanel') + .then(() => { + this.blockly.resetWorkspace(); + setTimeout(() => this.blockly.cleanUp(), 0); + }) + .catch(() => {}); }); $('.login-id-list').on('click', 'a', e => { diff --git a/templates/bot.mustache b/templates/bot.mustache index b95f2f54fe..b333fd04b9 100644 --- a/templates/bot.mustache +++ b/templates/bot.mustache @@ -129,12 +129,12 @@ - +
From 9cade9af1ec24745586f13ed9d292304ebcbdf5a Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Mon, 3 Dec 2018 18:18:39 +0800 Subject: [PATCH 03/22] Suppress tour popup for 24 hours after user hides it --- src/botPage/view/tour/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/botPage/view/tour/index.js b/src/botPage/view/tour/index.js index 81aa7eeabf..b46de31ea6 100644 --- a/src/botPage/view/tour/index.js +++ b/src/botPage/view/tour/index.js @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import Joyride from 'react-joyride'; -import { setDone, isDone } from '../../../common/utils/storageManager'; +import { set, get, setDone, isDone } from '../../../common/utils/storageManager'; import { translate } from '../../../common/i18n'; import welcome from './welcome'; @@ -24,6 +24,7 @@ class Tour extends PureComponent { next: () => this.joyride.next(), stop: () => { setDoneCheck(); + set('closedTourPopup', Date.now()); this.joyride.stop(); }, }; @@ -35,8 +36,12 @@ class Tour extends PureComponent { setDoneCheck(); } }; + const shouldShowTourPopup = () => { + const timeDifference = Date.now() - (parseInt(get('closedTourPopup')) || 0); + return !isDone('welcomeFinished') && timeDifference > 24 * 60 * 60 * 1000; + }; return ( - !isDone('welcomeFinished') && ( + shouldShowTourPopup() && (
Date: Mon, 3 Dec 2018 19:49:47 +0800 Subject: [PATCH 04/22] Remove test variable --- src/botPage/view/View.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/botPage/view/View.js b/src/botPage/view/View.js index 1a7072a660..c5146f111a 100644 --- a/src/botPage/view/View.js +++ b/src/botPage/view/View.js @@ -558,8 +558,7 @@ export default class View { $('#login') .bind('click.login', () => { - const test = showPopup('#loginPanel'); - test + showPopup('#loginPanel') .then(() => { document.location = getOAuthURL(); }) From 187dc4996f22012c30ad004589c055afdc2064a0 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Tue, 4 Dec 2018 13:52:21 +0800 Subject: [PATCH 05/22] Update confirmation message when attempting login --- src/botPage/view/View.js | 2 +- templates/bot.mustache | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/botPage/view/View.js b/src/botPage/view/View.js index c5146f111a..4facccbcb1 100644 --- a/src/botPage/view/View.js +++ b/src/botPage/view/View.js @@ -543,7 +543,7 @@ export default class View { }); $('.login-id-list').on('click', 'a', e => { - showPopup('#reloadPanel') + showPopup('#unsavedPanel') .then(() => { const activeToken = $(e.currentTarget).attr('value'); const tokenList = getTokenList(); diff --git a/templates/bot.mustache b/templates/bot.mustache index b333fd04b9..80f67149cc 100644 --- a/templates/bot.mustache +++ b/templates/bot.mustache @@ -25,11 +25,13 @@

+
+

+
-

+

-