diff --git a/browser/brave_profile_prefs.cc b/browser/brave_profile_prefs.cc index 15427f975648..ed897959613f 100644 --- a/browser/brave_profile_prefs.cc +++ b/browser/brave_profile_prefs.cc @@ -305,6 +305,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { registry->RegisterBooleanPref(kNewTabPageShowBinance, true); registry->RegisterBooleanPref(kNewTabPageShowTogether, false); registry->RegisterBooleanPref(kNewTabPageShowGemini, true); + registry->RegisterBooleanPref(kNewTabPageHideAllWidgets, false); + registry->RegisterIntegerPref( kNewTabPageShowsOptions, static_cast(NewTabPageShowsOptions::kDashboard)); diff --git a/browser/search/BUILD.gn b/browser/search/BUILD.gn index 27a8517c9a4d..4abd3c022819 100644 --- a/browser/search/BUILD.gn +++ b/browser/search/BUILD.gn @@ -1,3 +1,5 @@ +import("//brave/components/crypto_dot_com/browser/buildflags/buildflags.gni") + source_set("search") { sources = [] @@ -10,11 +12,39 @@ source_set("search") { ] deps += [ + "//base", "//brave/browser/profiles:profiles", "//brave/common:pref_names", + "//brave/components/crypto_dot_com/browser/buildflags", + "//brave/components/crypto_dot_com/common", "//chrome/common", "//components/pref_registry", "//components/prefs", ] } } + +source_set("unit_tests") { + testonly = true + + if (!is_android) { + sources = [ + "ntp_utils_unittest.cc", + ] + deps = [ + "//brave/browser/search", + "//brave/common:pref_names", + "//brave/components/crypto_dot_com/browser/buildflags:buildflags", + "//chrome/test:test_support", + "//components/prefs", + "//components/sync_preferences", + "//content/test:test_support", + "//testing/gtest", + ] + if (crypto_dot_com_enabled) { + deps += [ + "//brave/components/crypto_dot_com/common", + ] + } + } +} diff --git a/browser/search/ntp_utils.cc b/browser/search/ntp_utils.cc index 5b946707d5c0..de4fcbbe6b80 100644 --- a/browser/search/ntp_utils.cc +++ b/browser/search/ntp_utils.cc @@ -5,13 +5,19 @@ #include "brave/browser/search/ntp_utils.h" +#include "base/logging.h" #include "brave/browser/profiles/profile_util.h" #include "brave/common/pref_names.h" +#include "brave/components/crypto_dot_com/browser/buildflags/buildflags.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" +#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) +#include "brave/components/crypto_dot_com/common/pref_names.h" +#endif + namespace { void ClearNewTabPageProfilePrefs(Profile* profile) { @@ -19,6 +25,16 @@ void ClearNewTabPageProfilePrefs(Profile* profile) { prefs->ClearPref(kNewTabPageShowTopSites); } +const char* const kWidgetPrefNames[] = { + kNewTabPageShowRewards, + kNewTabPageShowTogether, + kNewTabPageShowBinance, +#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) + kCryptoDotComNewTabPageShowCryptoDotCom, +#endif + kNewTabPageShowGemini +}; + } // namespace namespace new_tab_page { @@ -26,11 +42,57 @@ namespace new_tab_page { void MigrateNewTabPagePrefs(Profile* profile) { // Migrate over to the Chromium setting for shortcuts visible // Only sets the value if user has changed it - const PrefService::Preference* pref = - profile->GetPrefs()->FindPreference(kNewTabPageShowTopSites); - if (pref->HasUserSetting()) { - profile->GetPrefs()->SetBoolean(prefs::kNtpShortcutsVisible, - profile->GetPrefs()->GetBoolean(kNewTabPageShowTopSites)); + auto* prefs = profile->GetPrefs(); + const PrefService::Preference* top_sites_pref = + prefs->FindPreference(kNewTabPageShowTopSites); + if (top_sites_pref->HasUserSetting()) { + prefs->SetBoolean(prefs::kNtpShortcutsVisible, + prefs->GetBoolean(kNewTabPageShowTopSites)); + } + + // The toggle to turn off all widgets used to simply turn off + // all existing widgets. We later introduced a pref so that future + // new widgets do not show for that user. Perform a one-off migration + // for known widgets at the time to set this new pref. + const PrefService::Preference* hide_widgets_pref = + prefs->FindPreference(kNewTabPageHideAllWidgets); + if (!hide_widgets_pref->HasUserSetting()) { + VLOG(1) << "Migrating hide widget pref..."; + // If all the widgets are off, assume user wants no future widgets. + bool all_were_off = true; + for (auto* const pref_name : kWidgetPrefNames) { + auto* pref = prefs->FindPreference(pref_name); + // Do not assume default is for pref to be on, so make + // sure user has overriden pref value and it is false, + // since that's what the previous version of the + // "turn off all widgets" toggle did. + bool user_turned_off = pref->HasUserSetting() && + (pref->GetValue()->GetIfBool().value_or(true) == false); + VLOG(1) << "Setting: " << pref_name << + ", was off? " << user_turned_off; + if (user_turned_off == false) { + all_were_off = false; + break; + } + } + if (all_were_off) { + // Turn the widgets back on so that when user "un-hides all", they + // will show. This replicates the previous functionality, for the first + // time the user re-enables. After that, the new functionality will + // take effect, whereby each widget's show/hide setting is remembered + // individually. + prefs->SetBoolean(kNewTabPageShowRewards, true); + prefs->SetBoolean(kNewTabPageShowTogether, true); + prefs->SetBoolean(kNewTabPageShowBinance, true); + #if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) + prefs->SetBoolean(kCryptoDotComNewTabPageShowCryptoDotCom, true); + #endif + prefs->SetBoolean(kNewTabPageShowGemini, true); + } + // Record whether this has been migrated by setting an explicit + // value for the HideAllWidgets pref. + prefs->SetBoolean(kNewTabPageHideAllWidgets, all_were_off); + VLOG(1) << "Done migrating hide widget pref: " << all_were_off; } // Clear deprecated prefs. diff --git a/browser/search/ntp_utils_unittest.cc b/browser/search/ntp_utils_unittest.cc new file mode 100644 index 000000000000..a419c31a6760 --- /dev/null +++ b/browser/search/ntp_utils_unittest.cc @@ -0,0 +1,79 @@ +// Copyright (c) 2021 The Brave Authors. All rights reserved. +// 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/. + +#include "brave/browser/search/ntp_utils.h" + +#include + +#include "brave/common/pref_names.h" +#include "brave/components/crypto_dot_com/browser/buildflags/buildflags.h" +#include "chrome/test/base/testing_profile.h" +#include "components/prefs/pref_registry_simple.h" +#include "components/prefs/testing_pref_service.h" +#include "components/sync_preferences/testing_pref_service_syncable.h" +#include "content/public/test/browser_task_environment.h" +#include "testing/gtest/include/gtest/gtest.h" + +#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) +#include "brave/components/crypto_dot_com/common/pref_names.h" +#endif + +class NTPUtilsTest : public ::testing::Test { + public: + NTPUtilsTest() = default; + + void SetUp() override { + profile_ = std::make_unique(); + } + + Profile* profile() { return profile_.get(); } + + protected: + // BrowserTaskEnvironment is needed before TestingProfile + content::BrowserTaskEnvironment task_environment_; + + std::unique_ptr profile_; +}; + +TEST_F(NTPUtilsTest, MigratesHideWidgetTrue) { + // Manually turn all off + auto* prefs = profile()->GetPrefs(); + prefs->SetBoolean(kNewTabPageShowRewards, false); + prefs->SetBoolean(kNewTabPageShowTogether, false); + prefs->SetBoolean(kNewTabPageShowBinance, false); +#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) + prefs->SetBoolean(kCryptoDotComNewTabPageShowCryptoDotCom, false); +#endif + prefs->SetBoolean(kNewTabPageShowGemini, false); + // Migrate + new_tab_page::MigrateNewTabPagePrefs(profile()); + // Expect migrated to off + EXPECT_TRUE(prefs->GetBoolean(kNewTabPageHideAllWidgets)); +} + +TEST_F(NTPUtilsTest, MigratesHideWidgetFalse) { + // Manually turn some off + auto* prefs = profile()->GetPrefs(); + prefs->SetBoolean(kNewTabPageShowRewards, false); + prefs->SetBoolean(kNewTabPageShowTogether, true); + prefs->SetBoolean(kNewTabPageShowBinance, false); +#if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) + prefs->SetBoolean(kCryptoDotComNewTabPageShowCryptoDotCom, false); +#endif + prefs->SetBoolean(kNewTabPageShowGemini, false); + // Migrate + new_tab_page::MigrateNewTabPagePrefs(profile()); + // Expect not migrated + EXPECT_FALSE(prefs->GetBoolean(kNewTabPageHideAllWidgets)); +} + +TEST_F(NTPUtilsTest, MigratesHideWidgetFalseDefault) { + // Don't manually change any settings + // Migrate + new_tab_page::MigrateNewTabPagePrefs(profile()); + // Expect not migrated + auto* prefs = profile()->GetPrefs(); + EXPECT_FALSE(prefs->GetBoolean(kNewTabPageHideAllWidgets)); +} diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index f98b92fa89e9..c49170ef85e6 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -403,6 +403,7 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "ftxConversionAmountAvailable", IDS_FTX_CONVERSION_AMOUNT_AVAILABLE }, { "ftxSummaryBlurLabel", IDS_FTX_SUMMARY_BLUR_LABEL }, { "ftxSummaryRevealLabel", IDS_FTX_SUMMARY_REVEAL_LABEL }, + { "ftxSummaryNoBalance", IDS_FTX_SUMMARY_NO_BALANCE}, #endif } }, { diff --git a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc index 37f30003c634..23df49888e31 100644 --- a/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc +++ b/browser/ui/webui/new_tab_page/brave_new_tab_message_handler.cc @@ -111,6 +111,9 @@ base::DictionaryValue GetPreferencesDictionary(PrefService* prefs) { prefs->GetBoolean(kBrandedWallpaperNotificationDismissed)); pref_data.SetBoolean("isBraveTodayOptedIn", prefs->GetBoolean(kBraveTodayOptedIn)); + pref_data.SetBoolean( + "hideAllWidgets", + prefs->GetBoolean(kNewTabPageHideAllWidgets)); pref_data.SetBoolean( "showBinance", prefs->GetBoolean(kNewTabPageShowBinance)); @@ -381,6 +384,10 @@ void BraveNewTabMessageHandler::OnJavascriptAllowed() { kNewTabPageShowGemini, base::BindRepeating(&BraveNewTabMessageHandler::OnPreferencesChanged, base::Unretained(this))); + pref_change_registrar_.Add( + kNewTabPageHideAllWidgets, + base::BindRepeating(&BraveNewTabMessageHandler::OnPreferencesChanged, + base::Unretained(this))); #if BUILDFLAG(CRYPTO_DOT_COM_ENABLED) pref_change_registrar_.Add( kCryptoDotComNewTabPageShowCryptoDotCom, @@ -501,6 +508,8 @@ void BraveNewTabMessageHandler::HandleSaveNewTabPagePref( settingsKey = kNewTabPageShowRewards; } else if (settingsKeyInput == "isBrandedWallpaperNotificationDismissed") { settingsKey = kBrandedWallpaperNotificationDismissed; + } else if (settingsKeyInput == "hideAllWidgets") { + settingsKey = kNewTabPageHideAllWidgets; } else if (settingsKeyInput == "showBinance") { settingsKey = kNewTabPageShowBinance; } else if (settingsKeyInput == "showTogether") { diff --git a/common/pref_names.cc b/common/pref_names.cc index 60a7bc3b27cd..9a0fcf1d9fe2 100644 --- a/common/pref_names.cc +++ b/common/pref_names.cc @@ -59,6 +59,7 @@ const char kNewTabPageShowRewards[] = "brave.new_tab_page.show_rewards"; const char kNewTabPageShowBinance[] = "brave.new_tab_page.show_binance"; const char kNewTabPageShowGemini[] = "brave.new_tab_page.show_gemini"; const char kNewTabPageShowTogether[] = "brave.new_tab_page.show_together"; +const char kNewTabPageHideAllWidgets[] = "brave.new_tab_page.hide_all_widgets"; const char kNewTabPageShowsOptions[] = "brave.new_tab_page.shows_options"; const char kBraveTodaySources[] = "brave.today.sources"; const char kBraveTodayIntroDismissed[] = "brave.today.intro_dismissed"; diff --git a/common/pref_names.h b/common/pref_names.h index ac466ac2d601..bbb3236b88b1 100644 --- a/common/pref_names.h +++ b/common/pref_names.h @@ -52,6 +52,7 @@ extern const char kNewTabPageShowRewards[]; extern const char kNewTabPageShowBinance[]; extern const char kNewTabPageShowGemini[]; extern const char kNewTabPageShowTogether[]; +extern const char kNewTabPageHideAllWidgets[]; extern const char kNewTabPageShowsOptions[]; extern const char kBraveTodaySources[]; extern const char kBraveTodayIntroDismissed[]; diff --git a/components/brave_new_tab_ui/api/preferences.ts b/components/brave_new_tab_ui/api/preferences.ts index 8d463285f2f0..7f8799d0344c 100644 --- a/components/brave_new_tab_ui/api/preferences.ts +++ b/components/brave_new_tab_ui/api/preferences.ts @@ -76,12 +76,8 @@ export function saveIsBraveTodayOptedIn (value: boolean): void { sendSavePref('isBraveTodayOptedIn', value) } -export function saveSetAllStackWidgets (value: boolean): void { - sendSavePref('showRewards', value) - sendSavePref('showTogether', value) - sendSavePref('showBinance', value) - sendSavePref('showGemini', value) - sendSavePref('showCryptoDotCom', value) +export function saveSetAllStackWidgets (visible: boolean): void { + sendSavePref('hideAllWidgets', !visible) } export function addChangeListener (listener: PreferencesUpdatedHandler): void { diff --git a/components/brave_new_tab_ui/components/default/page/index.tsx b/components/brave_new_tab_ui/components/default/page/index.tsx index d93656b0af6e..2c5aaf0a075c 100644 --- a/components/brave_new_tab_ui/components/default/page/index.tsx +++ b/components/brave_new_tab_ui/components/default/page/index.tsx @@ -276,17 +276,6 @@ export const FooterContent = styled('div')` } ` -export const VisitableBackground = styled('a')` - z-index: -1; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - display: block; - cursor: pointer; -` - function getPageBackground (p: HasImageProps) { // Page background is duplicated since a backdrop-filter's // ancestor which has blur must also have background. diff --git a/components/brave_new_tab_ui/containers/newTab/index.tsx b/components/brave_new_tab_ui/containers/newTab/index.tsx index efe510dac6c1..4b6f8a080871 100644 --- a/components/brave_new_tab_ui/containers/newTab/index.tsx +++ b/components/brave_new_tab_ui/containers/newTab/index.tsx @@ -295,6 +295,7 @@ class NewTabPage extends React.Component { } toggleShowFTX = () => { + this.props.actions.ftx.disconnect() this.props.saveShowFTX(!this.props.newTabData.showFTX) } @@ -695,6 +696,9 @@ class NewTabPage extends React.Component { } getCryptoContent () { + if (this.props.newTabData.hideAllWidgets) { + return null + } const { widgetStackOrder, togetherSupported, @@ -770,9 +774,10 @@ class NewTabPage extends React.Component { cryptoDotComSupported, showFTX, ftxSupported, - binanceSupported + binanceSupported, + hideAllWidgets } = this.props.newTabData - return [ + return hideAllWidgets || [ showRewards, togetherSupported && showTogether, binanceSupported && showBinance, @@ -782,40 +787,6 @@ class NewTabPage extends React.Component { ].every((widget: boolean) => !widget) } - toggleAllCards = (show: boolean) => { - if (!show) { - this.props.actions.saveWidgetStackOrder() - this.props.saveSetAllStackWidgets(false) - return - } - - const saveShowProps = { - 'binance': this.props.saveShowBinance, - 'cryptoDotCom': this.props.saveShowCryptoDotCom, - 'gemini': this.props.saveShowGemini, - 'rewards': this.props.saveShowRewards, - 'together': this.props.saveShowTogether, - 'ftx': this.props.saveShowFTX - } - - const setAllTrue = (list: NewTab.StackWidget[]) => { - list.forEach((widget: NewTab.StackWidget) => { - if (widget in saveShowProps) { - saveShowProps[widget](true) - } - }) - } - - const { savedWidgetStackOrder, widgetStackOrder } = this.props.newTabData - // When turning back on, all widgets should be set to shown - // in the case that all widgets were hidden previously. - setAllTrue( - !savedWidgetStackOrder.length ? - widgetStackOrder : - savedWidgetStackOrder - ) - } - renderCryptoContent () { const { newTabData } = this.props const { widgetStackOrder } = newTabData @@ -1183,13 +1154,6 @@ class NewTabPage extends React.Component { } - {isShowingBrandedWallpaper && newTabData.brandedWallpaperData && - newTabData.brandedWallpaperData.logo && - - } { newTabData.showToday && { showFTX={newTabData.showFTX} todayPublishers={this.props.todayData.publishers} cardsHidden={this.allWidgetsHidden()} - toggleCards={this.toggleAllCards} + toggleCards={this.props.saveSetAllStackWidgets} /> { showEditTopSite ? diff --git a/components/brave_new_tab_ui/containers/newTab/settings/braveToday/index.tsx b/components/brave_new_tab_ui/containers/newTab/settings/braveToday/index.tsx index 01c3a58293c2..2966fb9f1585 100644 --- a/components/brave_new_tab_ui/containers/newTab/settings/braveToday/index.tsx +++ b/components/brave_new_tab_ui/containers/newTab/settings/braveToday/index.tsx @@ -41,6 +41,10 @@ export default function BraveTodayPrefs (props: Props) { } }, [props.onClearPrefs]) + const shouldShowSources = !!(props.showToday && + props.publishers && + Object.keys(props.publishers).length !== 0) + return ( {!category && ( @@ -53,7 +57,7 @@ export default function BraveTodayPrefs (props: Props) { /> )} - {props.showToday && props.publishers && Object.keys(props.publishers).length && + {shouldShowSources && } {!category && ( diff --git a/components/brave_new_tab_ui/reducers/stack_widget_reducer.ts b/components/brave_new_tab_ui/reducers/stack_widget_reducer.ts index af2dff17e734..d88649fd3ce3 100644 --- a/components/brave_new_tab_ui/reducers/stack_widget_reducer.ts +++ b/components/brave_new_tab_ui/reducers/stack_widget_reducer.ts @@ -74,15 +74,6 @@ const stackWidgetReducer: Reducer = (state: NewTab.Sta case types.SET_FOREGROUND_STACK_WIDGET: state = setForegroundStackWidget(payload.widget as NewTab.StackWidget, state) break - case types.SAVE_WIDGET_STACK_ORDER: - const savedWidgets = state.widgetStackOrder.filter((widget: NewTab.StackWidget) => { - return state[widgets[widget]] - }) - state = { - ...state, - savedWidgetStackOrder: savedWidgets - } - break default: break diff --git a/components/brave_new_tab_ui/storage/new_tab_storage.ts b/components/brave_new_tab_ui/storage/new_tab_storage.ts index 3b4c01c5b109..bc0bea9c9882 100644 --- a/components/brave_new_tab_ui/storage/new_tab_storage.ts +++ b/components/brave_new_tab_ui/storage/new_tab_storage.ts @@ -27,6 +27,7 @@ export const defaultState: NewTab.State = { showBitcoinDotCom: false, showCryptoDotCom: false, showFTX: false, + hideAllWidgets: false, brandedWallpaperOptIn: false, isBrandedWallpaperNotificationDismissed: true, isBraveTodayOptedIn: false, @@ -75,7 +76,6 @@ export const defaultState: NewTab.State = { currentStackWidget: '', removedStackWidgets: [], // Order is ascending, with last entry being in the foreground - savedWidgetStackOrder: [], widgetStackOrder: ['ftx', 'cryptoDotCom', 'binance', 'gemini', 'rewards'], binanceState: { userTLD: 'com', @@ -291,8 +291,7 @@ export const debouncedSave = debounce((data: NewTab.State) => { cryptoDotComState: data.cryptoDotComState, ftxState: data.ftxState, removedStackWidgets: data.removedStackWidgets, - widgetStackOrder: data.widgetStackOrder, - savedWidgetStackOrder: data.savedWidgetStackOrder + widgetStackOrder: data.widgetStackOrder } window.localStorage.setItem(keyName, JSON.stringify(dataToSave)) } diff --git a/components/brave_new_tab_ui/stories/default/data/storybookState.ts b/components/brave_new_tab_ui/stories/default/data/storybookState.ts index 52028081be4e..312cfd76a3e8 100644 --- a/components/brave_new_tab_ui/stories/default/data/storybookState.ts +++ b/components/brave_new_tab_ui/stories/default/data/storybookState.ts @@ -81,6 +81,7 @@ export const getNewTabData = (state: NewTab.State = defaultState): NewTab.State ftxSupported: boolean('FTX supported?', true), showFTX: boolean('Show FTX?', true), showBinance: boolean('Show Binance?', true), + hideAllWidgets: boolean('Hide all widgets?', false), isBraveTodayOptedIn: boolean('Brave Today opted-in?', false), textDirection: select('Text direction', { ltr: 'ltr', rtl: 'rtl' } , 'ltr'), stats: { diff --git a/components/brave_new_tab_ui/widgets/ftx/components/summary.tsx b/components/brave_new_tab_ui/widgets/ftx/components/summary.tsx index 5723bd18d767..447eafc9b40a 100644 --- a/components/brave_new_tab_ui/widgets/ftx/components/summary.tsx +++ b/components/brave_new_tab_ui/widgets/ftx/components/summary.tsx @@ -23,17 +23,16 @@ type Props = { } export default function Summary (props: Props) { - const total = props.ftx.balanceTotal + const total = props.ftx.balanceTotal || 0 + const balanceKeys = Object.keys(props.ftx.balances) return ( - {total !== null && {getFormattedPrice(total)} - } + {balanceKeys.length !== 0 + ? - {Object.keys(props.ftx.balances).map(currencyKey => { + {balanceKeys.map(currencyKey => { const balance = props.ftx.balances[currencyKey] return ( @@ -67,6 +68,10 @@ export default function Summary (props: Props) { ) })} + : + {getLocale('ftxSummaryNoBalance')} + + } ) } diff --git a/components/brave_new_tab_ui/widgets/stories/locale.ts b/components/brave_new_tab_ui/widgets/stories/locale.ts index 0c13ae3a6566..c53b38f45da2 100644 --- a/components/brave_new_tab_ui/widgets/stories/locale.ts +++ b/components/brave_new_tab_ui/widgets/stories/locale.ts @@ -25,5 +25,6 @@ provideStrings({ ftxConversionBalanceNeeded: 'You need a balance in at least one currency in order to perform a conversion.', ftxConversionAmountAvailable: 'Available $1 $2', ftxSummaryBlurLabel: 'Hide your balances from display', - ftxSummaryRevealLabel: 'Reveal your balances on screen' + ftxSummaryRevealLabel: 'Reveal your balances on screen', + ftxSummaryNoBalance: 'You do not have any balances in your account. Visit FTX to purchase some.' }) diff --git a/components/definitions/newTab.d.ts b/components/definitions/newTab.d.ts index f81454d98ba0..2d7c64315f3b 100644 --- a/components/definitions/newTab.d.ts +++ b/components/definitions/newTab.d.ts @@ -89,7 +89,6 @@ declare namespace NewTab { currentStackWidget: StackWidget removedStackWidgets: StackWidget[] widgetStackOrder: StackWidget[] - savedWidgetStackOrder: StackWidget[] binanceState: BinanceWidgetState geminiState: GeminiWidgetState cryptoDotComState: CryptoDotComWidgetState @@ -105,6 +104,11 @@ declare namespace NewTab { clockFormat: string showTopSites: boolean showRewards: boolean + showTogether: boolean + showBinance: boolean + showGemini: boolean + showCryptoDotCom: boolean + hideAllWidgets: boolean isBraveTodayOptedIn: boolean isBrandedWallpaperNotificationDismissed: boolean } @@ -125,11 +129,7 @@ declare namespace NewTab { showBackgroundImage: boolean customLinksEnabled: boolean customLinksNum: number - showTogether: boolean - showBinance: boolean - showGemini: boolean showBitcoinDotCom: boolean - showCryptoDotCom: boolean, showFTX: boolean, stats: Stats, brandedWallpaperData?: BrandedWallpaper diff --git a/components/resources/ftx_strings.grdp b/components/resources/ftx_strings.grdp index 4d562751830b..b75a121c01b6 100644 --- a/components/resources/ftx_strings.grdp +++ b/components/resources/ftx_strings.grdp @@ -72,4 +72,7 @@ Reveal your balances on screen + + You do not have any balances in your account. Visit FTX to purchase some. + diff --git a/components/test/brave_new_tab_ui/reducers/stack_widget_reducer_test.ts b/components/test/brave_new_tab_ui/reducers/stack_widget_reducer_test.ts index 2a8847833067..e8d4ebbf00ca 100644 --- a/components/test/brave_new_tab_ui/reducers/stack_widget_reducer_test.ts +++ b/components/test/brave_new_tab_ui/reducers/stack_widget_reducer_test.ts @@ -99,66 +99,4 @@ describe('stackWidgetReducer', () => { expect(assertion).toEqual(expectedState) }) }) - - describe('SAVE_WIDGET_STACK_ORDER', () => { - it('saves the current enabled widgets, in order, to state (1)', () => { - const initialState = { - ...storage.defaultState, - showBinance: true, - showGemini: true, - widgetStackOrder: ['binance', 'rewards', 'gemini'], - savedWidgetStackOrder: [] - } - const expectedState = { - ...initialState, - savedWidgetStackOrder: ['binance', 'gemini'] - } - const assertion = stackWidgetReducer({ - ...initialState - }, { - type: types.SAVE_WIDGET_STACK_ORDER, - payload: {} - }) - expect(assertion).toEqual(expectedState) - }) - it('saves the current enabled widgets, in order, to state (2)', () => { - const initialState = { - ...storage.defaultState, - showBinance: true, - showGemini: true, - showTogether: true, - widgetStackOrder: ['binance', 'together', 'rewards', 'gemini'], - savedWidgetStackOrder: [] - } - const expectedState = { - ...initialState, - savedWidgetStackOrder: ['binance', 'together', 'gemini'] - } - const assertion = stackWidgetReducer({ - ...initialState - }, { - type: types.SAVE_WIDGET_STACK_ORDER, - payload: {} - }) - expect(assertion).toEqual(expectedState) - }) - it('sets cache to an empty list when non are on', () => { - const initialState = { - ...storage.defaultState, - widgetStackOrder: ['binance', 'together', 'rewards', 'gemini'], - savedWidgetStackOrder: [] - } - const expectedState = { - ...initialState, - savedWidgetStackOrder: [] - } - const assertion = stackWidgetReducer({ - ...initialState - }, { - type: types.SAVE_WIDGET_STACK_ORDER, - payload: {} - }) - expect(assertion).toEqual(expectedState) - }) - }) }) diff --git a/test/BUILD.gn b/test/BUILD.gn index 7a547cd4bbbd..251a44cd3b62 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -152,6 +152,7 @@ test("brave_unit_tests") { "//brave/browser/permissions:unit_tests", "//brave/browser/profiles:profiles", "//brave/browser/safebrowsing", + "//brave/browser/search:unit_tests", "//brave/browser/themes", "//brave/browser/tor:unit_tests", "//brave/browser/translate/buildflags",