Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

add support for legacy ledger settings #10441

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,37 @@ module.exports.runPreMigrations = (data) => {
data.autofill.creditCards.guid = guids
}
}
// xml migration
if (data.settings) {
// xml migration
if (data.settings[settings.DEFAULT_SEARCH_ENGINE] === 'content/search/google.xml') {
data.settings[settings.DEFAULT_SEARCH_ENGINE] = 'Google'
}
if (data.settings[settings.DEFAULT_SEARCH_ENGINE] === 'content/search/duckduckgo.xml') {
data.settings[settings.DEFAULT_SEARCH_ENGINE] = 'DuckDuckGo'
}
// ledger payments migration. see PR #10164
// changes was introduced in 0.21.x.
// if legacy setting exist, make sure the new setting inherits the legacy value
if (data.settings[settings.AUTO_SUGGEST_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_AUTO_SUGGEST] = data.settings[settings.AUTO_SUGGEST_SITES]
}
if (data.settings[settings.MINIMUM_VISIT_TIME] != null) {
data.settings[settings.PAYMENTS_MINIMUM_VISIT_TIME] = data.settings[settings.MINIMUM_VISIT_TIME]
}
if (data.settings[settings.MINIMUM_VISITS] != null) {
data.settings[settings.PAYMENTS_MINIMUM_VISITS] = data.settings[settings.MINIMUM_VISITS]
}
if (data.settings[settings.HIDE_LOWER_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_SHOW_LESS] = data.settings[settings.HIDE_LOWER_SITES]
}
if (data.settings[settings.HIDE_EXCLUDED_SITES] != null) {
data.settings[settings.PAYMENTS_SITES_HIDE_EXCLUDED] = data.settings[settings.HIDE_EXCLUDED_SITES]
}
// PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED kept the same
// constant but has its value changed.
if (data.settings['payments.notificationTryPaymentsDismissed'] != null) {
data.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED] = data.settings['payments.notificationTryPaymentsDismissed']
}
}

