From 259e3b3c000db007cacd669d814b1d9390e94c7b Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Sun, 30 Jul 2017 15:12:10 +0900 Subject: [PATCH] Replace hideLower with showLess Also: - Rename constants to sort them not only alphabetically but semantically - Add lacking states to docs/state.md Closes #10158 Auditors: Test Plan: 1. Run `npm run add-simulated-synopsis-visits 100` 2. Open about:preferences#payments 3. Click `Show All` button 4. Click `Show Less` button 5. Make sure the buttons work --- app/common/lib/publisherUtil.js | 2 +- .../locales/en-US/preferences.properties | 4 +-- app/ledger.js | 20 ++++++------ .../preferences/payment/advancedSettings.js | 6 ++-- .../preferences/payment/ledgerTable.js | 20 ++++++------ .../components/preferences/paymentsTab.js | 2 +- docs/state.md | 15 +++++---- js/constants/appConfig.js | 32 ++++++++++--------- js/constants/settings.js | 18 +++++------ test/about/ledgerPanelTest.js | 6 ++-- 10 files changed, 65 insertions(+), 60 deletions(-) diff --git a/app/common/lib/publisherUtil.js b/app/common/lib/publisherUtil.js index 76c17775d41..0988cdd922f 100644 --- a/app/common/lib/publisherUtil.js +++ b/app/common/lib/publisherUtil.js @@ -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. diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 71cc0dc3ca7..fb82d21d4ff 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -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 diff --git a/app/ledger.js b/app/ledger.js index 4d2c792fa8d..7abd30e03cb 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -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 @@ -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 @@ -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 @@ -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) && @@ -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 diff --git a/app/renderer/components/preferences/payment/advancedSettings.js b/app/renderer/components/preferences/payment/advancedSettings.js index d5236dd6ba6..ba7bbc02e96 100644 --- a/app/renderer/components/preferences/payment/advancedSettings.js +++ b/app/renderer/components/preferences/payment/advancedSettings.js @@ -34,8 +34,8 @@ class AdvancedSettingsContent extends ImmutableComponent { + defaultValue={minPublisherDuration || appConfig.defaultSettings[settings.PAYMENTS_MINIMUM_VISIT_TIME]} + onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.PAYMENTS_MINIMUM_VISIT_TIME)}>