Petar.petkovic has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392452 )

Change subject: [WIP] Split WL and RC prefs for ORES
......................................................................

[WIP] Split WL and RC prefs for ORES

- Make ORES preferences separate for Watchlist and RecentChanges,
so both include:
        * Prediction Threshold
        * "Highlight likely problem edits" control
        * "Show only likely problem edits" control
- Provide both sections with separate titles, not mentioning the other one.
- Change instruction text displayed on help icon click.

Bug: T180866
Change-Id: Ifbc5a6b3a5f5e634cc308d769360365f30fceecc
---
M extension.json
M i18n/en.json
M includes/Hooks.php
M includes/Hooks/PreferencesHookHandler.php
4 files changed, 27 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES 
refs/changes/52/392452/1

diff --git a/extension.json b/extension.json
index 63f226b..e8c6af3 100644
--- a/extension.json
+++ b/extension.json
@@ -206,6 +206,7 @@
        "DefaultUserOptions": {
                "ores-damaging-flag-rc": false,
                "oresDamagingPref": "soft",
+               "rcOresDamagingPref": "soft",
                "oresHighlight": false,
                "oresRCHideNonDamaging": false,
                "oresWatchlistHideNonDamaging": false
diff --git a/i18n/en.json b/i18n/en.json
index 5cd0889..498b69e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -11,11 +11,11 @@
        "ores-damaging-legend": "This edit may have problems and should be 
reviewed ([[:mw:Special:MyLanguage/ORES review tool|more info]])",
        "ores-hide-nondamaging-filter": "Hide probably good edits",
        "ores-pref-damaging": "Prediction threshold",
-       "ores-pref-damaging-flag": "Highlight likely problem edits with colors 
and an \"{{int:ores-damaging-letter}}\" for \"needs review\" (to set the level 
at which edits are marked, use the \"{{int:ores-pref-damaging}}\" setting in 
the Watchlist preferences)",
+       "ores-pref-damaging-flag": "Highlight likely problem edits with colors 
and an \"{{int:ores-damaging-letter}}\" for \"needs review\"",
        "ores-damaging-maybebad": "May have problems (flags most problem edits 
but includes many false positives)",
        "ores-damaging-likelybad": "Likely have problems (medium probability)",
        "ores-damaging-verylikelybad": "Very likely have problems (flags few 
false positives but finds a smaller % of problem edits)",
-       "ores-help-damaging-pref": "Sets the sensitivity of the \"Highlight 
likely problem edits...\" and \"Show only likely problem edits...\" options on 
Recent Changes and Watchlist.",
+       "ores-help-damaging-pref": "Change the \"threshold\" setting to make 
the options below broader or more selective.",
        "ores-rcfilters-whats-this-link-text": "Learn more",
        "ores-rcfilters-ores-conflicts-logactions-global": "The 
\"{{int:rcfilters-filter-logactions-label}}\" filter conflicts with one or more 
Contribution Quality or User Intent filters. Quality and Intent predictions are 
not available for logged actions. The conflicting filters are marked in the 
Active Filters area, above.",
        "ores-rcfilters-logactions-conflicts-ores": "This filter conflicts with 
one or more Contribution Quality or User Intent filters. Quality and Intent 
predictions are not available for logged actions.",
@@ -48,7 +48,8 @@
        "ores-pref-highlight": "Highlight likely problem edits with colors and 
an \"{{int:ores-damaging-letter}}\" for \"needs review\"",
        "ores-pref-rc-hidenondamaging": "Show only likely problem edits (and 
hide probably good edits)",
        "ores-pref-watchlist-hidenondamaging": "Show only likely problem edits 
(and hide probably good edits)",
-       "prefs-ores" : "Revision scoring",
+       "prefs-ores-wl" : "Revision scoring on Watchlist",
+       "prefs-ores-rc" : "Revision scoring on Recent changes, Related changes, 
Contributions",
        "apihelp-query+ores-description": "Return ORES configuration and model 
data for this wiki.",
        "apihelp-query+ores-summary": "Return ORES configuration and model data 
for this wiki.",
        "apihelp-query+ores-example-simple": "Fetch ORES data:",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 78c71c3..abaee0a 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -10,6 +10,8 @@
 use MediaWiki\Logger\LoggerFactory;
 use OutputPage;
 use RecentChange;
