RCLFilters specific message for invalid target page
authorStephane Bisson <sbisson@wikimedia.org>
Mon, 22 Jan 2018 22:46:31 +0000 (14:46 -0800)
committerCatrope <roan@wikimedia.org>
Fri, 23 Feb 2018 06:02:22 +0000 (06:02 +0000)
* always hide the big red .errorbox when rcfilters
  is enabled

* always identify the changes-list section with
  .mw-changeslist or .mw-changeslist-empty

* conditionally add .mw-changeslist-empty-<reason>
  to the changeslist section when the reason for it
  being empty is known

* handle RCL being empty because the specified title
  is invalid or inter-wiki

Bug: T184952
Change-Id: I5dd974f5f769503e89301dd22bdfd3d49b0dd11f

includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchangeslinked.php
resources/Resources.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.less
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js

index 5aa1c6b..4204443 100644 (file)
@@ -844,7 +844,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         */
        protected function outputTimeout() {
                $this->getOutput()->addHTML(
-                       '<div class="mw-changeslist-timeout">' .
+                       '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
                        $this->msg( 'recentchanges-timeout' )->parse() .
                        '</div>'
                );
index d4aef6c..181b4db 100644 (file)
@@ -65,7 +65,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
                        $outputPage->addHTML(
                                Html::errorBox( $this->msg( 'allpagesbadtitle' )->parse() )
                        );
-
                        return false;
                }
 
@@ -295,12 +294,19 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
        }
 
        protected function outputNoResults() {
-               if ( $this->getTargetTitle() === false ) {
+               $targetTitle = $this->getTargetTitle();
+               if ( $targetTitle === false ) {
                        $this->getOutput()->addHTML(
-                               '<div class="mw-changeslist-notargetpage">' .
+                               '<div class="mw-changeslist-empty mw-changeslist-notargetpage">' .
                                $this->msg( 'recentchanges-notargetpage' )->parse() .
                                '</div>'
                        );
+               } elseif ( !$targetTitle || $targetTitle->isExternal() ) {
+                       $this->getOutput()->addHTML(
+                               '<div class="mw-changeslist-empty mw-changeslist-invalidtargetpage">' .
+                               $this->msg( 'allpagesbadtitle' )->parse() .
+                               '</div>'
+                       );
                } else {
                        parent::outputNoResults();
                }
index 2465441..f5f17e0 100644 (file)
@@ -1929,6 +1929,7 @@ return [
                        'recentchanges-timeout',
                        'recentchanges-network',
                        'recentchanges-notargetpage',
+                       'allpagesbadtitle',
                        'quotation-marks',
                ],
                'dependencies' => [
index dcce92d..16f58ee 100644 (file)
                                info.noResultsDetails = 'NO_RESULTS_TIMEOUT';
                        } else if ( $root.find( '.mw-changeslist-notargetpage' ).length ) {
                                info.noResultsDetails = 'NO_RESULTS_NO_TARGET_PAGE';
+                       } else if ( $root.find( '.mw-changeslist-invalidtargetpage' ).length ) {
+                               info.noResultsDetails = 'NO_RESULTS_INVALID_TARGET_PAGE';
                        } else {
                                info.noResultsDetails = 'NO_RESULTS_NORMAL';
                        }
index 1f72484..d181532 100644 (file)
                                {
                                        $topSection: $topSection,
                                        $filtersContainer: $( '.rcfilters-container' ),
-                                       $changesListContainer: $( [
-                                               '.mw-changeslist',
-                                               '.mw-changeslist-empty',
-                                               '.mw-changeslist-timeout',
-                                               '.mw-changeslist-notargetpage'
-                                       ].join( ', ' ) ),
+                                       $changesListContainer: $( '.mw-changeslist, .mw-changeslist-empty' ),
                                        $formContainer: $initialFieldset
                                }
                        );
index 413d45b..ca9b252 100644 (file)
                }
        }
 
-       // Temporarily hide any specific 'no result' message while we load rcfilters.
-       .mw-changeslist-empty,
-       .mw-changeslist-timeout,
-       .mw-changeslist-notargetpage {
+       // Temporarily hide the empty results section while we load rcfilters.
+       .mw-changeslist-empty {
+               display: none;
+       }
+
+       .errorbox {
                display: none;
        }
 
index e2092dc..b49a1cb 100644 (file)
                                                        .text( mw.msg( this.getMsgKeyForNoResults( noResultsDetails ) ) )
                                        );
 
-                               this.$element.removeClass( 'mw-changeslist-timeout' );
-                               this.$element.removeClass( 'mw-changeslist-notargetpage' );
+                               // remove all classes matching mw-changeslist-*
+                               this.$element.removeClass( function ( elementIndex, allClasses ) {
+                                       return allClasses
+                                               .split( ' ' )
+                                               .filter( function ( className ) {
+                                                       return className.indexOf( 'mw-changeslist-' ) === 0;
+                                               } )
+                                               .join( ' ' );
+                               } );
                        }
 
                        this.$element.append( $message );
                        NO_RESULTS_NORMAL: 'recentchanges-noresult',
                        NO_RESULTS_TIMEOUT: 'recentchanges-timeout',
                        NO_RESULTS_NETWORK_ERROR: 'recentchanges-network',
-                       NO_RESULTS_NO_TARGET_PAGE: 'recentchanges-notargetpage'
+                       NO_RESULTS_NO_TARGET_PAGE: 'recentchanges-notargetpage',
+                       NO_RESULTS_INVALID_TARGET_PAGE: 'allpagesbadtitle'
                };
                return reasonMsgKeyMap[ reason ];
        };