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

Commit

Permalink
Manual backport of code changed in 0.21.x which caused conflict with …
Browse files Browse the repository at this point in the history
…BAT Mercury.

Details:
Because the settings were renamed, git didn't properly handle changes when cherry-picking backwards.
This caused the code in 0.19.x and 0.20.x to use the naming from 0.21.x

Merge pull request #10164 from luixxiul/polish-hideLower
Replace hideLower with showLess
f0d9c3d

Merge pull request #10441 from brave/10322
add support for legacy ledger settings
052277d

Also includes fixes from 9ad7b4f (most of this commit was already backported, just grabbed the settings migration fixes)

Auditors: @NejcZdovc, @luixxiul, @cezaraugusto

Fixes #11261
Fixes #11260
Fixes #11250
Fixes #11246
Fixes #11263
  • Loading branch information
cezaraugusto authored and bsclifton committed Oct 4, 2017
1 parent 9989178 commit 3bc7c1f
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 106 deletions.
4 changes: 2 additions & 2 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ checkDefaultOnStartup=Always check on startup
dashboardSettingsTitle=Dashboard
dashboardShowImages=Show images
requiresRestart=* Requires browser restart
showAll=Show all
hideLower=Hide lower
showAll=Show All
showLess=Show Less
scaleSizeSmaller=Smaller
scaleSizeNormal=Normal
scaleSizeLarger=Larger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class AdvancedSettingsContent extends ImmutableComponent {
<SettingItem>
<SettingDropdown
data-test-id='durationSelector'
defaultValue={minPublisherDuration || appConfig.defaultSettings[settings.MINIMUM_VISIT_TIME]}
onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.MINIMUM_VISIT_TIME)}>
defaultValue={minPublisherDuration || appConfig.defaultSettings[settings.PAYMENTS_MINIMUM_VISIT_TIME]}
onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.PAYMENTS_MINIMUM_VISIT_TIME)}>
<option data-l10n-id='minimumPageTimeLow' value='5000' />
<option data-l10n-id='minimumPageTimeMedium' value='8000' />
<option data-l10n-id='minimumPageTimeHigh' value='60000' />
Expand Down Expand Up @@ -73,7 +73,7 @@ class AdvancedSettingsContent extends ImmutableComponent {
<SettingCheckbox
dataTestId='payment-advance-nonverified'
dataL10nId='nonVerifiedPublishers'
prefKey={settings.PAYMENTS_NON_VERIFIED}
prefKey={settings.PAYMENTS_ALLOW_NON_VERIFIED}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting}
className={css(styles.listItem, commonStyles.noMarginBottom)}
Expand Down
18 changes: 9 additions & 9 deletions app/renderer/components/preferences/payment/ledgerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LedgerTable extends ImmutableComponent {
}

showAll (value) {
this.props.onChangeSetting(settings.HIDE_LOWER_SITES, value)
this.props.onChangeSetting(settings.PAYMENTS_SITES_SHOW_LESS, value)
}

getFormattedTime (synopsis) {
Expand Down Expand Up @@ -235,7 +235,7 @@ class LedgerTable extends ImmutableComponent {
}

const allRows = this.synopsis.filter(synopsis => {
return (!getSetting(settings.HIDE_EXCLUDED_SITES, this.props.settings) || this.enabledForSite(synopsis)) &&
return (!getSetting(settings.PAYMENTS_SITES_HIDE_EXCLUDED, this.props.settings) || this.enabledForSite(synopsis)) &&
this.shouldShow(synopsis)
})
const pinnedRows = allRows.filter(synopsis => {
Expand All @@ -246,9 +246,9 @@ class LedgerTable extends ImmutableComponent {
})

const totalUnPinnedRows = unPinnedRows.size
const hideLower = getSetting(settings.HIDE_LOWER_SITES, this.props.settings)
const showLess = getSetting(settings.PAYMENTS_SITES_SHOW_LESS, this.props.settings)

if (hideLower && totalUnPinnedRows > 10) {
if (showLess && totalUnPinnedRows > 10) {
let sumUnPinned = 0
let threshold = 90
const limit = 0.9 // show only 90th of publishers
Expand All @@ -260,15 +260,15 @@ class LedgerTable extends ImmutableComponent {
})
}

const showButton = (hideLower && totalUnPinnedRows !== unPinnedRows.size) || (!hideLower && totalUnPinnedRows > 10)
const showButton = (showLess && totalUnPinnedRows !== unPinnedRows.size) || (!showLess && totalUnPinnedRows > 10)

return <section data-test-id='ledgerTable'>
<div className={css(styles.hideExcludedSites)}>
<div className={css(styles.columnOffset)} />
<div className={css(styles.rightColumn)}>
<SettingCheckbox small
dataL10nId='hideExcluded'
prefKey={settings.HIDE_EXCLUDED_SITES}
prefKey={settings.PAYMENTS_SITES_HIDE_EXCLUDED}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting}
/>
Expand Down Expand Up @@ -308,9 +308,9 @@ class LedgerTable extends ImmutableComponent {
showButton
? <div className={css(styles.ledgerTable__showAllWrap)}>
<BrowserButton secondaryColor
testId={hideLower ? 'showAll' : 'hideLower'}
l10nId={hideLower ? 'showAll' : 'hideLower'}
onClick={this.showAll.bind(this, !hideLower)}
testId={showLess ? 'showAll' : 'showLess'}
l10nId={showLess ? 'showAll' : 'showLess'}
onClick={this.showAll.bind(this, !showLess)}
/>
</div>
: null
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/preferences/paymentsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class PaymentsTab extends ImmutableComponent {
<div className={css(styles.switchWrap__autoSuggestSwitch)}>
<div className={css(styles.flexAlignCenter, styles.autoSuggestSwitch__subtext)}>
<SettingCheckbox dataL10nId='autoSuggestSites'
prefKey={settings.AUTO_SUGGEST_SITES}
prefKey={settings.PAYMENTS_SITES_AUTO_SUGGEST}
settings={this.props.settings}
disabled={!enabled}
onChangeSetting={this.props.onChangeSetting}
Expand Down
31 changes: 30 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,43 @@ 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]
delete 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]
delete data.settings[settings.MINIMUM_VISIT_TIME]
}
if (data.settings[settings.MINIMUM_VISITS] != null) {
data.settings[settings.PAYMENTS_MINIMUM_VISITS] = data.settings[settings.MINIMUM_VISITS]
delete 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]
delete 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]
delete 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']
delete data.settings['payments.notificationTryPaymentsDismissed']
}
}

return data
Expand Down
42 changes: 27 additions & 15 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,14 @@ AppStore
settings: {
// See defaults in js/constants/appConfig.js
'adblock.customRules': string, // custom rules in ABP filter syntax
'advanced.auto-suggest-sites': boolean, // show auto suggestion
'advanced.default-zoom-level': number, // the default zoom level for sites that have no specific setting
'advanced.hardware-acceleration-enabled': boolean, // false if hardware acceleration should be explicitly disabled
'advanced.hide-excluded-sites': boolean, // whether to hide excluded sites in the payments list
'advanced.minimum-visit-time': number,
'advanced.minimum-visits': number,
'advanced.minimum-percentage': boolean,
'advanced.pdfjs-enabled': boolean, // whether or not to render PDF documents in the browser
'advanced.send-crash-reports': boolean, // true or undefined if crash reports should be sent
'advanced.send-usage-statistics': boolean, // true or undefined if usage reports should be sent
'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 All @@ -332,10 +325,18 @@ AppStore
'general.useragent.value': (undefined|string), // custom user agent value
'notification-add-funds-timestamp': number, // timestamp on which we decide if we will show notification Add founds
'notification-reconcile-soon-timestamp': number, // timestamp
'payments.allow-non-verified-publishers': boolean,
'payments.contribution-amount': number, // in USD
'payments.enabled': boolean, // true if the Payments pane is active
'payments.minimum-visit-time': number,
'payments.minimum-visits': number,
'payments.notification-add-funds-timestamp': number,
'payments.notification-reconcile-soon-timestamp': number,
'payments.notification-try-payments-dismissed': boolean, // true if you dismiss the message or enable Payments
'payments.notifications': boolean, // true to show payment notifications
'payments.notificationTryPaymentsDismissed': boolean, // true if you dismiss the message or enable Payments
'payments.sites-auto-suggest': boolean, // show auto suggestion
'payments.sites-hide-excluded': boolean, // whether to hide excluded sites in the payments list
'payments.sites-show-less': boolean, // whether to show less sites in the payments list
'privacy.autocomplete.history-size': number, // number of autocomplete entries to keep
'privacy.autofill-enabled': boolean, // true to enable autofill
'privacy.block-canvas-fingerprinting': boolean, // canvas fingerprinting defense
Expand All @@ -350,12 +351,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 @@ -368,7 +363,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
},
sites: {
[siteKey]: {
Expand Down
67 changes: 45 additions & 22 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,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,
'payments.enabled': false,
'payments.notifications': false,
'payments.allow-non-verified-publishers': true,
// "Add funds to your wallet" -- Limit to once every n days to reduce nagging.
'payments.notification-add-funds-timestamp': null,
// "Out of money, pls add" / "In 24h we'll pay publishers [Review]"
// After shown, set timestamp to next reconcile time - 1 day.
'payments.notification-reconcile-soon-timestamp': null,
'payments.notificationTryPaymentsDismissed': false, // True if you dismiss the message or enable Payments
'payments.contribution-amount': 5, // USD
'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 All @@ -190,6 +174,23 @@ module.exports = {
// have immersive mode w/ touch makes it too hard to enter a URL.
// Tracking issue for that and to re-enable title mode on Windows is at #9900.
'general.disable-title-mode': process.platform === 'linux' || process.platform === 'win32',
// payments
'payments.allow-non-verified-publishers': true,
'payments.contribution-amount': 5, // USD
'payments.enabled': false,
'payments.minimum-visit-time': 8000,
'payments.minimum-visits': 1,
// "Add funds to your wallet" -- Limit to once every n days to reduce nagging.
'payments.notification-add-funds-timestamp': null,
// "Out of money, pls add" / "In 24h we'll pay publishers [Review]"
// After shown, set timestamp to next reconcile time - 1 day.
'payments.notification-reconcile-soon-timestamp': null,
'payments.notification-try-payments-dismissed': false, // True if you dismiss the message or enable Payments
'payments.notifications': false,
'payments.sites-auto-suggest': true,
'payments.sites-hide-excluded': false,
'payments.sites-show-less': true,
// advanced
'advanced.hardware-acceleration-enabled': true,
'advanced.default-zoom-level': null,
'advanced.pdfjs-enabled': true,
Expand All @@ -198,11 +199,6 @@ module.exports = {
'advanced.send-crash-reports': true,
'advanced.send-usage-statistics': false,
'advanced.update-to-preview-releases': false,
'advanced.hide-excluded-sites': false,
'advanced.minimum-visit-time': 8000,
'advanced.minimum-visits': 1,
'advanced.auto-suggest-sites': true,
'advanced.hide-lower-sites': true,
'advanced.toolbar-ui-scale': 'normal',
'advanced.swipe-nav-distance': 101,
'shutdown.clear-history': false,
Expand All @@ -220,7 +216,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'
}
Loading

0 comments on commit 3bc7c1f

Please sign in to comment.