Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312445

Change subject: Add a continuation button to ApiSandbox
......................................................................

Add a continuation button to ApiSandbox

Change-Id: I4def43b2000b5639e3ced2643afea4b1288e28b0
---
M includes/api/ApiFormatBase.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/Resources.php
M resources/src/mediawiki.special/mediawiki.special.apisandbox.js
5 files changed, 37 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/45/312445/1

diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php
index c826bba..4df7f51 100644
--- a/includes/api/ApiFormatBase.php
+++ b/includes/api/ApiFormatBase.php
@@ -231,6 +231,7 @@
                                                        
$out->getModuleScripts(),
                                                        $out->getModuleStyles()
                                                ) ) ),
+                                               'continue' => 
$this->getResult()->getResultData( 'continue' ),
                                                'time' => round( $time * 1000 ),
                                        ],
                                        false, FormatJson::ALL_OK
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 67e6491..6af0f1e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1922,6 +1922,7 @@
        "apisandbox-results-fixtoken-fail": "Failed to fetch \"$1\" token.",
        "apisandbox-alert-page": "Fields on this page are not valid.",
        "apisandbox-alert-field": "The value of this field is not valid.",
+       "apisandbox-continue": "Continue",
        "booksources": "Book sources",
        "booksources-summary": "",
        "booksources-search-legend": "Search for book sources",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 163b613..0f7b60b 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2106,6 +2106,7 @@
        "apisandbox-results-fixtoken-fail": "Displayed as an error message from 
JavaScript when a CSRF token could not be fetched.\n\nParameters:\n* $1 - Token 
type",
        "apisandbox-alert-page": "Tooltip for the alert icon on a module's page 
tab when the page contains fields with issues.",
        "apisandbox-alert-field": "Tooltip for the alert icon on a field when 
the field has issues.",
+       "apisandbox-continue": "Button text for sending another request using 
query continuation.",
        "booksources": "{{doc-special|BookSources}}\n\n'''This message 
shouldn't be changed unless it has serious mistakes.'''\n\nIt's used as the 
page name of the configuration page of [[Special:BookSources]]. Changing it 
breaks existing sites using the default version of this message.\n\nSee 
also:\n* {{msg-mw|Booksources|title}}\n* {{msg-mw|Booksources-text|text}}",
        "booksources-summary": "{{doc-specialpagesummary|booksources}}",
        "booksources-search-legend": "Box heading on [[Special:BookSources|book 
sources]] special page. The box is for searching for places where a particular 
book can be bought or viewed.",
diff --git a/resources/Resources.php b/resources/Resources.php
index 89168db..7678037 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1858,6 +1858,7 @@
                        'apisandbox-results-fixtoken-fail',
                        'apisandbox-alert-page',
                        'apisandbox-alert-field',
+                       'apisandbox-continue',
                        'blanknamespace',
                ],
        ],
diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js 
b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
index 5c3715d..8b61dcb 100644
--- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
+++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js
@@ -962,6 +962,39 @@
                                                                .text( data )
                                                                .appendTo( 
$result );
                                                }
+                                               if ( data.continue ) {
+                                                       $result.append(
+                                                               $( '<div>' 
).append(
+                                                                       new 
OO.ui.ButtonWidget( {
+                                                                               
label: mw.message( 'apisandbox-continue' ).text()
+                                                                       } ).on( 
'click', function () {
+                                                                               
$.each( pages, function ( _, page ) {
+                                                                               
        var key,
+                                                                               
                params = {};
+                                                                               
        page.getQueryParams( params, {} );
+                                                                               
        $.each( params, function ( k ) {
+                                                                               
                // This is a hack. Normally the client would have to keep track 
of which are the
+                                                                               
                // original parameters and which are from continuing, and only 
keep the former,
+                                                                               
                // but with the possibility of the user clicking around in the 
GUI between
+                                                                               
                // requests that is too much of a moving target.
+                                                                               
                if ( k.match( /continue$/ ) ) {
+                                                                               
                        delete params[k];
+                                                                               
                }
+                                                                               
        } );
+                                                                               
        for ( i = 0; i < page.paramInfo.parameters.length; i++ ) {
+                                                                               
                key = ( page.prefix || '' ) + ( page.paramInfo.prefix || '' )
+                                                                               
                        + page.paramInfo.parameters[i].name;
+                                                                               
                if ( key in data.continue ) {
+                                                                               
                        params[key] = data.continue[key];
+                                                                               
                }
+                                                                               
        }
+                                                                               
        page.loadQueryParams( params );
+                                                                               
} );
+                                                                               
ApiSandbox.sendRequest();
+                                                                       } 
).$element
+                                                               )
+                                                       );
+                                               }
                                                if ( typeof loadTime === 
'number' ) {
                                                        $result.append(
                                                                $( '<div>' 
).append(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4def43b2000b5639e3ced2643afea4b1288e28b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>

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

Reply via email to