if (data.sites) {
Expand Down
27 changes: 18 additions & 9 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ AppStore
'advanced.smooth-scroll-enabled': boolean, // false if smooth scrolling should be explicitly disabled
'advanced.torrent-viewer-enabled': boolean, // whether to render magnet links in the browser
'bookmarks.toolbar.show': boolean, // true if the bookmakrs toolbar should be shown
'bookmarks.toolbar.showFavicon': boolean, // true if bookmark favicons should be shown on the bookmarks toolbar
'bookmarks.toolbar.showOnlyFavicon': boolean, // true if only favicons should be shown on the bookmarks toolbar
'extensions.pocket.enabled': boolean, // true if pocket is enabled
'extensions.vimium.enabled': boolean, // true if vimium is enabled
'extensions.honey.enabled': boolean, // true if Honey is enabled
Expand Down Expand Up @@ -268,12 +266,6 @@ AppStore
'shields.blocked-count-badge': boolean, // true if blocked counts on the shield button should be enabled
'shields.compact-bravery-panel': boolean, // true if the compact Bravery panel should be enabled
'security.passwords.active-password-manager': string, // name of active password manager
'security.passwords.bitwarden-enabled': boolean, // true if the bitwarden extension should be enabled
'security.passwords.dashlane-enabled': boolean, // true if the Dashlane extension should be enabled
'security.passwords.enpass-enabled': boolean, // true if the Enpass extension should be enabled
'security.passwords.last-pass-enabled': boolean, // true if the Last password extension should be enabled
'security.passwords.manager-enabled': boolean, // whether to use default password manager
'security.passwords.one-password-enabled': boolean, // true if the 1Password extension should be enabled
'security.fullscreen.content': string, // whether or not user choose to allow fullscreen content by default
'shutdown.clear-all-site-cookies': boolean, // true to clear all site cookies on shutdown
'shutdown.clear-autocomplete-data': boolean, // true to clear all autocomplete data on shutdown
Expand All @@ -286,7 +278,24 @@ AppStore
'tabs.paint-tabs': boolean, // true if the page theme color and favicon color should be used for tabs
'tabs.show-tab-previews': boolean, // true to show tab previews
'tabs.switch-to-new-tabs': boolean, // true if newly opened tabs should be focused immediately
'tabs.tabs-per-page': number // number of tabs per tab page
'tabs.tabs-per-page': number, // number of tabs per tab page

// DEPRECATED with 0.11.4
'security.passwords.dashlane-enabled': boolean, // true if the Dashlane extension should be enabled
'security.passwords.last-pass-enabled': boolean, // true if the Last password extension should be enabled
'security.passwords.manager-enabled': boolean, // whether to use default password manager
'security.passwords.one-password-enabled': boolean, // true if the 1Password extension should be enabled

// DEPRECATED with 0.12.6
'bookmarks.toolbar.showFavicon': boolean, // true if bookmark favicons should be shown on the bookmarks toolbar
'bookmarks.toolbar.showOnlyFavicon': boolean, // true if only favicons should be shown on the bookmarks toolbar

// DEPRECATED with 0.21.0
'advanced.hide-excluded-sites': boolean, // whether to hide excluded sites in the payments list
'advanced.hide-lower-sites': boolean,
'advanced.minimum-visit-time': number,
'advanced.minimum-visits': number,
'advanced.auto-suggest-sites': boolean // show auto suggestion
},
locationSiteKeyCache: {
[location]: Array.<string> // location -> site keys
Expand Down
35 changes: 28 additions & 7 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,9 @@ module.exports = {
'privacy.autocomplete.history-size': 500,
'privacy.block-canvas-fingerprinting': false,
'bookmarks.toolbar.show': false,
'bookmarks.toolbar.showFavicon': false,
'bookmarks.toolbar.showOnlyFavicon': false,
'privacy.autofill-enabled': true,
'privacy.do-not-track': false,
'security.passwords.active-password-manager': null, // Set in settings.js by passwordManagerDefault (defaults to built in)
'security.passwords.manager-enabled': true,
'security.passwords.one-password-enabled': false,
'security.passwords.dashlane-enabled': false,
'security.passwords.last-pass-enabled': false,
'security.passwords.enpass-enabled': false,
'security.passwords.bitwarden-enabled': false,
'security.fullscreen.content': fullscreenOption.ALWAYS_ASK,
Expand Down Expand Up @@ -221,7 +215,34 @@ module.exports = {
'general.bookmarks-toolbar-mode': null,
'general.is-default-browser': null,
'notification-add-funds-timestamp': null,
'notification-reconcile-soon-timestamp': null
'notification-reconcile-soon-timestamp': null,

// DEPRECATED settings
// DO NOT REMOVE OR CHANGE THESE VALUES
// ########################
// These values should only ever be references from ./settings.js
// Any place using those should have a migration to convert the value
// ########################

// START - DEPRECATED WITH 0.11.4
'security.passwords.manager-enabled': true,
'security.passwords.one-password-enabled': false,
'security.passwords.dashlane-enabled': false,
'security.passwords.last-pass-enabled': false,
// END - DEPRECATED WITH 0.11.4

// START - DEPRECATED WITH 0.12.6
'bookmarks.toolbar.showFavicon': false,
'bookmarks.toolbar.showOnlyFavicon': false,
// END - DEPRECATED WITH 0.12.6

// START - DEPRECATED WITH 0.21.0
'advanced.hide-excluded-sites': false,
'advanced.minimum-visit-time': 8000,
'advanced.minimum-visits': 1,
'advanced.auto-suggest-sites': true,
'advanced.hide-lower-sites': true
// END - DEPRECATED WITH 0.21.0
},
defaultFavicon: 'img/empty_favicon.png'
}
31 changes: 22 additions & 9 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,39 @@ const settings = {
SYNC_TYPE_HISTORY: 'sync.type.history',
SYNC_TYPE_SITE_SETTING: 'sync.type.siteSetting',
SYNC_NETWORK_DISABLED: 'sync.network.disabled', // disable network connection to sync server. only used in testing.
// Extension settings
POCKET_ENABLED: 'extensions.pocket.enabled',
VIMIUM_ENABLED: 'extensions.vimium.enabled',
HONEY_ENABLED: 'extensions.honey.enabled',
PINTEREST_ENABLED: 'extensions.pinterest.enabled',
METAMASK_ENABLED: 'extensions.metamask.enabled',

// DEPRECATED settings
// DO NOT REMOVE OR CHANGE THESE VALUES
// ########################
// these constants should not appear outside of this file, ../settings.js, and our tests
// NOTE: these settings rely on default values being set in ./appConfig.js
// ########################
// > phased out with 0.11.4

// START - DEPRECATED WITH 0.11.4
PASSWORD_MANAGER_ENABLED: 'security.passwords.manager-enabled',
ONE_PASSWORD_ENABLED: 'security.passwords.one-password-enabled',
DASHLANE_ENABLED: 'security.passwords.dashlane-enabled',
LAST_PASS_ENABLED: 'security.passwords.last-pass-enabled',
ENPASS_ENABLED: 'security.passwords.enpass-enabled',
BITWARDEN_ENABLED: 'security.passwords.bitwarden-enabled',
// > phased out with 0.12.6
// END - DEPRECATED WITH 0.11.4

// START - DEPRECATED WITH 0.12.6
SHOW_BOOKMARKS_TOOLBAR_FAVICON: 'bookmarks.toolbar.showFavicon',
SHOW_BOOKMARKS_TOOLBAR_ONLY_FAVICON: 'bookmarks.toolbar.showOnlyFavicon',
POCKET_ENABLED: 'extensions.pocket.enabled',
VIMIUM_ENABLED: 'extensions.vimium.enabled',
HONEY_ENABLED: 'extensions.honey.enabled',
PINTEREST_ENABLED: 'extensions.pinterest.enabled',
METAMASK_ENABLED: 'extensions.metamask.enabled'
// END - DEPRECATED WITH 0.12.6

// START - DEPRECATED WITH 0.21.0
HIDE_EXCLUDED_SITES: 'advanced.hide-excluded-sites',
HIDE_LOWER_SITES: 'advanced.hide-lower-sites',
MINIMUM_VISIT_TIME: 'advanced.minimum-visit-time',
MINIMUM_VISITS: 'advanced.minimum-visits',
AUTO_SUGGEST_SITES: 'advanced.auto-suggest-sites'
// END - DEPRECATED WITH 0.21.0
}

module.exports = settings
10 changes: 4 additions & 6 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const settings = require('./constants/settings')
const {passwordManagers, defaultPasswordManager, extensionIds, displayNames} = require('./constants/passwordManagers')
const {bookmarksToolbarMode} = require('../app/common/constants/settingsEnums')

// individual settings were deprecated with 0.11.4
// DO NOT ADD TO THIS LIST
const passwordManagerDefault = (settingKey, settingsCollection) => {
const onePasswordEnabled = resolveValue(settings.ONE_PASSWORD_ENABLED, settingsCollection) === true
if (onePasswordEnabled) return passwordManagers.ONE_PASSWORD
Expand All @@ -18,18 +20,14 @@ const passwordManagerDefault = (settingKey, settingsCollection) => {
const lastPassEnabled = resolveValue(settings.LAST_PASS_ENABLED, settingsCollection) === true
if (lastPassEnabled) return passwordManagers.LAST_PASS

const enpassEnabled = resolveValue(settings.ENPASS_ENABLED, settingsCollection) === true
if (enpassEnabled) return passwordManagers.ENPASS

const bitwardenEnabled = resolveValue(settings.BITWARDEN_ENABLED, settingsCollection) === true
if (bitwardenEnabled) return passwordManagers.BITWARDEN

const disabled = resolveValue(settings.PASSWORD_MANAGER_ENABLED, settingsCollection) === false
if (disabled) return passwordManagers.UNMANAGED

return defaultPasswordManager
}

// individual settings were deprecated with 0.12.6
// DO NOT ADD TO THIS LIST
const bookmarksBarDefault = (settingKey, settingsCollection) => {
const faviconsOnly = resolveValue(settings.SHOW_BOOKMARKS_TOOLBAR_ONLY_FAVICON, settingsCollection) === true
if (faviconsOnly) return bookmarksToolbarMode.FAVICONS_ONLY
Expand Down
52 changes: 52 additions & 0 deletions test/unit/app/sessionStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,56 @@ describe('sessionStore unit tests', function () {
}
})
})

