Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126214

Change subject: Show error message when server connection failed
......................................................................

Show error message when server connection failed

Change-Id: I9d93c1f451d7fd325bbc9274a7fb39a4dc31374a
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/base/ext.cx.datamanager.js
M modules/header/ext.cx.header.render.js
M modules/header/styles/ext.cx.header.less
6 files changed, 31 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/14/126214/1

diff --git a/Resources.php b/Resources.php
index 84c2de3..5a37e7b 100644
--- a/Resources.php
+++ b/Resources.php
@@ -51,7 +51,8 @@
        ),
        'messages' => array(
                'cx-header-translation-center',
-               'cx-publish-button'
+               'cx-publish-button',
+               'cx-error-server-connection',
        ),
 ) + $resourcePaths;
 
diff --git a/i18n/en.json b/i18n/en.json
index 1a570b7..e7055ba 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -28,5 +28,6 @@
     "cx-tools-instructions-text5": "Publish the translation",
     "cx-tools-instructions-text6": "When you are happy with the result, press 
{{int:cx-publish-button}}.",
     "cx-tools-searchbox-text": "Search for a word",
-    "cx-tools-view-guidelines": "[$1 View translation guidelines]"
+    "cx-tools-view-guidelines": "[$1 View translation guidelines]",
+       "cx-error-server-connection": "Error: Could not connect to the server"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 904d1b1..4809242 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -29,5 +29,6 @@
     "cx-tools-instructions-text5": "Help text for the translation tools pane.",
     "cx-tools-instructions-text6": "Help text for the translation tools 
pane.\n\nRefers to {{msg-mw|Cx-publish-button}}.",
     "cx-tools-searchbox-text": "Placeholder text for the searchbox on the 
translation tools column",
-    "cx-tools-view-guidelines": "Parameters:\n* $1 - the URL pointing to the 
guidelines for translation in Wikipedia"
+    "cx-tools-view-guidelines": "Parameters:\n* $1 - the URL pointing to the 
guidelines for translation in Wikipedia",
+       "cx-error-server-connection": "Error message shown when connection to 
the ontent translation server is failed."
 }
diff --git a/modules/base/ext.cx.datamanager.js 
b/modules/base/ext.cx.datamanager.js
index a404c73..79e815a 100644
--- a/modules/base/ext.cx.datamanager.js
+++ b/modules/base/ext.cx.datamanager.js
@@ -15,8 +15,12 @@
 
        /* global io */
        function initConnection() {
+               if ( !window.io ) {
+                       return false;
+               }
                socket = io.connect( mw.config.get( 
'wgContentTranslationServerURL' ) );
                mw.log( '[CX] Connected to server' );
+               return true;
        }
 
        function updateModel( data ) {
@@ -27,7 +31,13 @@
 
        mw.cx.connect = function () {
                if ( !socket ) {
-                       initConnection();
+                       if ( !initConnection() ) {
+                               // io not defined. Server is unreachable.
+                               $( '.cx-header__infobar' )
+                                       .text( mw.msg( 
'cx-error-server-connection' ) )
+                                       .show();
+                               return;
+                       }
                }
                socket.emit( 'cx.init', {
                        // FIXME
diff --git a/modules/header/ext.cx.header.render.js 
b/modules/header/ext.cx.header.render.js
index 2328bae..16cc732 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, $publishButton,
-                       $translationCenterLink, $translationCenter;
+                       $translationCenterLink, $translationCenter, $infoBar;
 
                $logo = $( '<div>' ).addClass( 'cx-header__logo' );
                $userName = $( '<a>' )
@@ -35,9 +35,12 @@
                $headerBar = $( '<div>' )
                        .addClass( 'cx-header__bar' )
                        .append( $translationCenter, $publishButton );
+               $infoBar = $( '<div>' )
+                       .addClass( 'cx-header__infobar' )
+                       .hide();
                this.$container
                        .addClass( 'cx-header' )
-                       .append( $logo, $userDetails, $headerBar );
+                       .append( $logo, $userDetails, $headerBar, $infoBar );
        };
 
 }( jQuery, mediaWiki ) );
diff --git a/modules/header/styles/ext.cx.header.less 
b/modules/header/styles/ext.cx.header.less
index a909d11..4591efd 100644
--- a/modules/header/styles/ext.cx.header.less
+++ b/modules/header/styles/ext.cx.header.less
@@ -40,6 +40,15 @@
        }
 }
 
+.cx-header__infobar {
+       .mw-ui-item;
+       .mw-ui-one-whole;
+       padding: 10px;
+       color: #f00;
+       border-bottom: 1px solid #ddd;
+       font-size: large;
+}
+
 .cx-header__publish {
        .mw-ui-item;
        .mw-ui-one-eighth;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d93c1f451d7fd325bbc9274a7fb39a4dc31374a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to