jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/342643 )

Change subject: Allow the ORES extension features to be 'on' by default
......................................................................


Allow the ORES extension features to be 'on' by default

Introducing $wgOresExtensionStatus, it takes the following values
  'on': all ORES extension features are turned on
  'beta': (same as current behavior) it adds the beta feature which
          can be enabled by individual users
  <anything else>: means it is turned off

Rephrased 'hide probably good edits from rc|watchlist' preferenced
as per the ticket.

Added new preference to control highlighting of potentially damaging edits.

Moved 'oresWatchlistHideNonDamaging' preference to 
'watchlist/advancedwatchlist' section.

Bug: T159763
Change-Id: I63b11eff3a4a2f41e38b1a5ea8daaeb4db60a51c
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/Hooks.php
M modules/ext.ores.styles.css
M tests/phpunit/includes/HooksTest.php
6 files changed, 71 insertions(+), 36 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 16c0db0..f22a55a 100644
--- a/extension.json
+++ b/extension.json
@@ -100,6 +100,7 @@
                "ORESFetchScoreJob": "ORES\\FetchScoreJob"
        },
        "config": {
+               "OresExtensionStatus": "on",
                "OresBaseUrl": "https://ores.wikimedia.org/";,
                "OresExcludeBots": true,
                "OresModels": {
diff --git a/i18n/en.json b/i18n/en.json
index 5912924..8cdf211 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -15,8 +15,6 @@
        "ores-help-damaging-pref": "This threshold determines how sensitive 
ORES is when flagging edits needing review",
        "ores-hide-nondamaging-filter": "Hide probably good edits",
        "ores-pref-damaging": "ORES sensitivity",
-       "ores-pref-rc-hidenondamaging": "Hide probably good edits from recent 
changes",
-       "ores-pref-watchlist-hidenondamaging": "Hide probably good edits from 
the watchlist",
        "ores-rcfilters-damaging-title": "Contribution quality predictions",
        "ores-rcfilters-damaging-likelygood-label": "Very likely good",
        "ores-rcfilters-damaging-likelygood-desc": "Highly accurate at finding 
almost all problem-free edits.",
@@ -33,6 +31,9 @@
        "ores-rcfilters-goodfaith-maybebad-desc": "Finds most bad-faith edits 
but with a lower accuracy.",
        "ores-rcfilters-goodfaith-bad-label": "Likely bad faith",
        "ores-rcfilters-goodfaith-bad-desc": "With medium accuracy, finds the 
most obvious 25% of bad-faith edits.",
+       "ores-pref-highlight": "Highlight probably damaging edits",
+       "ores-pref-rc-hidenondamaging": "Show only edits that may have problems 
(and hide probably good edits)",
+       "ores-pref-watchlist-hidenondamaging": "Show only edits that may have 
problems (and hide probably good edits)",
        "prefs-ores" : "Revision scoring",
        "apihelp-query+ores-description": "Return ORES configuration and model 
data for this wiki.",
        "apihelp-query+ores-example-simple": "Fetch ORES data:",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 1a58bfd..5615b1a 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -19,6 +19,7 @@
        "ores-help-damaging-pref": "Help text for \"ORES sensitivity\" in 
preferences",
        "ores-hide-nondamaging-filter": "Label for Contributions filter, 'only 
show'",
        "ores-pref-damaging": "Part asking for damaging threshold",
+       "ores-pref-highlight": "Display message for user preference to enable 
highlighting of damaging edits.",
        "ores-pref-rc-hidenondamaging": "Display message for user preferences 
to make hidenondamaging default in recent changes",
        "ores-pref-watchlist-hidenondamaging": "Display message for user 
preferences to make hidenondamaging default in the watchlist",
        "ores-rcfilters-damaging-title": "Title for the filter group for ORES 
damaging score.",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 576d899..3f6260f 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -355,6 +355,9 @@
                        }
 
                        $classes[] = 'damaging';
+                       if ( $changesList->getUser()->getBoolOption( 
'oresHighlight' ) ) {
+                               $classes[] = 'ores-highlight';
+                       }
                        $parts = explode( $separator, $s );
                        $parts[1] = ChangesList::flag( 'damaging' ) . $parts[1];
                        $s = implode( $separator, $parts );
@@ -437,6 +440,9 @@
                if ( $row->ores_damaging_score > $row->ores_damaging_threshold 
) {
                        // Add the damaging class
                        $classes[] = 'damaging';
+                       if ( $pager->getUser()->getBoolOption( 'oresHighlight' 
) ) {
+                               $classes[] = 'ores-highlight';
+                       }
                }
        }
 
@@ -484,6 +490,9 @@
                $damaging = self::getScoreRecentChangesList( $rcObj, $context );
                if ( $damaging ) {
                        $classes[] = 'damaging';
+                       if ( $context->getUser()->getBoolOption( 
'oresHighlight' ) ) {
+                               $classes[] = 'ores-highlight';
+                       }
                        $data['recentChangesFlags']['damaging'] = true;
                }
        }
@@ -561,10 +570,17 @@
                        'help-message' => 'ores-help-damaging-pref',
                ];
 
+               // highlight damaging edits based on configured sensitivity
+               $preferences['oresHighlight'] = [
+                       'type' => 'toggle',
+                       'section' => 'rc/ores',
+                       'label-message' => 'ores-pref-highlight',
+               ];
+
                // Make hidenondamaging default
                $preferences['oresWatchlistHideNonDamaging'] = [
                        'type' => 'toggle',
-                       'section' => 'watchlist/ores',
+                       'section' => 'watchlist/advancedwatchlist',
                        'label-message' => 
'ores-pref-watchlist-hidenondamaging',
                ];
                $preferences['oresRCHideNonDamaging'] = [
@@ -594,8 +610,10 @@
                                'oresThresholds',
                                [ 'damaging' => $wgOresDamagingThresholds ]
                        );
