mw.Upload.BookletLayout: Handle additional warnings/errors

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
This commit is contained in:
Bartosz Dziewoński 2016-04-05 22:25:46 +02:00
parent 51d5d5deaf
commit f3b2f2023a
4 changed files with 21 additions and 3 deletions

View file

@ -3900,6 +3900,7 @@
"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}}",

View file

@ -4076,6 +4076,7 @@
"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}}",

View 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
],
],

View file

@ -322,9 +322,13 @@
);
}
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() ),
@ -346,6 +350,11 @@
$( '<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' ] ),
@ -371,6 +380,11 @@
$( '<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