+use DerivativeContext;
+use DerivativeRequest;
 use RequestContext;
 use Skin;
 use SpecialRecentChanges;
@@ -115,7 +117,12 @@
         * @return string 'maybebad', 'likelybad', or 'verylikelybad'
         */
        public static function getDamagingLevelPreference( User $user ) {
-               $pref = $user->getOption( 'oresDamagingPref' );
+               $context = new DerivativeContext( RequestContext::getMain() );
+               $context->setUser( $user );
+               $context->setRequest( new DerivativeRequest( 
$context->getRequest(), [] ) );
+               $wlPage = self::isWLPage( $context );
+
+               $pref = $user->getOption( $wlPage ? 'oresDamagingPref' : 
'rcOresDamagingPref' );
                if ( isset( self::$damagingPrefMap[ $pref ] ) ) {
                        $pref = self::$damagingPrefMap[ $pref ];
                }
diff --git a/includes/Hooks/PreferencesHookHandler.php 
b/includes/Hooks/PreferencesHookHandler.php
index 44a538b..3d10fdc 100644
--- a/includes/Hooks/PreferencesHookHandler.php
+++ b/includes/Hooks/PreferencesHookHandler.php
@@ -3,9 +3,6 @@
 namespace ORES\Hooks;
 
 use ORES\Hooks;
-use DerivativeContext;
-use DerivativeRequest;
-use RequestContext;
 use User;
 
 class PreferencesHookHandler {
@@ -39,11 +36,19 @@
                                $options[ $text ] = $prefName;
                        }
                }
-               $oresSection = $wgOresExtensionStatus === 'beta' ? 'rc/ores' : 
'watchlist/ores';
+
                $preferences['oresDamagingPref'] = [
                        'type' => 'select',
                        'label-message' => 'ores-pref-damaging',
-                       'section' => $oresSection,
+                       'section' => 'watchlist/ores-wl',
+                       'options' => $options,
+                       'help-message' => 'ores-help-damaging-pref',
+               ];
+
+               $preferences['rcOresDamagingPref'] = [
+                       'type' => 'select',
+                       'label-message' => 'ores-pref-damaging',
+                       'section' => 'rc/ores-rc',
                        'options' => $options,
                        'help-message' => 'ores-help-damaging-pref',
                ];
@@ -52,14 +57,14 @@
                        // highlight damaging edits based on configured 
sensitivity
                        $preferences['oresHighlight'] = [
                                'type' => 'toggle',
-                               'section' => $oresSection,
+                               'section' => 'watchlist/ores-wl',
                                'label-message' => 'ores-pref-highlight',
                        ];
 
                        // Control whether the "r" appears on RC
                        $preferences['ores-damaging-flag-rc'] = [
                                'type' => 'toggle',
-                               'section' => 'rc/advancedrc',
+                               'section' => 'rc/ores-rc',
                                'label-message' => 'ores-pref-damaging-flag',
                        ];
                }
@@ -67,26 +72,14 @@
                // Make hidenondamaging default
                $preferences['oresWatchlistHideNonDamaging'] = [
                        'type' => 'toggle',
-                       'section' => 'watchlist/ores',
+                       'section' => 'watchlist/ores-wl',
                        'label-message' => 
'ores-pref-watchlist-hidenondamaging',
                ];
                $preferences['oresRCHideNonDamaging'] = [
                        'type' => 'toggle',
-                       'section' => 'rc/advancedrc',
+                       'section' => 'rc/ores-rc',
                        'label-message' => 'ores-pref-rc-hidenondamaging',
                ];
-
-               // Hide RC/wL prefs if enhanced filters are enabled
-               $context = new DerivativeContext( RequestContext::getMain() );
-               $context->setUser( $user );
-               $context->setRequest( new DerivativeRequest( 
$context->getRequest(), [] ) );
-               $rcFiltersEnabled = Hooks::isRCStructuredUiEnabled( $context );
-               // HACK: Note that this only hides the preferences on the 
preferences page,
-               // it does not cause them to behave as if they're set to their 
default value,
-               // because this hook only runs on the preferences page.
-               if ( $rcFiltersEnabled ) {
-                       $wgHiddenPrefs[] = 'ores-damaging-flag-rc';
-               }
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/392452
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbc5a6b3a5f5e634cc308d769360365f30fceecc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Petar.petkovic <ppetko...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to