diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4f9dff0c8..430d1b50c 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -208,6 +208,12 @@ "backToAll": { "message": "Back to All" }, + "backupApprovalNotice": { + "message": "Backup your Secret Recovery code to keep your wallet and funds secure." + }, + "backupApprovalInfo": { + "message": "This secret code is required to recover your wallet in case you lose your device, forget your password, have to re-install MetaMask, or want to access your wallet on another device." + }, "backupNow": { "message": "Backup now" }, @@ -550,6 +556,9 @@ "directDepositEtherExplainer": { "message": "If you already have some Ether, the quickest way to get Ether in your new wallet by direct deposit." }, + "dismiss": { + "message": "Dismiss" + }, "done": { "message": "Done" }, diff --git a/app/scripts/controllers/provider-approval.js b/app/scripts/controllers/provider-approval.js index 00ec0aea1..5d565c385 100644 --- a/app/scripts/controllers/provider-approval.js +++ b/app/scripts/controllers/provider-approval.js @@ -24,6 +24,7 @@ class ProviderApprovalController extends SafeEventEmitter { this.preferencesController = preferencesController this.store = new ObservableStore({ approvedOrigins: {}, + dismissedOrigins: {}, providerRequests: [], }) } @@ -66,7 +67,9 @@ class ProviderApprovalController extends SafeEventEmitter { _handleProviderRequest (origin, siteTitle, siteImage) { this.store.updateState({ providerRequests: [{ origin, siteTitle, siteImage }] }) const isUnlocked = this.keyringController.memStore.getState().isUnlocked - if (this.store.getState().approvedOrigins[origin] && this.caching && isUnlocked) { + const { approvedOrigins, dismissedOrigins } = this.store.getState() + const originAlreadyHandled = approvedOrigins[origin] || dismissedOrigins[origin] + if (originAlreadyHandled && this.caching && isUnlocked) { return } this.openPopup && this.openPopup() @@ -82,13 +85,21 @@ class ProviderApprovalController extends SafeEventEmitter { this.closePopup() } - const { approvedOrigins, providerRequests } = this.store.getState() + const { approvedOrigins, dismissedOrigins, providerRequests } = this.store.getState() + + let _dismissedOrigins = dismissedOrigins + if (dismissedOrigins[origin]) { + _dismissedOrigins = Object.assign({}, dismissedOrigins) + delete _dismissedOrigins[origin] + } + const remainingProviderRequests = providerRequests.filter(request => request.origin !== origin) this.store.updateState({ approvedOrigins: { ...approvedOrigins, [origin]: true, }, + dismissedOrigins: _dismissedOrigins, providerRequests: remainingProviderRequests, }) this.emit(`resolvedRequest:${origin}`, { approved: true }) @@ -104,7 +115,7 @@ class ProviderApprovalController extends SafeEventEmitter { this.closePopup() } - const { approvedOrigins, providerRequests } = this.store.getState() + const { approvedOrigins, providerRequests, dismissedOrigins } = this.store.getState() const remainingProviderRequests = providerRequests.filter(request => request.origin !== origin) // We're cloning and deleting keys here because we don't want to keep unneeded keys @@ -114,6 +125,10 @@ class ProviderApprovalController extends SafeEventEmitter { this.store.putState({ approvedOrigins: _approvedOrigins, providerRequests: remainingProviderRequests, + dismissedOrigins: { + ...dismissedOrigins, + [origin]: true, + }, }) this.emit(`resolvedRequest:${origin}`, { approved: false }) } @@ -124,13 +139,21 @@ class ProviderApprovalController extends SafeEventEmitter { * @param {string} origin - origin of the domain that had provider access approved */ forceApproveProviderRequestByOrigin (origin) { - const { approvedOrigins, providerRequests } = this.store.getState() + const { approvedOrigins, dismissedOrigins, providerRequests } = this.store.getState() const remainingProviderRequests = providerRequests.filter(request => request.origin !== origin) + + let _dismissedOrigins = dismissedOrigins + if (dismissedOrigins[origin]) { + _dismissedOrigins = Object.assign({}, dismissedOrigins) + delete _dismissedOrigins[origin] + } + this.store.updateState({ approvedOrigins: { ...approvedOrigins, [origin]: true, }, + dismissedOrigins: _dismissedOrigins, providerRequests: remainingProviderRequests, }) diff --git a/test/e2e/incremental-security.spec.js b/test/e2e/incremental-security.spec.js index c2b231c86..5b0990581 100644 --- a/test/e2e/incremental-security.spec.js +++ b/test/e2e/incremental-security.spec.js @@ -207,12 +207,12 @@ describe('MetaMask', function () { describe('backs up the seed phrase', () => { it('should show a backup reminder', async () => { - const backupReminder = await findElements(driver, By.css('.backup-notification')) + const backupReminder = await findElements(driver, By.xpath("//div[contains(@class, 'home-notification__text') and contains(text(), 'Backup your Secret Recovery code to keep your wallet and funds secure')]")) assert.equal(backupReminder.length, 1) }) it('should take the user to the seedphrase backup screen', async () => { - const backupButton = await findElement(driver, By.css('.backup-notification__submit-button')) + const backupButton = await findElement(driver, By.css('.home-notification__accept-button')) await backupButton.click() await delay(regularDelayMs) }) diff --git a/ui/app/components/app/backup-notification/backup-notification.component.js b/ui/app/components/app/backup-notification/backup-notification.component.js deleted file mode 100644 index dba79186c..000000000 --- a/ui/app/components/app/backup-notification/backup-notification.component.js +++ /dev/null @@ -1,50 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import Button from '../../ui/button' -import { - INITIALIZE_SEED_PHRASE_ROUTE, -} from '../../../helpers/constants/routes' - -export default class BackupNotification extends PureComponent { - static propTypes = { - history: PropTypes.object, - showSeedPhraseBackupAfterOnboarding: PropTypes.func, - } - - static contextTypes = { - t: PropTypes.func, - metricsEvent: PropTypes.func, - } - - handleSubmit = () => { - const { history, showSeedPhraseBackupAfterOnboarding } = this.props - showSeedPhraseBackupAfterOnboarding() - history.push(INITIALIZE_SEED_PHRASE_ROUTE) - } - - render () { - const { t } = this.context - - return ( -