r78301 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78300‎ | r78301 | r78302 >
Date:13:15, 13 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r78296 - improved error handling
Modified paths:
  • /trunk/extensions/Push/Push.i18n.php (modified) (history)
  • /trunk/extensions/Push/Push.php (modified) (history)
  • /trunk/extensions/Push/includes/Push_Tab.php (modified) (history)
  • /trunk/extensions/Push/includes/ext.push.tab.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Push/Push.i18n.php
@@ -30,6 +30,7 @@
3131 'push-button-text' => 'Push',
3232 'push-tab-desc' => 'This tab allows you to push the current revision of this page to one or more other wikis.',
3333 'push-button-pushing' => 'Pushing',
 34+ 'push-button-pushing-files' => 'Pushing files',
3435 'push-button-completed' => 'Push completed',
3536 'push-button-failed' => 'Push failed',
3637 'push-tab-title' => 'Pushing $1',
Index: trunk/extensions/Push/Push.php
@@ -81,6 +81,7 @@
8282 'push-tab-last-edit',
8383 'push-tab-not-created',
8484 'push-err-captcha-page',
 85+ 'push-button-pushing-files',
8586 );
8687
8788 // For backward compatibility with MW < 1.17.
Index: trunk/extensions/Push/includes/Push_Tab.php
@@ -244,7 +244,14 @@
245245 'id' => 'targetinfo' . $targetId,
246246 'style' => 'display:none'
247247 )
248 - )
 248+ ) .
 249+ Html::element(
 250+ 'div',
 251+ array(
 252+ 'id' => 'targeterrors' . $targetId,
 253+ 'style' => 'display:none; color:darkred'
 254+ )
 255+ )
249256 ) .
250257 Html::rawElement(
251258 'td',
Index: trunk/extensions/Push/includes/ext.push.tab.js
@@ -36,6 +36,9 @@
3737 this.disabled = true;
3838 this.innerHTML = mediaWiki.msg( 'push-button-pushing' );
3939
 40+ var errorDiv = $( '#targeterrors' + $(this).attr( 'targetid' ) );
 41+ errorDiv.fadeOut( 'fast' );
 42+
4043 if ( $('#checkIncTemplates').attr('checked') ) {
4144 pages = window.wgPushTemplates;
4245 pages.unshift( $('#pageName').attr('value') );
@@ -133,42 +136,22 @@
134137 handleError( sender, targetUrl, { info: mediaWiki.msg( 'push-err-captacha', targetName ) } );
135138 }
136139 else {
137 - sender.innerHTML = mediaWiki.msg( 'push-button-completed' );
138 - setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 );
 140+ if ( $('#checkIncFiles').length != 0 && $('#checkIncFiles').attr('checked') ) {
 141+ setButtonToImgPush( sender, targetUrl, targetName );
 142+ }
 143+ else {
 144+ sender.innerHTML = mediaWiki.msg( 'push-button-completed' );
 145+ setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 );
 146+ }
139147 }
140148 }
141149 );
142150 }
143151
144 - function reEnableButton( button, targetUrl, targetName ) {
145 - button.innerHTML = mediaWiki.msg( 'push-button-text' );
146 - button.disabled = false;
147 -
148 - var pushAllButton = $('#push-all-button');
149 -
150 - // If there is a "push all" button, make sure to reset it
151 - // when all other buttons have been reset.
152 - if ( typeof pushAllButton === "undefined" ) {
153 - imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } );
154 - startImagesPush();
155 - }
156 - else {
157 - var hasDisabled = false;
158 -
159 - $.each($(".push-button"), function(i,v) {
160 - if ( v.disabled ) {
161 - hasDisabled = true;
162 - }
163 - });
164 -
165 - if ( !hasDisabled ) {
166 - pushAllButton.attr( "disabled", false );
167 - pushAllButton.text( mediaWiki.msg( 'push-button-all' ) );
168 -
169 - imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } );
170 - startImagesPush();
171 - }
172 - }
 152+ function setButtonToImgPush( button, targetUrl, targetName ) {
 153+ button.innerHTML = mediaWiki.msg( 'push-button-pushing-files' );
 154+ imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } );
 155+ startImagesPush();
173156 }
174157
175158 function getIncludedImages() {
@@ -222,23 +205,61 @@
223206 'targets': targetUrl
224207 },
225208 function( data ) {
226 - if ( data.upload ) {
227 -
 209+ var fail = false;
 210+
 211+ for ( i in data.upload ) {
 212+ if ( data.error ) {
 213+ handleError( sender, targetUrl, data.error );
 214+ fail = true;
 215+ break;
 216+ }
 217+ else if ( !data.upload ) {
 218+ handleError( sender, targetUrl, { info: 'Unknown error' } ); // TODO
 219+ fail = true;
 220+ break;
 221+ }
228222 }
229 - else if ( data.error ) {
230 - // TODO
 223+
 224+ if ( !fail ) {
 225+ sender.innerHTML = mediaWiki.msg( 'push-button-completed' );
 226+ setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 );
231227 }
232 - else {
233 - // TODO
234 - }
235228 }
236229 );
237230 }
238231
 232+ function reEnableButton( button, targetUrl, targetName ) {
 233+ button.innerHTML = mediaWiki.msg( 'push-button-text' );
 234+ button.disabled = false;
 235+
 236+ var pushAllButton = $('#push-all-button');
 237+
 238+ // If there is a "push all" button, make sure to reset it
 239+ // when all other buttons have been reset.
 240+ if ( typeof pushAllButton !== "undefined" ) {
 241+ var hasDisabled = false;
 242+
 243+ $.each($(".push-button"), function(i,v) {
 244+ if ( v.disabled ) {
 245+ hasDisabled = true;
 246+ }
 247+ });
 248+
 249+ if ( !hasDisabled ) {
 250+ pushAllButton.attr( "disabled", false );
 251+ pushAllButton.text( mediaWiki.msg( 'push-button-all' ) );
 252+ }
 253+ }
 254+ }
 255+
239256 function handleError( sender, targetUrl, error ) {
240 - alert( error.info );
 257+ var errorDiv = $( '#targeterrors' + $(sender).attr( 'targetid' ) );
 258+
 259+ errorDiv.text( error.info );
 260+ errorDiv.fadeIn( 'slow' );
 261+
241262 sender.innerHTML = mediaWiki.msg( 'push-button-failed' );
242 - setTimeout( function() {reEnableButton( sender );}, 3000 );
 263+ setTimeout( function() {reEnableButton( sender );}, 2500 );
243264 }
244265
245266 } ); })(jQuery);
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78296Added preliminary file pushing supportjeroendedauw12:29, 13 December 2010

Status & tagging log