describe('runPreMigrations', function () {
let data = {
settings: {
[settings.AUTO_SUGGEST_SITES]: 'sure thing',
[settings.MINIMUM_VISIT_TIME]: 'almost instantly',
[settings.MINIMUM_VISITS]: 'a million',
[settings.HIDE_LOWER_SITES]: 'pls do it',
[settings.HIDE_EXCLUDED_SITES]: 'no thanks',
'payments.notificationTryPaymentsDismissed': 'why would I?'
}
}

describe('if data.settings exist', function () {
it('PAYMENTS_SITES_AUTO_SUGGEST inherits data from AUTO_SUGGEST_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_AUTO_SUGGEST]
const oldValue = runPreMigrations.settings[settings.AUTO_SUGGEST_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_MINIMUM_VISIT_TIME inherits data from MINIMUM_VISIT_TIME', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_MINIMUM_VISIT_TIME]
const oldValue = runPreMigrations.settings[settings.MINIMUM_VISIT_TIME]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_MINIMUM_VISITS inherits data from MINIMUM_VISITS', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_MINIMUM_VISITS]
const oldValue = runPreMigrations.settings[settings.MINIMUM_VISITS]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_SITES_SHOW_LESS inherits data from HIDE_LOWER_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_SHOW_LESS]
const oldValue = runPreMigrations.settings[settings.HIDE_LOWER_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_SITES_HIDE_EXCLUDED inherits data from HIDE_EXCLUDED_SITES', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_SITES_HIDE_EXCLUDED]
const oldValue = runPreMigrations.settings[settings.HIDE_EXCLUDED_SITES]
assert.equal(newValue, oldValue)
})
it('PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED inherits data from payments.notificationTryPaymentsDismissed', function () {
const runPreMigrations = sessionStore.runPreMigrations(data)
const newValue = runPreMigrations.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED]
const oldValue = runPreMigrations.settings['payments.notificationTryPaymentsDismissed']
assert.equal(newValue, oldValue)
})
})
})
})
26 changes: 1 addition & 25 deletions test/unit/settingsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,13 @@ describe('settings unit test', function () {
assert.equal(response, passwordManagers.LAST_PASS)
})

