From: petarpetkovic Date: Tue, 31 Oct 2017 15:36:14 +0000 (+0100) Subject: More specific warning when RC page fails to load X-Git-Tag: 1.31.0-rc.0~1617^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=55c47368834161ba5b7fa9415716d41b0073332e;p=lhc%2Fweb%2Fwiklou.git More specific warning when RC page fails to load - Provide more specific message when the page fails to load (when the connection drops for any reason), replacing the current message, which says misleadingly that no results could be found. - Center warning messages horizontally. Bug: T177413 Change-Id: Ie2bc4fe4bd19103b513e4753e59f4adb295fbafa --- diff --git a/languages/i18n/en.json b/languages/i18n/en.json index e4aa867b32..27bc813eb9 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1340,6 +1340,7 @@ "recentchangestext": "-", "recentchanges-noresult": "No changes during the given period match these criteria.", "recentchanges-timeout": "This search has timed out. You may wish to try different search parameters.", + "recentchanges-network": "Due to a technical error, no results could be loaded. Please try refreshing the page.", "recentchanges-feed-description": "Track the most recent changes to the wiki in this feed.", "recentchanges-label-newpage": "This edit created a new page", "recentchanges-label-minor": "This is a minor edit", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 9e7bfca612..d2666c4c8e 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1534,6 +1534,7 @@ "recentchangestext": "Text in [[Special:RecentChanges]]", "recentchanges-noresult": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]], and [[Special:Watchlist]] when there are no changes to be shown.", "recentchanges-timeout": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]], and [[Special:Watchlist]] when a query times out.", + "recentchanges-network": "Used in [[Special:RecentChanges]], [[Special:RecentChangesLinked]] and [[Special:Watchlist]] when network error occurs.", "recentchanges-feed-description": "Used in feed of RecentChanges. See example [{{canonicalurl:Special:RecentChanges|feed=atom}} feed].", "recentchanges-label-newpage": "# Used as tooltip for {{msg-mw|Newpageletter}}.\n# Also used as legend. Preceded by {{msg-mw|Newpageletter}} and followed by {{msg-mw|Recentchanges-legend-newpage}}.", "recentchanges-label-minor": "# Used as tooltip for {{msg-mw|Minoreditletter}}\n# Also used as legend. Preceded by {{msg-mw|Minoreditletter}}", diff --git a/resources/Resources.php b/resources/Resources.php index df0c24968b..7d606e7fbc 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1891,6 +1891,7 @@ return [ 'invert', 'recentchanges-noresult', 'recentchanges-timeout', + 'recentchanges-network', 'quotation-marks', ], 'dependencies' => [ diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js index 3c03c70a0d..15fe334261 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ChangesListViewModel.js @@ -33,7 +33,7 @@ * @event update * @param {jQuery|string} $changesListContent List of changes * @param {jQuery} $fieldset Server-generated form - * @param {boolean} isDatabaseTimeout Whether this is an error state due to a database query + * @param {string} noResultsDetails Type of no result error * @param {boolean} isInitialDOM Whether the previous dom variables are from the initial page load * @param {boolean} fromLiveUpdate These are new changes fetched via Live Update * @@ -73,18 +73,18 @@ * * @param {jQuery|string} changesListContent * @param {jQuery} $fieldset - * @param {boolean} isDatabaseTimeout Whether this is an error state due to a database query + * @param {string} noResultsDetails Type of no result error * timeout. * @param {boolean} [isInitialDOM] Using the initial (already attached) DOM elements * @param {boolean} [separateOldAndNew] Whether a logical separation between old and new changes is needed * @fires update */ - mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, isDatabaseTimeout, isInitialDOM, separateOldAndNew ) { + mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, noResultsDetails, isInitialDOM, separateOldAndNew ) { var from = this.nextFrom; this.valid = true; this.extractNextFrom( $fieldset ); this.checkForUnseenWatchedChanges( changesListContent ); - this.emit( 'update', changesListContent, $fieldset, isDatabaseTimeout, isInitialDOM, separateOldAndNew ? from : null ); + this.emit( 'update', changesListContent, $fieldset, noResultsDetails, isInitialDOM, separateOldAndNew ? from : null ); }; /** diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 8d36cf5ef2..d1092a1ced 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -908,7 +908,7 @@ this.changesListModel.update( $changesListContent, $fieldset, - pieces.noResultsDetails === 'NO_RESULTS_TIMEOUT', + pieces.noResultsDetails, false, // separator between old and new changes updateMode === this.SHOW_NEW_CHANGES || updateMode === this.LIVE_UPDATE @@ -1005,7 +1005,22 @@ return this._queryChangesList( 'updateChangesList' ) .then( function ( data ) { - var $parsed = $( '
' ).append( $( $.parseHTML( data.content ) ) ); + var $parsed; + + // Status code 0 is not HTTP status code, + // but is valid value of XMLHttpRequest status. + // It is used for variety of network errors, for example + // when an AJAX call was cancelled before getting the response + if ( data && data.status === 0 ) { + return { + changes: 'NO_RESULTS', + // We need empty result set, to avoid exceptions because of undefined value + fieldset: $( [] ), + noResultsDetails: 'NO_RESULTS_NETWORK_ERROR' + }; + } + + $parsed = $( '
' ).append( $( $.parseHTML( data.content ) ) ); return this._extractChangesListInfo( $parsed ); diff --git a/resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ChangesListWrapperWidget.less b/resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ChangesListWrapperWidget.less index 0fa3137569..b923efb879 100644 --- a/resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ChangesListWrapperWidget.less +++ b/resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ChangesListWrapperWidget.less @@ -31,8 +31,9 @@ &-noresult, &-conflict { - font-weight: bold; margin-bottom: 0.5em; + font-weight: bold; + text-align: center; } } diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js index d4faf836df..b6a0a4fff4 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js @@ -119,12 +119,12 @@ * * @param {jQuery|string} $changesListContent The content of the updated changes list * @param {jQuery} $fieldset The content of the updated fieldset - * @param {boolean} isDatabaseTimeout Whether this is an error state due to a database query + * @param {string} noResultsDetails Type of no result error * @param {boolean} isInitialDOM Whether $changesListContent is the existing (already attached) DOM * @param {boolean} from Timestamp of the new changes */ mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onModelUpdate = function ( - $changesListContent, $fieldset, isDatabaseTimeout, isInitialDOM, from + $changesListContent, $fieldset, noResultsDetails, isInitialDOM, from ) { var conflictItem, noResultsKey, $message = $( '
' ) @@ -154,9 +154,12 @@ .text( mw.message( conflictItem.getCurrentConflictResultMessage() ).text() ) ); } else { - noResultsKey = isDatabaseTimeout ? - 'recentchanges-timeout' : - 'recentchanges-noresult'; + noResultsKey = + ( noResultsDetails === 'NO_RESULTS_TIMEOUT' ) ? + 'recentchanges-timeout' : + ( noResultsDetails === 'NO_RESULTS_NETWORK_ERROR' ) ? + 'recentchanges-network' : + 'recentchanges-noresult'; $message .append( diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js index 4edc272d1d..6aa335a58a 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js @@ -95,10 +95,10 @@ * * @param {jQuery|string} $changesList Updated changes list * @param {jQuery} $fieldset Updated fieldset - * @param {boolean} isDatabaseTimeout Whether this is an error state due to a database query + * @param {string} noResultsDetails Type of no result error * @param {boolean} isInitialDOM Whether $changesListContent is the existing (already attached) DOM */ - mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset, isDatabaseTimeout, isInitialDOM ) { + mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset, noResultsDetails, isInitialDOM ) { this.$submitButton.prop( 'disabled', false ); // Replace the entire fieldset