mw.Upload.BookletLayout: Handle additional warnings/errors
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 5 Apr 2016 20:25:46 +0000 (22:25 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 5 Apr 2016 20:25:46 +0000 (22:25 +0200)
Warnings:
* 'exists-normalized': Same handling as 'exists', the only difference
  is exact match vs only matching after title normalization.
* 'was-deleted': Added new l10n message 'api-error-was-deleted',
  based on 'filewasdeleted' but shorter/simpler.

Errors:
* 'protectedpage': Display 'protectedpagetext' message.

Bug: T131709
Change-Id: Ia9f65fc39d59018dc62b758f9a2ae98de7d187fe

languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki/mediawiki.Upload.BookletLayout.js

index fe307d4..c0b2ebc 100644 (file)
        "api-error-unknownerror": "Unknown error: \"$1\".",
        "api-error-uploaddisabled": "Uploading is disabled on this wiki.",
        "api-error-verification-error": "This file might be corrupt, or have the wrong extension.",
+       "api-error-was-deleted": "A file of this name has been previously uploaded and subsequently deleted.",
        "duration-seconds": "$1 {{PLURAL:$1|second|seconds}}",
        "duration-minutes": "$1 {{PLURAL:$1|minute|minutes}}",
        "duration-hours": "$1 {{PLURAL:$1|hour|hours}}",
index 2ee34bd..285093d 100644 (file)
        "api-error-unknownerror": "API error message that can be used for client side localisation of API errors.\n\nParameters:\n* $1 - an unknown error message\n{{Identical|Unknown error}}",
        "api-error-uploaddisabled": "API error message that can be used for client side localisation of API errors.",
        "api-error-verification-error": "The word \"extension\" refers to the part behind the last dot in a file name, that by convention gives a hint about the kind of data format which a files contents are in.",
+       "api-error-was-deleted": "API error message that can be used for client side localisation of API errors.",
        "duration-seconds": "Used as duration. Parameters:\n* $1 - number of seconds\n{{Related|Duration}}\n{{Identical|Second}}",
        "duration-minutes": "Used as duration. Parameters:\n* $1 - number of minutes\n{{Related|Duration}}\n{{Identical|Minute}}",
        "duration-hours": "Used as duration. Parameters:\n* $1 - number of hours\n{{Related|Duration}}",
index b206ba3..5cc5681 100644 (file)
@@ -1255,11 +1255,13 @@ return [
                        'api-error-unknown-error',
                        'api-error-uploaddisabled',
                        'api-error-verification-error',
+                       'api-error-was-deleted',
                        'fileexists',
                        'filepageexists',
                        'filename-bad-prefix',
                        'filename-thumb-name',
                        'badfilename',
+                       'protectedpagetext',
                        'api-error-blacklisted', // HACK
                ],
        ],
index 33b10bd..6af0edf 100644 (file)
                                );
                        }
 
-                       message = mw.message( 'api-error-' + error.code );
-                       if ( !message.exists() ) {
-                               message = mw.message( 'api-error-unknownerror', JSON.stringify( stateDetails ) );
+                       if ( error.code === 'protectedpage' ) {
+                               message = mw.message( 'protectedpagetext' );
+                       } else {
+                               message = mw.message( 'api-error-' + error.code );
+                               if ( !message.exists() ) {
+                                       message = mw.message( 'api-error-unknownerror', JSON.stringify( stateDetails ) );
+                               }
                        }
                        return new OO.ui.Error(
                                $( '<p>' ).append( message.parseDom() ),
                                        $( '<p>' ).msg( 'fileexists', 'File:' + warnings.exists ),
                                        { recoverable: false }
                                );
+                       } else if ( warnings[ 'exists-normalized' ] !== undefined ) {
+                               return new OO.ui.Error(
+                                       $( '<p>' ).msg( 'fileexists', 'File:' + warnings[ 'exists-normalized' ] ),
+                                       { recoverable: false }
+                               );
                        } else if ( warnings[ 'page-exists' ] !== undefined ) {
                                return new OO.ui.Error(
                                        $( '<p>' ).msg( 'filepageexists', 'File:' + warnings[ 'page-exists' ] ),
                                        $( '<p>' ).msg( 'api-error-duplicate-archive', 1 ),
                                        { recoverable: false }
                                );
+                       } else if ( warnings[ 'was-deleted' ] !== undefined ) {
+                               return new OO.ui.Error(
+                                       $( '<p>' ).msg( 'api-error-was-deleted' ),
+                                       { recoverable: false }
+                               );
                        } else if ( warnings.badfilename !== undefined ) {
                                // Change the name if the current name isn't acceptable
                                // TODO This might not really be the best place to do this