Skip to content

Commit

Permalink
gui: Introduce UserActionRequiredDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
sebn committed Jul 17, 2018
1 parent 4864db7 commit 6724479
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions gui/elm/Window/Tray/UserActionRequiredPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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") ]
Expand Down
49 changes: 49 additions & 0 deletions gui/js/components/UserActionRequiredDialog.js
Original file line number Diff line number Diff line change
@@ -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')
]
}
}
}

0 comments on commit 6724479

Please sign in to comment.