it('returns `Enpass` if ENPASS_ENABLED was true', function () {
settingsCollection[settingsConst.ENPASS_ENABLED] = true
const response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.ENPASS)
})

it('returns `bitwarden` if BITWARDEN_ENABLED was true', function () {
settingsCollection[settingsConst.BITWARDEN_ENABLED] = true
const response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.BITWARDEN)
})

it('returns `BuiltIn` if PASSWORD_MANAGER_ENABLED was true', function () {
settingsCollection[settingsConst.PASSWORD_MANAGER_ENABLED] = true
const response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.BUILT_IN)
})

it('returns `1Password`/`Dashlane`/`LastPass`/`Enpass`/`bitwarden`, even if PASSWORD_MANAGER_ENABLED was true', function () {
it('returns `1Password`/`Dashlane`/`LastPass`, even if PASSWORD_MANAGER_ENABLED was true', function () {
// 1Password
settingsCollection[settingsConst.ONE_PASSWORD_ENABLED] = true
settingsCollection[settingsConst.PASSWORD_MANAGER_ENABLED] = true
Expand All @@ -112,18 +100,6 @@ describe('settings unit test', function () {
settingsCollection[settingsConst.PASSWORD_MANAGER_ENABLED] = true
response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.LAST_PASS)
// Enpass
settingsCollection = {}
settingsCollection[settingsConst.ENPASS_ENABLED] = true
settingsCollection[settingsConst.PASSWORD_MANAGER_ENABLED] = true
response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.ENPASS)
// bitwarden
settingsCollection = {}
settingsCollection[settingsConst.BITWARDEN_ENABLED] = true
settingsCollection[settingsConst.PASSWORD_MANAGER_ENABLED] = true
response = settings.getSetting(settingsConst.ACTIVE_PASSWORD_MANAGER, settingsCollection)
assert.equal(response, passwordManagers.BITWARDEN)
})

it('returns `Unmanaged` if PASSWORD_MANAGER_ENABLED was false', function () {
Expand Down