From 240fd64eb9de5c7679a8199e234569c7377306ce Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 31 Oct 2016 12:47:49 -0700 Subject: [PATCH] Finishing up settings for newtab: Fixes https://github.com/brave/browser-laptop/issues/2106 - pulled out setting values into an enum - position moved to below "Brave starts with" (in preferences.js) - resolved circular dependency issue in appUrlUtil which broke app - made a newtab option called BLANK and renamed value TEMP. We can change back when ready to go live - defaultUrl removed from main.js (since it gets defaulted in windowStore.js) - removed defaultUrl from window.js (since windowStore.js also handles this) - put about pages into config; updated contextMenus.js to use config constants - adding missing "base" element to searchProviders that had it missing (mdn, github, startpage, etc) - updated defaultUrl logic in appUrlUtil.js to default unknown values to about:blank - windowStore.js now uses new defaultUrl method (from appUrlUtil) instead of config.defaultUrl Auditors: @kingscott @cezaraugusto --- app/common/constants/bookmarksToolbarMode.js | 11 ---- app/common/constants/settingsEnums.js | 28 ++++++++++ .../locales/en-US/preferences.properties | 7 ++- docs/state.md | 2 +- js/about/preferences.js | 26 +++++----- js/components/frame.js | 8 +-- js/components/main.js | 6 +-- js/components/tabs.js | 22 +------- js/components/window.js | 5 +- js/constants/appConfig.js | 2 +- js/constants/settings.js | 2 +- js/contextMenus.js | 2 +- js/data/searchProviders.js | 4 ++ js/lib/appUrlUtil.js | 51 +++++++++---------- js/settings.js | 2 +- js/stores/windowStore.js | 11 ++-- test/unit/settingsTest.js | 2 +- 17 files changed, 96 insertions(+), 95 deletions(-) delete mode 100644 app/common/constants/bookmarksToolbarMode.js create mode 100644 app/common/constants/settingsEnums.js diff --git a/app/common/constants/bookmarksToolbarMode.js b/app/common/constants/bookmarksToolbarMode.js deleted file mode 100644 index 824cbfb7283..00000000000 --- a/app/common/constants/bookmarksToolbarMode.js +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const settings = { - TEXT_ONLY: 'textOnly', - TEXT_AND_FAVICONS: 'textAndFavicons', - FAVICONS_ONLY: 'faviconsOnly' -} - -module.exports = settings diff --git a/app/common/constants/settingsEnums.js b/app/common/constants/settingsEnums.js new file mode 100644 index 00000000000..976f0cbc440 --- /dev/null +++ b/app/common/constants/settingsEnums.js @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const startsWithOption = { + WINDOWS_TABS_FROM_LAST_TIME: 'lastTime', + HOMEPAGE: 'homePage', + NEW_TAB_PAGE: 'newTabPage' +} + +const newTabMode = { + BLANK: 'blank', + NEW_TAB_PAGE: 'newTabPage', + HOMEPAGE: 'homePage', + DEFAULT_SEARCH_ENGINE: 'defaultSearchEngine' +} + +const bookmarksToolbarMode = { + TEXT_ONLY: 'textOnly', + TEXT_AND_FAVICONS: 'textAndFavicons', + FAVICONS_ONLY: 'faviconsOnly' +} + +module.exports = { + startsWithOption, + newTabMode, + bookmarksToolbarMode +} diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 249e8160504..9cfa00f3f6f 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -103,9 +103,12 @@ startsWith=Brave starts with startsWithOptionLastTime=my windows / tabs from last time startsWithOptionHomePage=my home page startsWithOptionNewTabPage=the new tab page -startsWithOptionDefaultSearchEngine=default search engine +newTabMode=A new tab shows +newTabBlank=blank +newTabNewTabPage=the new tab page +newTabHomePage=my home page +newTabDefaultSearchEngine=default search engine myHomepage=My homepage is -newTabMode=A new tab is default=Default searchEngine=Search Engine engineGoKey=Engine Go Key (Type First) diff --git a/docs/state.md b/docs/state.md index 798b0791a5c..398760dc178 100644 --- a/docs/state.md +++ b/docs/state.md @@ -161,7 +161,7 @@ AppStore // See defaults in js/constants/appConfig.js 'general.startup-mode': string, // One of: lastTime, homePage, newTabPage 'general.homepage': string, // URL of the user's homepage - 'general.newtab-mode': string, // One of: newTabPage, homePage, defaultSearchEngine + 'general.newtab-mode-TEMP': string, // One of: blank, newTabPage, homePage, defaultSearchEngine 'general.show-home-button': boolean, // true if the home button should be shown 'general.useragent.value': (undefined|string), // custom user agent value 'general.downloads.default-save-path': string, // default path for saving files diff --git a/js/about/preferences.js b/js/about/preferences.js index 8029df8cbd6..d7ccd4610c9 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -20,7 +20,8 @@ const messages = require('../constants/messages') const settings = require('../constants/settings') const coinbaseCountries = require('../constants/coinbaseCountries') const {passwordManagers, extensionIds} = require('../constants/passwordManagers') -const bookmarksToolbarMode = require('../../app/common/constants/bookmarksToolbarMode') +const {startsWithOption, newTabMode, bookmarksToolbarMode} = require('../../app/common/constants/settingsEnums') + const WidevineInfo = require('../../app/renderer/components/widevineInfo') const aboutActions = require('./aboutActions') const getSetting = require('../settings').getSetting @@ -646,9 +647,18 @@ class GeneralTab extends ImmutableComponent { + + + @@ -675,14 +685,6 @@ class GeneralTab extends ImmutableComponent { prefKey={settings.SHOW_BOOKMARKS_TOOLBAR} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} /> - - -