jenkins-bot has submitted this change and it was merged.

Change subject: Error message indicator of server error or page not found
......................................................................


Error message indicator of server error or page not found

Change-Id: I4d6ec4485549dccf593f4324e6641afba9818e3b
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/header/ext.cx.header.js
M modules/header/ext.cx.header.render.js
A modules/header/images/clear.png
A modules/header/images/clear.svg
M modules/header/styles/ext.cx.header.less
M modules/source/ext.cx.source.js
9 files changed, 51 insertions(+), 10 deletions(-)

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



diff --git a/Resources.php b/Resources.php
index e94ce18..887b04a 100644
--- a/Resources.php
+++ b/Resources.php
@@ -50,6 +50,7 @@
        ),
        'messages' => array(
                'cx-error-server-connection',
+               'cx-error-page-not-found',
                'cx-header-translation-center',
                'cx-publish-button',
        ),
diff --git a/i18n/en.json b/i18n/en.json
index 67a8408..f7187d3 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -52,5 +52,6 @@
        "cx-tools-reference-remove": "Remove reference",
        "cx-tools-link-instruction-shortcut": "Shift + click any link to open",
        "cx-tools-link-hover-tooltip": "Click to open",
-       "cx-warning-unsaved-translation": "You have unsaved translation."
+       "cx-warning-unsaved-translation": "You have unsaved translation.",
+       "cx-error-page-not-found": "The \"$1\" page could not be found in $2 
Wikipedia"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index de86fe6..c6c09c1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -55,5 +55,6 @@
        "cx-tools-reference-remove": "Text shown in the reference tool card. 
Clicking on it removes the reference in the context.",
        "cx-tools-link-instruction-shortcut": "Text explaining the shortcut for 
opening a link. Appears in the link tool card.",
        "cx-tools-link-hover-tooltip": "Tooltip text shown when the mouse is 
over the link with shift or control key is pressed.",
-       "cx-warning-unsaved-translation": "Warning message shown when user 
tried to navigate away when translation is not saved."
+       "cx-warning-unsaved-translation": "Warning message shown when user 
tried to navigate away when translation is not saved.",
+       "cx-error-page-not-found": "Error message shown when a page is not 
found in a given language wikipedia\n\nParameters:\n* $1 - the title of the 
page.\n* $2 - The language name"
 }
diff --git a/modules/header/ext.cx.header.js b/modules/header/ext.cx.header.js
index 666c480..96fa7da 100644
--- a/modules/header/ext.cx.header.js
+++ b/modules/header/ext.cx.header.js
@@ -36,11 +36,27 @@
                this.$publishButton.prop( 'disabled', parseInt( progress, 10 ) 
=== 0 );
        };
 
+       /**
+        * Show error message
+        * @param {string} message
+        */
+       ContentTranslationHeader.prototype.showError = function ( message ) {
+               this.$infoBar
+                       .show()
+                       .find( '.text' )
+                       .text( message );
+       };
+
        ContentTranslationHeader.prototype.listen = function () {
                this.$container.find( '.publish' ).on( 'click', function () {
                        mw.hook( 'mw.cx.publish' ).fire();
                } );
+               // Click hander for remove icon in info bar.
+               this.$infoBar.find( '.remove' ).click( function () {
+                       $( this ).parent().hide();
+               } );
                mw.hook( 'mw.cx.progress' ).add( $.proxy( 
this.setPublishButtonState, this ) );
+               mw.hook( 'mw.cx.error' ).add( $.proxy( this.showError, this ) );
        };
 
        $.fn.cxHeader = function ( options ) {
diff --git a/modules/header/ext.cx.header.render.js 
b/modules/header/ext.cx.header.render.js
index fdab480..e4c2368 100644
--- a/modules/header/ext.cx.header.render.js
+++ b/modules/header/ext.cx.header.render.js
@@ -13,7 +13,7 @@
 
        mw.cx.ContentTranslationHeader.prototype.render = function () {
                var $logo, $userName, $userDetails, $headerBar,
-                       $translationCenterLink, $translationCenter, $infoBar;
+                       $translationCenterLink, $translationCenter;
 
                $logo = $( '<div>' ).addClass( 'cx-header__logo' );
 
@@ -43,12 +43,14 @@
                        .addClass( 'cx-header__bar' )
                        .append( $translationCenter, this.$publishButton );
 
-               $infoBar = $( '<div>' )
+               this.$infoBar = $( '<div>' )
                        .addClass( 'cx-header__infobar' )
+                       .append( $( '<span>' ).addClass( 'text' ) )
+                       .append( $( '<span>' ).addClass( 'remove' ) )
                        .hide();
 
                this.$container
                        .addClass( 'cx-header' )
-                       .append( $logo, $userDetails, $headerBar, $infoBar );
+                       .append( $logo, $userDetails, $headerBar, this.$infoBar 
);
        };
 }( jQuery, mediaWiki ) );
diff --git a/modules/header/images/clear.png b/modules/header/images/clear.png
new file mode 100644
index 0000000..f900e7d
--- /dev/null
+++ b/modules/header/images/clear.png
Binary files differ
diff --git a/modules/header/images/clear.svg b/modules/header/images/clear.svg
new file mode 100755
index 0000000..8cb15e3
--- /dev/null
+++ b/modules/header/images/clear.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg"; 
width="12.52" height="12.52"><path fill="#555" d="M0 1.194l1.194-1.194 11.326 
11.326-1.194 1.194zM11.326 0l1.194 1.194-11.326 11.326-1.194-1.194z"/></svg>
\ No newline at end of file
diff --git a/modules/header/styles/ext.cx.header.less 
b/modules/header/styles/ext.cx.header.less
index 4591efd..6caba3c 100644
--- a/modules/header/styles/ext.cx.header.less
+++ b/modules/header/styles/ext.cx.header.less
@@ -44,9 +44,24 @@
        .mw-ui-item;
        .mw-ui-one-whole;
        padding: 10px;
-       color: #f00;
+       background-color: #F7D358;
        border-bottom: 1px solid #ddd;
        font-size: large;
+       .remove {
+               @vertical-margin: 10px;
+               @horizontal-margin: 15px;
+               float: right;
+               padding: @vertical-margin @horizontal-margin;
+               /* @embed */
+               background: url(../images/clear.png) no-repeat scroll 10px 
center;
+               /* @embed */
+               background-image: -webkit-linear-gradient(transparent, 
transparent), url(../images/clear.svg);
+               /* @embed */
+               background-image: linear-gradient(transparent, transparent), 
url(../images/clear.svg);
+               background-size: 15px;
+               cursor: pointer;
+               clear: both;
+       }
 }
 
 .cx-header__publish {
diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index a6998dc..cef799b 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -23,10 +23,14 @@
                        .done( function ( response ) {
                                mw.cx.data = response;
                                mw.hook( 'mw.cx.source.loaded' ).fire();
-                       } ).fail( function () {
-                               $( '.cx-header__infobar' )
-                                       .text( mw.msg( 
'cx-error-server-connection' ) )
-                                       .show();
+                       } ).fail( function ( xhr ) {
+                               if ( xhr.status === 404 ) {
+                                       mw.hook( 'mw.cx.error' ).fire(
+                                               mw.msg( 
'cx-error-page-not-found', title, $.uls.data.getAutonym( language ) )
+                                       );
+                               } else {
+                                       mw.hook( 'mw.cx.error' ).fire( mw.msg( 
'cx-error-server-connection' ) );
+                               }
                        } );
        };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/146016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4d6ec4485549dccf593f4324e6641afba9818e3b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to