[MediaWiki-commits] [Gerrit] mediawiki...WikiEditor[master]: Show invalidreason from API response on invalid title

2017-10-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383500 )

Change subject: Show invalidreason from API response on invalid title
..


Show invalidreason from API response on invalid title

Bug: T99547
Change-Id: I34372e054e509732b008875260ba5c5e0248e551
---
M modules/jquery.wikiEditor.dialogs.config.js
1 file changed, 19 insertions(+), 7 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/modules/jquery.wikiEditor.dialogs.config.js 
b/modules/jquery.wikiEditor.dialogs.config.js
index ccbcead..3539217 100644
--- a/modules/jquery.wikiEditor.dialogs.config.js
+++ b/modules/jquery.wikiEditor.dialogs.config.js
@@ -115,7 +115,7 @@
}
 
// Updates the status indicator 
above the target link
-   function updateWidget( status ) 
{
+   function updateWidget( status, 
reason ) {
$( 
'#wikieditor-toolbar-link-int-target-status' ).children().hide();
$( 
'#wikieditor-toolbar-link-int-target' ).parent()
.removeClass(
@@ -129,6 +129,13 @@
$( 
'.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.prop( 
'disabled', true )

.addClass( 'disabled' );
+   if ( reason ) {
+   $( 
'#wikieditor-toolbar-link-int-target-status-invalid' ).html( reason );
+   } else {
+   $( 
'#wikieditor-toolbar-link-int-target-status-invalid' )
+   .text( 
mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-invalid' ) );
+   }
+
} else {
$( 
'.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.prop( 
'disabled', false )
@@ -142,7 +149,8 @@
// Abort previous 
request
var request = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'request' ),
target = $( 
'#wikieditor-toolbar-link-int-target' ).val(),
-   cache = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'existencecache' );
+   cache = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'existencecache' ),
+   reasoncache = 
$( '#wikieditor-toolbar-link-int-target-status' ).data( 'reasoncache' );
// ensure the internal 
parameter is a boolean
if ( internal !== true 
) {
internal = 
false;
@@ -151,7 +159,7 @@
request.abort();
}
if ( hasOwn.call( 
cache, target ) ) {
-   updateWidget( 
cache[ target ] );
+   updateWidget( 
cache[ target ], reasoncache[ target ] );
return;
}
if ( target.replace( 
/^\s+$/, '' ) === '' ) {
@@ -184,9 +192,11 @@
action: 
'query',
prop: 
'pageprops',
titles: 
target,
-   ppprop: 
'disambiguation'
+   ppprop: 

[MediaWiki-commits] [Gerrit] mediawiki...WikiEditor[master]: Show invalidreason from API response on invalid title

2017-10-10 Thread Fomafix (Code Review)
Fomafix has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383500 )

Change subject: Show invalidreason from API response on invalid title
..

Show invalidreason from API response on invalid title

Bug: T99547
Change-Id: I34372e054e509732b008875260ba5c5e0248e551
---
M modules/jquery.wikiEditor.dialogs.config.js
1 file changed, 19 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiEditor 
refs/changes/00/383500/1

diff --git a/modules/jquery.wikiEditor.dialogs.config.js 
b/modules/jquery.wikiEditor.dialogs.config.js
index ccbcead..ecb529c 100644
--- a/modules/jquery.wikiEditor.dialogs.config.js
+++ b/modules/jquery.wikiEditor.dialogs.config.js
@@ -115,7 +115,7 @@
}
 
// Updates the status indicator 
above the target link
-   function updateWidget( status ) 
{
+   function updateWidget( status, 
reason ) {
$( 
'#wikieditor-toolbar-link-int-target-status' ).children().hide();
$( 
'#wikieditor-toolbar-link-int-target' ).parent()
.removeClass(
@@ -129,6 +129,13 @@
$( 
'.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.prop( 
'disabled', true )

.addClass( 'disabled' );
+   if ( reason ) {
+   $( 
'#wikieditor-toolbar-link-int-target-status-invalid' ).html( reason );
+   } else {
+   $( 
'#wikieditor-toolbar-link-int-target-status-invalid' )
+   .text( 
mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-invalid' ) )
+   }
+
} else {
$( 
'.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.prop( 
'disabled', false )
@@ -142,7 +149,8 @@
// Abort previous 
request
var request = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'request' ),
target = $( 
'#wikieditor-toolbar-link-int-target' ).val(),
-   cache = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'existencecache' );
+   cache = $( 
'#wikieditor-toolbar-link-int-target-status' ).data( 'existencecache' ),
+   reasoncache = 
$( '#wikieditor-toolbar-link-int-target-status' ).data( 'reasoncache' );
// ensure the internal 
parameter is a boolean
if ( internal !== true 
) {
internal = 
false;
@@ -151,7 +159,7 @@
request.abort();
}
if ( hasOwn.call( 
cache, target ) ) {
-   updateWidget( 
cache[ target ] );
+   updateWidget( 
cache[ target ], reasoncache[ target ] );
return;
}
if ( target.replace( 
/^\s+$/, '' ) === '' ) {
@@ -184,9 +192,11 @@
action: 
'query',
prop: 
'pageprops',
titles: 
target,
-   ppprop: 
'disambiguation'
+   ppprop: