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

Replace hideLower with showLess #10164

Merged
merged 1 commit into from
Aug 6, 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
2 changes: 1 addition & 1 deletion app/common/lib/publisherUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const publisherState = {
// All publishers will be enabled by default if AUTO_SUGGEST is ON,
// excluding publishers defined on ledger's exclusion list
const excluded = locationInfo.getIn([locationId, 'exclude'])
const autoSuggestSites = getSetting(settings.AUTO_SUGGEST_SITES)
const autoSuggestSites = getSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST)

// If session is clear then siteSettings is undefined and icon
// will never be shown, but synopsis may not be empty.
Expand Down
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 @@ -371,8 +371,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
20 changes: 10 additions & 10 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,21 @@ const doAction = (state, action) => {
setPaymentInfo(action.value)
break

case settings.MINIMUM_VISIT_TIME:
case settings.PAYMENTS_MINIMUM_VISIT_TIME:
if (action.value <= 0) break

synopsis.options.minPublisherDuration = action.value
updatePublisherInfo()
break

case settings.MINIMUM_VISITS:
case settings.PAYMENTS_MINIMUM_VISITS:
if (action.value <= 0) break

synopsis.options.minPublisherVisits = action.value
updatePublisherInfo()
break

case settings.PAYMENTS_NON_VERIFIED:
case settings.PAYMENTS_ALLOW_NON_VERIFIED:
synopsis.options.showOnlyVerified = action.value
updatePublisherInfo()
break
Expand Down Expand Up @@ -666,7 +666,7 @@ eventStore.addChangeListener(() => {
synopsis.initPublisher(publisher)
if (initP) {
excludeP(publisher, (unused, exclude) => {
if (!getSetting(settings.AUTO_SUGGEST_SITES)) {
if (!getSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST)) {
exclude = false
} else {
exclude = !exclude
Expand Down Expand Up @@ -800,19 +800,19 @@ var enable = (paymentsEnabled) => {
var value

// cf., the `Synopsis` constructor, https://github.com/brave/ledger-publisher/blob/master/index.js#L167
value = getSetting(settings.MINIMUM_VISIT_TIME)
value = getSetting(settings.PAYMENTS_MINIMUM_VISIT_TIME)
if (!value) {
value = 8 * 1000
appActions.changeSetting(settings.MINIMUM_VISIT_TIME, value)
appActions.changeSetting(settings.PAYMENTS_MINIMUM_VISIT_TIME, value)
}

// for earlier versions of the code...
if ((value > 0) && (value < 1000)) synopsis.options.minPublisherDuration = value * 1000

value = getSetting(settings.MINIMUM_VISITS)
value = getSetting(settings.PAYMENTS_MINIMUM_VISITS)
if (!value) {
value = 1
appActions.changeSetting(settings.MINIMUM_VISITS, value)
appActions.changeSetting(settings.PAYMENTS_MINIMUM_VISITS, value)
}
if (value > 0) synopsis.options.minPublisherVisits = value

Expand Down Expand Up @@ -1054,7 +1054,7 @@ var stickyP = (publisher) => {

var eligibleP = (publisher) => {
if (!synopsis.options.minPublisherDuration && process.env.NODE_ENV !== 'test') {
synopsis.options.minPublisherDuration = getSetting(settings.MINIMUM_VISIT_TIME)
synopsis.options.minPublisherDuration = getSetting(settings.PAYMENTS_MINIMUM_VISIT_TIME)
}

return ((synopsis.publishers[publisher].scores[synopsis.options.scorekeeper] > 0) &&
Expand All @@ -1064,7 +1064,7 @@ var eligibleP = (publisher) => {

var visibleP = (publisher) => {
if (synopsis.options.showOnlyVerified === undefined) {
synopsis.options.showOnlyVerified = getSetting(settings.PAYMENTS_NON_VERIFIED)
synopsis.options.showOnlyVerified = getSetting(settings.PAYMENTS_ALLOW_NON_VERIFIED)
}

const publisherOptions = synopsis.publishers[publisher].options
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
20 changes: 10 additions & 10 deletions app/renderer/components/preferences/payment/ledgerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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 @@ -69,7 +69,7 @@ class LedgerTable extends ImmutableComponent {
return result
}
}
return getSetting(settings.AUTO_SUGGEST_SITES, this.props.settings)
return getSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST, this.props.settings)
}

shouldShow (synopsis) {
Expand Down Expand Up @@ -233,7 +233,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 @@ -244,9 +244,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 @@ -258,15 +258,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 @@ -306,9 +306,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
15 changes: 9 additions & 6 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,8 @@ 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
Expand All @@ -192,10 +187,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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed above 3 ones to group semantically

'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 Down
32 changes: 17 additions & 15 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,6 @@ module.exports = {
'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)
Expand Down Expand Up @@ -189,6 +179,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 @@ -197,11 +204,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 Down
18 changes: 9 additions & 9 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ const settings = {
// Autofill
AUTOFILL_ENABLED: 'privacy.autofill-enabled',
// Payments Tab
PAYMENTS_ALLOW_NON_VERIFIED: 'payments.allow-non-verified-publishers',
PAYMENTS_CONTRIBUTION_AMOUNT: 'payments.contribution-amount',
PAYMENTS_ENABLED: 'payments.enabled',
PAYMENTS_NOTIFICATIONS: 'payments.notifications',
PAYMENTS_MINIMUM_VISIT_TIME: 'payments.minimum-visit-time',
PAYMENTS_MINIMUM_VISITS: 'payments.minimum-visits',
PAYMENTS_NOTIFICATION_ADD_FUNDS_TIMESTAMP: 'notification-add-funds-timestamp',
PAYMENTS_NOTIFICATION_RECONCILE_SOON_TIMESTAMP: 'notification-reconcile-soon-timestamp',
PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED: 'payments.notificationTryPaymentsDismissed',
PAYMENTS_CONTRIBUTION_AMOUNT: 'payments.contribution-amount',
PAYMENTS_NON_VERIFIED: 'payments.allow-non-verified-publishers',
PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED: 'payments.notification-try-payments-dismissed',
PAYMENTS_NOTIFICATIONS: 'payments.notifications',
PAYMENTS_SITES_AUTO_SUGGEST: 'payments.sites-auto-suggest',
PAYMENTS_SITES_HIDE_EXCLUDED: 'payments.sites-hide-excluded',
PAYMENTS_SITES_SHOW_LESS: 'payments.sites-show-less',
// Shields Tab
BLOCKED_COUNT_BADGE: 'shields.blocked-count-badge',
COMPACT_BRAVERY_PANEL: 'shields.compact-bravery-panel',
Expand All @@ -72,11 +77,6 @@ const settings = {
SEND_USAGE_STATISTICS: 'advanced.send-usage-statistics',
UPDATE_TO_PREVIEW_RELEASES: 'advanced.update-to-preview-releases',
ADBLOCK_CUSTOM_RULES: 'adblock.customRules',
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',
TOOLBAR_UI_SCALE: 'advanced.toolbar-ui-scale',
SWIPE_NAV_DISTANCE: 'advanced.swipe-nav-distance',
// Sync settings
Expand Down
6 changes: 3 additions & 3 deletions test/about/ledgerPanelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('Regular payment panel tests', function () {
beforeEach(function * () {
yield setup(this.app.client)
yield this.app.client
.changeSetting(settings.AUTO_SUGGEST_SITES, true)
.changeSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST, true)
.tabByIndex(0)
.loadUrl(prefsUrl)
.waitForVisible(paymentsTab)
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('Regular payment panel tests', function () {
it('site is not added automatically', function * () {
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.changeSetting(settings.AUTO_SUGGEST_SITES, false)
.changeSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST, false)
.tabByIndex(0)
.loadUrl(site1)
.windowByUrl(Brave.browserWindowUrl)
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('Regular payment panel tests', function () {
.waitForSiteEntry(site1)
.tabByUrl(site1)
.windowByUrl(Brave.browserWindowUrl)
.changeSetting(settings.AUTO_SUGGEST_SITES, false)
.changeSetting(settings.PAYMENTS_SITES_AUTO_SUGGEST, false)
.tabByIndex(0)
.loadUrl(site2)
.windowByUrl(Brave.browserWindowUrl)
Expand Down