RCFilters: Add an opt-out preference for filters on watchlist
authorRoan Kattouw <roan.kattouw@gmail.com>
Thu, 31 May 2018 02:25:17 +0000 (19:25 -0700)
committerCatrope <roan@wikimedia.org>
Thu, 31 May 2018 17:24:28 +0000 (17:24 +0000)
And a temporary feature flag so we can roll it out in stages.

Bug: T195431
Change-Id: I170840146a197ac381df94434350ae2f0561d147

includes/DefaultSettings.php
includes/preferences/DefaultPreferencesFactory.php
includes/specials/SpecialWatchlist.php
languages/i18n/en.json
languages/i18n/qqq.json

index 87ca016..3362502 100644 (file)
@@ -4905,6 +4905,7 @@ $wgDefaultUserOptions = [
        'watchlistunwatchlinks' => 0,
        'watchmoves' => 0,
        'watchrollback' => 0,
+       'wlenhancedfilters-disable' => 0,
        'wllimit' => 250,
        'useeditwarning' => 1,
        'prefershttps' => 1,
@@ -6890,6 +6891,15 @@ $wgUseRCPatrol = true;
  */
 $wgStructuredChangeFiltersShowPreference = false;
 
+/**
+ * Whether a preference is displayed for structured change filters on watchlist.
+ * Works just like $wgStructuredChangeFiltersShowPreference.
+ *
+ * Temporary variable during development and will be removed
+ * @since 1.32
+ */
+$wgStructuredChangeFiltersShowWatchlistPreference = false;
+
 /**
  * Whether to enable RCFilters app on Special:Watchlist
  *
index 2d7d73f..87e2693 100644 (file)
@@ -1275,6 +1275,15 @@ class DefaultPreferencesFactory implements PreferencesFactory {
                                'help-message' => 'prefs-help-watchlist-token2',
                        ];
                }
+
+               if ( $this->config->get( 'StructuredChangeFiltersShowWatchlistPreference' ) ) {
+                       $defaultPreferences['wlenhancedfilters-disable'] = [
+                               'type' => 'toggle',
+                               'section' => 'watchlist/opt-out',
+                               'label-message' => 'rcfilters-watchlist-preference-label',
+                               'help-message' => 'rcfilters-watchlist-preference-help',
+                       ];
+               }
        }
 
        /**
index dda1dac..1862133 100644 (file)
@@ -111,10 +111,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
-               return (
-                       $config->get( 'StructuredChangeFiltersOnWatchlist' ) &&
-                       $user->getOption( 'rcenhancedfilters' )
-               );
+               if ( !$config->get( 'StructuredChangeFiltersOnWatchlist' ) ) {
+                       return false;
+               }
+
+               if ( $config->get( 'StructuredChangeFiltersShowWatchlistPreference' ) ) {
+                       return !$user->getOption( 'wlenhancedfilters-disable' );
+               } else {
+                       return $user->getOption( 'rcenhancedfilters' );
+               }
        }
 
        /**
index 215b356..eec7ad1 100644 (file)
        "rcfilters-watchlist-showupdated": "Changes to pages you haven't visited since the changes occurred are in <strong>bold</strong>, with solid markers.",
        "rcfilters-preference-label": "Hide the improved version of Recent Changes",
        "rcfilters-preference-help": "Rolls back the 2017 interface redesign and all tools added then and since.",
+       "rcfilters-watchlist-preference-label": "Hide the improved version of the Watchlist",
+       "rcfilters-watchlist-preference-help": "Rolls back the 2017 interface redesign and all tools added then and since.",
        "rcfilters-filter-showlinkedfrom-label": "Show changes on pages linked from",
        "rcfilters-filter-showlinkedfrom-option-label": "<strong>Pages linked from</strong> the selected page",
        "rcfilters-filter-showlinkedto-label": "Show changes on pages linking to",
index 97ac807..56f01fe 100644 (file)
        "rcfilters-watchlist-showupdated": "Message at the top of [[Special:Watchlist]] when the Structured filters are enabled that describes what unseen changes look like.\n\nCf. {{msg-mw|wlheader-showupdated}}",
        "rcfilters-preference-label": "Option in RecentChanges tab of [[Special:Preferences]].",
        "rcfilters-preference-help": "Explanation for the option in the RecentChanges tab of [[Special:Preferences]].",
+       "rcfilters-watchlist-preference-label": "Option in Watchlist tab of [[Special:Preferences]].",
+       "rcfilters-watchlist-preference-help": "Explanation for the option in the Watchlist tab of [[Special:Preferences]].",
        "rcfilters-filter-showlinkedfrom-label": "Label that indicates that the page is showing changes that link FROM the target page. Used on [[Special:Recentchangeslinked]] when structured filters are enabled.",
        "rcfilters-filter-showlinkedfrom-option-label": "Menu option to show changes FROM the target page. Used on [[Special:Recentchangeslinked]] when structured filters are enabled.",
        "rcfilters-filter-showlinkedto-label": "Label that indicates that the page is showing changes that link TO the target page. Used on [[Special:Recentchangeslinked]] when structured filters are enabled.",