-                       $out->addModules( 'ext.ores.highlighter' );
                        $out->addModuleStyles( 'ext.ores.styles' );
+                       if ( $out->getUser()->getBoolOption( 'oresHighlight' ) 
) {
+                               $out->addModules( 'ext.ores.highlighter' );
+                       }
                }
        }
 
@@ -606,31 +624,45 @@
         * @param string[] &$prefs
         */
        public static function onGetBetaFeaturePreferences( User $user, array 
&$prefs ) {
-               global $wgExtensionAssetsPath;
+               global $wgOresExtensionStatus, $wgExtensionAssetsPath;
 
-               $prefs['ores-enabled'] = [
-                       'label-message' => 'ores-beta-feature-message',
-                       'desc-message' => 'ores-beta-feature-description',
-                       'screenshot' => [
-                               'ltr' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-ltr.svg",
-                               'rtl' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-rtl.svg",
-                       ],
-                       'info-link' => 
'https://www.mediawiki.org/wiki/ORES_review_tool',
-                       'discussion-link' => 
'https://www.mediawiki.org/wiki/Talk:ORES_review_tool',
-               ];
+               if ( $wgOresExtensionStatus === 'beta' ) {
+                       $prefs['ores-enabled'] = [
+                               'label-message' => 'ores-beta-feature-message',
+                               'desc-message' => 
'ores-beta-feature-description',
+                               'screenshot' => [
+                                       'ltr' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-ltr.svg",
+                                       'rtl' => 
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-rtl.svg",
+                               ],
+                               'info-link' => 
'https://www.mediawiki.org/wiki/ORES_review_tool',
+                               'discussion-link' => 
'https://www.mediawiki.org/wiki/Talk:ORES_review_tool',
+                       ];
+               }
        }
 
        /**
-        * Check whether the user enabled ores as a beta feature
+        * Check whether ores is enabled
         *
         * @param User $user
         * @return bool
         */
        private static function oresEnabled( User $user ) {
-               if ( !class_exists( 'BetaFeatures' ) ) {
-                       return false;
+               global $wgOresExtensionStatus;
+
+               // enabled by default for everybody
+               if ( $wgOresExtensionStatus === 'on' ) {
+                       return true;
                }
-               return BetaFeatures::isFeatureEnabled( $user, 'ores-enabled' );
+
+               // exists as a beta feature, enabled by $user
+               if ( $wgOresExtensionStatus === 'beta' ) {
+                       return $user &&
+                               $user->isLoggedIn() &&
+                               class_exists( 'BetaFeatures' ) &&
+                               BetaFeatures::isFeatureEnabled( $user, 
'ores-enabled' );
+               }
+
+               return false;
        }
 
        /**
diff --git a/modules/ext.ores.styles.css b/modules/ext.ores.styles.css
index acb7ce5..4bbc11b 100644
--- a/modules/ext.ores.styles.css
+++ b/modules/ext.ores.styles.css
@@ -9,8 +9,8 @@
 /**
  * Make the whole row orange
  */
-li.damaging,
-tr.damaging {
+li.damaging.ores-highlight,
+tr.damaging.ores-highlight {
        background: #fef6e7;
        line-height: 1.8;
 }
diff --git a/tests/phpunit/includes/HooksTest.php 
b/tests/phpunit/includes/HooksTest.php
index 9155431..5824a97 100644
--- a/tests/phpunit/includes/HooksTest.php
+++ b/tests/phpunit/includes/HooksTest.php
@@ -496,31 +496,31 @@
                $prefs = [];
                ORES\Hooks::onGetPreferences( $this->user, $prefs );
 
-               $this->assertSame( 3, count( $prefs ) );
+               $this->assertSame( 4, count( $prefs ) );
        }
 
-       public function testOnGetPreferencesDisabled() {
-               $user = static::getTestUser()->getUser();
-               $user->setOption( 'ores-enabled', "0" );
-               $user->saveSettings();
-
+       public function testOnGetBetaFeaturePreferences_on() {
+               $this->setMwGlobals( 'wgOresExtensionStatus', 'on' );
                $prefs = [];
-               ORES\Hooks::onGetPreferences( $this->user, $prefs );
+               ORES\Hooks::onGetBetaFeaturePreferences( $this->user, $prefs );
 
-               $this->assertSame( [], $prefs );
+               $this->assertSame( 0, count( $prefs ) );
        }
 
-       public function testOnGetBetaFeaturePreferences() {
+       public function testOnGetBetaFeaturePreferences_off() {
+               $this->setMwGlobals( 'wgOresExtensionStatus', 'off' );
+               $prefs = [];
+               ORES\Hooks::onGetBetaFeaturePreferences( $this->user, $prefs );
+
+               $this->assertSame( 0, count( $prefs ) );
+       }
+
+       public function testOnGetBetaFeaturePreferences_beta() {
+               $this->setMwGlobals( 'wgOresExtensionStatus', 'beta' );
                $prefs = [];
                ORES\Hooks::onGetBetaFeaturePreferences( $this->user, $prefs );
 
                $this->assertSame( 1, count( $prefs ) );
-               $this->assertArrayHasKey( 'ores-enabled', $prefs );
-       }
-
-       public function testOresEnabled() {
-               $prefs = [];
-               ORES\Hooks::onGetBetaFeaturePreferences( $this->user, $prefs );
                $this->assertArrayHasKey( 'ores-enabled', $prefs );
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I63b11eff3a4a2f41e38b1a5ea8daaeb4db60a51c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to