r84223 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84222‎ | r84223 | r84224 >
Date:02:19, 18 March 2011
Author:neilk
Status:deferred
Tags:
Comment:
error status lines for duplicate uploads
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.Api.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -145,7 +145,13 @@
146146 if ( !mw.isDefined( args ) ) {
147147 args = [];
148148 }
149 - $j( this.div ).find( '.mwe-upwiz-file-status' ).html( gM( msgKey, args ) ).show();
 149+ // get the status line for our upload
 150+ $statusDiv = $j( this.div ).find( '.mwe-upwiz-file-status' );
 151+
 152+ // apply the message and args, but if any anchors were created make sure they link to new windows.
 153+ $statusDiv.msg( msgKey, args ).find( 'a' ).attr( 'target', '_blank' );
 154+
 155+ $statusDiv.show();
150156 },
151157
152158 /**
@@ -187,9 +193,7 @@
188194 var args = [ code ];
189195 if ( $j.inArray( code, mw.Api.errors ) !== -1 ) {
190196 msgKey = 'mwe-upwiz-api-error-' + code;
191 - // args may change base on particular error messages.
192 - // for instance, we are throwing away the extra info right now. Might be nice to surface that in a debug mode
193 - args = [];
 197+ args = $j.makeArray( info );
194198 }
195199 this.setStatus( msgKey, args );
196200 },
Index: trunk/extensions/UploadWizard/resources/mw.Api.js
@@ -156,6 +156,9 @@
157157 /* occurs when POST aborted - jQuery 1.4 can't distinguish abort or lost connection from 200 OK + empty result */
158158 'ok-but-empty',
159159
 160+ /* really a warning, but we treat it like an error */
 161+ 'duplicate',
 162+
160163 /* remote errors, defined in API */
161164 'uploaddisabled',
162165 'nomodule',
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -98,7 +98,13 @@
9999 return;
100100 }
101101
102 - if ( result.upload && result.upload.imageinfo ) {
 102+ if ( result.upload && result.upload.warnings && result.upload.warnings.exists ) {
 103+ var fileTitle = new mw.Title( result.upload.warnings.exists, 'file' ).toString();
 104+ var fileUri = new mw.Uri( document.URL );
 105+ fileUri.path = wgScript;
 106+ fileUri.query = { title: fileTitle, action: 'view' };
 107+ _this.setError( 'duplicate', fileUri.toString() );
 108+ } else if ( result.upload && result.upload.imageinfo ) {
103109 // success
104110 _this.state = 'transported';
105111 _this.transportProgress = 1;
@@ -133,7 +139,7 @@
134140 if ( result.error ) {
135141 code = result.error.code;
136142 info = result.error.info;
137 - }
 143+ }
138144 _this.setError( code, info );
139145 }
140146

Status & tagging log