commit 90ce611386b0d35a769d6835957e1e0bdb42ed8c
parent aa06bff72582cb91abe7f308bef1a8e1cf94fbf7
Author: Reem H <42309026+reemhamz@users.noreply.github.com>
Date: Wed, 22 Oct 2025 02:37:12 +0000
Bug 1993138 - Add nimbus controls for weather opt-in feature. r=home-newtab-reviewers,thecount
Differential Revision: https://phabricator.services.mozilla.com/D267901
Diffstat:
4 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/browser/extensions/newtab/content-src/components/Weather/Weather.jsx b/browser/extensions/newtab/content-src/components/Weather/Weather.jsx
@@ -275,21 +275,16 @@ export class _Weather extends React.PureComponent {
const showDetailedView = Prefs.values["weather.display"] === "detailed";
- const isOptInEnabled = Prefs.values["system.showWeatherOptIn"];
+ const weatherOptIn = Prefs.values["system.showWeatherOptIn"];
+ const nimbusWeatherOptInEnabled =
+ Prefs.values.trainhopConfig?.weather?.weatherOptInEnabled;
+
const optInDisplayed = Prefs.values["weather.optInDisplayed"];
- const nimbusOptInDisplayed =
- Prefs.values.trainhopConfig?.weather?.optInDisplayed;
const optInUserChoice = Prefs.values["weather.optInAccepted"];
- const nimbusOptInUserChoice =
- Prefs.values.trainhopConfig?.weather?.optInAccepted;
const staticWeather = Prefs.values["weather.staticData.enabled"];
- const nimbusStaticWeather =
- Prefs.values.trainhopConfig?.weather?.staticDataEnabled;
- const optInPrompt = nimbusOptInDisplayed ?? optInDisplayed ?? false;
- const userChoice = nimbusOptInUserChoice ?? optInUserChoice ?? false;
- const isUserWeatherEnabled = Prefs.values.showWeather;
- const staticDataEnabled = nimbusStaticWeather ?? staticWeather ?? false;
+ // Conditionals for rendering feature based on prefs + nimbus experiment variables
+ const isOptInEnabled = weatherOptIn || nimbusWeatherOptInEnabled;
// Opt-in dialog should only show if:
// - weather enabled on customization menu
@@ -297,21 +292,20 @@ export class _Weather extends React.PureComponent {
// - opt-in prompt is enabled
// - user hasn't accepted the opt-in yet
const shouldShowOptInDialog =
- isUserWeatherEnabled && isOptInEnabled && optInPrompt && !userChoice;
+ isOptInEnabled && optInDisplayed && !optInUserChoice;
// Show static weather data only if:
// - weather is enabled on customization menu
// - weather opt-in pref is enabled
// - static weather data is enabled
- const showStaticData =
- isUserWeatherEnabled && isOptInEnabled && staticDataEnabled;
+ const showStaticData = isOptInEnabled && staticWeather;
// Note: The temperature units/display options will become secondary menu items
const WEATHER_SOURCE_CONTEXT_MENU_OPTIONS = [
...(Prefs.values["weather.locationSearchEnabled"]
? ["ChangeWeatherLocation"]
: []),
- ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []),
+ ...(isOptInEnabled ? ["DetectLocation"] : []),
...(Prefs.values["weather.temperatureUnits"] === "f"
? ["ChangeTempUnitCelsius"]
: ["ChangeTempUnitFahrenheit"]),
@@ -325,7 +319,7 @@ export class _Weather extends React.PureComponent {
...(Prefs.values["weather.locationSearchEnabled"]
? ["ChangeWeatherLocation"]
: []),
- ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []),
+ ...(isOptInEnabled ? ["DetectLocation"] : []),
"HideWeather",
"OpenLearnMoreURL",
];
diff --git a/browser/extensions/newtab/data/content/activity-stream.bundle.js b/browser/extensions/newtab/data/content/activity-stream.bundle.js
@@ -11729,34 +11729,31 @@ class _Weather extends (external_React_default()).PureComponent {
const WEATHER_SUGGESTION = Weather.suggestions?.[0];
const outerClassName = ["weather", Weather.searchActive && "search", props.isInSection && "section-weather"].filter(v => v).join(" ");
const showDetailedView = Prefs.values["weather.display"] === "detailed";
- const isOptInEnabled = Prefs.values["system.showWeatherOptIn"];
+ const weatherOptIn = Prefs.values["system.showWeatherOptIn"];
+ const nimbusWeatherOptInEnabled = Prefs.values.trainhopConfig?.weather?.weatherOptInEnabled;
const optInDisplayed = Prefs.values["weather.optInDisplayed"];
- const nimbusOptInDisplayed = Prefs.values.trainhopConfig?.weather?.optInDisplayed;
const optInUserChoice = Prefs.values["weather.optInAccepted"];
- const nimbusOptInUserChoice = Prefs.values.trainhopConfig?.weather?.optInAccepted;
const staticWeather = Prefs.values["weather.staticData.enabled"];
- const nimbusStaticWeather = Prefs.values.trainhopConfig?.weather?.staticDataEnabled;
- const optInPrompt = nimbusOptInDisplayed ?? optInDisplayed ?? false;
- const userChoice = nimbusOptInUserChoice ?? optInUserChoice ?? false;
- const isUserWeatherEnabled = Prefs.values.showWeather;
- const staticDataEnabled = nimbusStaticWeather ?? staticWeather ?? false;
+
+ // Conditionals for rendering feature based on prefs + nimbus experiment variables
+ const isOptInEnabled = weatherOptIn || nimbusWeatherOptInEnabled;
// Opt-in dialog should only show if:
// - weather enabled on customization menu
// - weather opt-in pref is enabled
// - opt-in prompt is enabled
// - user hasn't accepted the opt-in yet
- const shouldShowOptInDialog = isUserWeatherEnabled && isOptInEnabled && optInPrompt && !userChoice;
+ const shouldShowOptInDialog = isOptInEnabled && optInDisplayed && !optInUserChoice;
// Show static weather data only if:
// - weather is enabled on customization menu
// - weather opt-in pref is enabled
// - static weather data is enabled
- const showStaticData = isUserWeatherEnabled && isOptInEnabled && staticDataEnabled;
+ const showStaticData = isOptInEnabled && staticWeather;
// Note: The temperature units/display options will become secondary menu items
- const WEATHER_SOURCE_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), ...(Prefs.values["weather.temperatureUnits"] === "f" ? ["ChangeTempUnitCelsius"] : ["ChangeTempUnitFahrenheit"]), ...(Prefs.values["weather.display"] === "simple" ? ["ChangeWeatherDisplayDetailed"] : ["ChangeWeatherDisplaySimple"]), "HideWeather", "OpenLearnMoreURL"];
- const WEATHER_SOURCE_SHORTENED_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(Prefs.values["system.showWeatherOptIn"] ? ["DetectLocation"] : []), "HideWeather", "OpenLearnMoreURL"];
+ const WEATHER_SOURCE_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(isOptInEnabled ? ["DetectLocation"] : []), ...(Prefs.values["weather.temperatureUnits"] === "f" ? ["ChangeTempUnitCelsius"] : ["ChangeTempUnitFahrenheit"]), ...(Prefs.values["weather.display"] === "simple" ? ["ChangeWeatherDisplayDetailed"] : ["ChangeWeatherDisplaySimple"]), "HideWeather", "OpenLearnMoreURL"];
+ const WEATHER_SOURCE_SHORTENED_CONTEXT_MENU_OPTIONS = [...(Prefs.values["weather.locationSearchEnabled"] ? ["ChangeWeatherLocation"] : []), ...(isOptInEnabled ? ["DetectLocation"] : []), "HideWeather", "OpenLearnMoreURL"];
const contextMenu = contextOpts => /*#__PURE__*/external_React_default().createElement("div", {
className: "weatherButtonContextMenuWrapper"
}, /*#__PURE__*/external_React_default().createElement("button", {
diff --git a/browser/extensions/newtab/karma.mc.config.js b/browser/extensions/newtab/karma.mc.config.js
@@ -305,8 +305,8 @@ module.exports = function (config) {
branches: 0,
},
"content-src/components/Weather/Weather.jsx": {
- statements: 51.1,
- lines: 52.38,
+ statements: 50,
+ lines: 50.94,
functions: 31.2,
branches: 31.2,
},
diff --git a/browser/extensions/newtab/lib/ActivityStream.sys.mjs b/browser/extensions/newtab/lib/ActivityStream.sys.mjs
@@ -369,7 +369,7 @@ export const PREFS_CONFIG = new Map([
{
title:
"Enable opt-in dialog to display for weather widget in GDPR regions.",
- value: false,
+ value: true,
},
],
[
@@ -385,7 +385,7 @@ export const PREFS_CONFIG = new Map([
{
title:
"Static weather data shown when user has not set/enabled location from opt-in.",
- value: false,
+ value: true,
},
],
[