From 4864db7beca6dcb9c57d3d708235f9a65358961f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Tue, 17 Jul 2018 12:02:10 +0200 Subject: [PATCH 1/3] gui: Remove debug message --- gui/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/main.js b/gui/main.js index eac9bcf2e..68f3ae35a 100644 --- a/gui/main.js +++ b/gui/main.js @@ -263,7 +263,6 @@ const startSync = (force, ...args) => { desktop.synchronize(desktop.config.config.mode) .then(() => sendErrorToMainWindow('stopped')) .catch((err) => { - log.error({status: err.status}, 'RIGHT RIGHT HERE') if (err.status === 402) { userActionRequired = pick(err, ['title', 'code', 'detail', 'links', 'message'] From 672447902cc8f49cbc33ec6235bf3f7c57dfa713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Tue, 17 Jul 2018 12:34:05 +0200 Subject: [PATCH 2/3] gui: Introduce UserActionRequiredDialog --- .../Window/Tray/UserActionRequiredPage.elm | 1 + gui/js/components/UserActionRequiredDialog.js | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 gui/js/components/UserActionRequiredDialog.js diff --git a/gui/elm/Window/Tray/UserActionRequiredPage.elm b/gui/elm/Window/Tray/UserActionRequiredPage.elm index 47198ba97..ea13384c3 100644 --- a/gui/elm/Window/Tray/UserActionRequiredPage.elm +++ b/gui/elm/Window/Tray/UserActionRequiredPage.elm @@ -16,6 +16,7 @@ include_GDPR_link base_text url = view : Helpers -> UserActionRequiredError -> msg -> Html msg view helpers { code, title, detail, links } msg = div [ class "two-panes two-panes__content user-action-required" ] + -- Same logic as gui/js/components/UserActionRequiredDialog.js (if code == "tos-updated" then [ img [ class "error_img", src "images/tos_updated.svg" ] [] , h2 [] [ text (helpers.t "CGU Updated") ] diff --git a/gui/js/components/UserActionRequiredDialog.js b/gui/js/components/UserActionRequiredDialog.js new file mode 100644 index 000000000..6ae71ea9d --- /dev/null +++ b/gui/js/components/UserActionRequiredDialog.js @@ -0,0 +1,49 @@ +const { dialog } = require('electron') +const opn = require('opn') +const { translate } = require('../i18n') +const { logger } = require('../../../core/app') + +const log = logger({ + component: 'UserActionRequiredDialog' +}) + +module.exports = { + show +} + +function show (err) { + const userChoice = dialog.showMessageBox(null, options(err)) + if (userChoice === 0) opn(err.links.self) + else log.warn({userChoice}, 'Unexpected user choice') +} + +function options (err) { + const type = 'warning' + + // Same logic as gui/elm/UserActionRequiredPage.elm + if (err.code === 'tos-updated') { + return { + type, + title: translate('CGU Updated'), + message: translate('CGU Updated'), + detail: [ + 'CGU Updated Detail', + 'CGU Updated Required strong', + 'CGU Updated Required rest' + ].map(translate).join('. '), + buttons: [ + translate('CGU Updated See') + ] + } + } else { + return { + type, + title: err.title, + message: err.message, + detail: err.detail, + buttons: [ + translate('Error Ok') + ] + } + } +} From fca5a841b2d78fb52cfae67f2f60923df4391291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nicouleaud?= Date: Tue, 17 Jul 2018 12:34:28 +0200 Subject: [PATCH 3/3] gui: Show user action required notification on first check only So user doesn't get spammed with notifications. --- gui/main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gui/main.js b/gui/main.js index 68f3ae35a..0618c8e68 100644 --- a/gui/main.js +++ b/gui/main.js @@ -22,6 +22,7 @@ const {buildAppMenu} = require('./js/appmenu') const i18n = require('./js/i18n') const {translate} = i18n const {incompatibilitiesErrorMessage} = require('./js/incompatibilitiesmsg') +const UserActionRequiredDialog = require('./js/components/UserActionRequiredDialog') const {app, Menu, Notification, ipcMain, dialog} = require('electron') // FIXME: https://github.com/electron/electron/issues/10864 @@ -264,6 +265,10 @@ const startSync = (force, ...args) => { .then(() => sendErrorToMainWindow('stopped')) .catch((err) => { if (err.status === 402) { + // Only show notification popup on the first check (the GUI will + // include a warning anyway). + if (!userActionRequired) UserActionRequiredDialog.show(err) + userActionRequired = pick(err, ['title', 'code', 'detail', 'links', 'message'] )