diff --git a/app/extensions/brave/locales/en-US/app.properties b/app/extensions/brave/locales/en-US/app.properties index 97a698bc4c8..688d83902ad 100644 --- a/app/extensions/brave/locales/en-US/app.properties +++ b/app/extensions/brave/locales/en-US/app.properties @@ -259,3 +259,9 @@ preventMoreAlerts=Prevent this page from creating additional dialogs copied=Copied! connectionError=Server connection failed. Please make sure you are connected to the Internet. unknownError=Oops, something went wrong. + +modalBackupLedgerTitle=Backup ledger wallet +modalBackupLedgerSubTitle=Your Brave wallet has received new founds. +modalBackupLedgerSubTitle2=Would you like to backup your wallet now? +modalBackupLedgerContent=If your computer malfunctions, or if you change computers, recovery keys are required to restore your Brave wallet. You can back up your wallet at any time through Brave Payments Advanced Options. +modalBackupLedgerLater=Remind me diff --git a/app/renderer/components/modals/backupLedger.js b/app/renderer/components/modals/backupLedger.js new file mode 100644 index 00000000000..4797b97fa36 --- /dev/null +++ b/app/renderer/components/modals/backupLedger.js @@ -0,0 +1,38 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const React = require('react') + +// components +const ImmutableComponent = require('../../../../js/components/immutableComponent') +const ModalOverlay = require('../../../../js/components/modalOverlay') +const appActions = require('../../../../js/actions/appActions') + +class ModalBackupLedger extends ImmutableComponent { + modalHidden () { + } + + closeModal () { + appActions.hideModal('ledgerBackup') + } + + render () { + return +
+
+
+
+ } + footer={ +
+ } + onHide={this.modalHidden.bind(this)} + /> + } +} + +module.exports = ModalBackupLedger diff --git a/app/renderer/components/modals/container.js b/app/renderer/components/modals/container.js new file mode 100644 index 00000000000..0150b0a921e --- /dev/null +++ b/app/renderer/components/modals/container.js @@ -0,0 +1,34 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const React = require('react') +const ImmutableComponent = require('../../../../js/components/immutableComponent') +const ModalBackupLedger = require('./backupLedger') + +class ModalsContainer extends ImmutableComponent { + render () { + console.log(this.props.modals) + return
+ {this.props.modals.map((modal) => { + const found = modals.find((item) => { + return item.id === modal.get('id') + }) + + if (found) { + const Slug = found.component + return + } + + return null + })} +
+ } +} + +module.exports = ModalsContainer + +const modals = [{ + id: 'ledgerBackup', + component: ModalBackupLedger +}] diff --git a/docs/appActions.md b/docs/appActions.md index 837583d51a9..e12cd5ad50f 100644 --- a/docs/appActions.md +++ b/docs/appActions.md @@ -835,6 +835,26 @@ Update ledger publishers pinned percentages according to the new synopsis +### showModal(id) + +Shows a modal in the modals container + +**Parameters** + +**id**: `string`, modal id + + + +### hideModal(id) + +Hide a modal from the modals container + +**Parameters** + +**id**: `string`, modal id + + + * * * diff --git a/docs/state.md b/docs/state.md index fe056d64ec8..c81866354c5 100644 --- a/docs/state.md +++ b/docs/state.md @@ -126,6 +126,11 @@ AppStore menu: { template: object // used on Windows and by our tests: template object with Menubar control }, + modals: [{ + closeOnClose: Array, // modal id's that should be closed when this modal is closed + closeOnOpen: Array|boolean, // modal id's that should be closed when this modal is opened, true to close all + id: string // modal id + }], notifications: [{ buttons: [{ className: string, // button class e.g. 'primary'. see notificationBar.less diff --git a/js/actions/appActions.js b/js/actions/appActions.js index d452226780d..2787516eb0c 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -1023,6 +1023,28 @@ const appActions = { actionType: appConstants.APP_CHANGE_LEDGER_PINNED_PERCENTAGES, publishers }) + }, + + /** + * Shows a modal in the modals container + * @param id {string} modal id + */ + showModal: function (id) { + AppDispatcher.dispatch({ + actionType: appConstants.APP_SHOW_MODAL, + id + }) + }, + + /** + * Hide a modal from the modals container + * @param id {string} modal id + */ + hideModal: function (id) { + AppDispatcher.dispatch({ + actionType: appConstants.APP_HIDE_MODAL, + id + }) } } diff --git a/js/components/main.js b/js/components/main.js index 7e5f91ca6b4..003ef33f795 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -46,6 +46,7 @@ const LongPressButton = require('./longPressButton') const Menubar = require('../../app/renderer/components/menubar') const WindowCaptionButtons = require('../../app/renderer/components/windowCaptionButtons') const CheckDefaultBrowserDialog = require('../../app/renderer/components/checkDefaultBrowserDialog') +const ModalsContainer = require('../../app/renderer/components/modals/container') // Constants const appConfig = require('../constants/appConfig') @@ -366,6 +367,8 @@ class Main extends ImmutableComponent { this.registerWindowLevelShortcuts() this.registerCustomTitlebarHandlers() + appActions.showModal('ledgerBackup') + ipc.on(messages.LEAVE_FULL_SCREEN, this.exitFullScreen.bind(this)) ipc.on(messages.DEBUG_REACT_PROFILE, (e, args) => { @@ -1250,6 +1253,11 @@ class Main extends ImmutableComponent { activeFrame={activeFrame} /> : null } + { + this.props.appState.get('modals') && this.props.appState.get('modals').size + ? + : null + } { showBookmarksToolbar ? { appState = appState.set('siteSettings', newSiteSettings) }) break + case appConstants.APP_SHOW_MODAL: + const foo = appState.get('modals') || Immutable.List() + appState = appState.set('modals', foo.push(Immutable.fromJS({ + id: action.id + }))) + break + case appConstants.APP_HIDE_MODAL: + appState = appState.set('modals', appState.get('modals').filterNot((modal) => { + return modal.get('id') === action.id + })) + break default: }