Amire80 has uploaded a new change for review.

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


Change subject: Show the history menu item only if it exists
......................................................................

Show the history menu item only if it exists

If the message doesn't have a translation, the history link
leads to an empty page. Now it's hidden for untranslated message
and shown for translated messages.

Change-Id: I35cd21fa7d80d3ff75d1e651178ca08cfa91c9d9
---
M resources/js/ext.translate.editor.js
1 file changed, 28 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/35/59035/1

diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index c21f091..39bbfca 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -150,6 +150,11 @@
                        // immediately move to the next message.
                        translateEditor.next();
 
+                       // Now the message definitely has a history,
+                       // so make sure the history menu item is shown
+                       translateEditor.$editor.find( '.message-tools-history' )
+                               .removeClass( 'hide' );
+
                        api.postWithEditToken( {
                                action: 'edit',
                                title: translateEditor.message.title,
@@ -250,7 +255,8 @@
                },
 
                createMessageTools: function () {
-                       var wgScript = mw.config.get( 'wgScript' ),
+                       var $historyItem, $translationsItem,
+                               wgScript = mw.config.get( 'wgScript' ),
                                historyUri = new mw.Uri(),
                                translationsUri = new mw.Uri();
 
@@ -259,31 +265,36 @@
                                title: this.message.title,
                                action: 'history'
                        };
+                       $historyItem = $( '<li>' )
+                               .addClass( 'message-tools-history' +
+                                       ( ( this.message.translation === null ) 
? ' hide' : '' )
+                               )
+                               .append( $( '<a>' )
+                               .attr( {
+                                       href: historyUri.toString(),
+                                       target: '_blank'
+                               } )
+                               .text( mw.msg( 
'tux-editor-message-tools-history' ) )
+                       );
 
                        translationsUri.path = wgScript;
                        translationsUri.query = {
                                title: 'Special:Translations',
                                message: this.message.title.replace( 
/\/[a-z\-]+$/, '' )
                        };
+                       $translationsItem = $( '<li>' )
+                               .addClass( 'message-tools-translations' )
+                               .append( $( '<a>' )
+                               .attr( {
+                                       href: translationsUri.toString(),
+                                       target: '_blank'
+                               } )
+                               .text( mw.msg( 
'tux-editor-message-tools-translations' ) )
+                       );
 
                        return $( '<ul>' )
                                .addClass( 'dropdown-menu 
tux-message-tools-menu hide' )
-                               .append(
-                                       $( '<li>' ).append( $( '<a>' )
-                                               .attr( {
-                                                       href: 
historyUri.toString(),
-                                                       target: '_blank'
-                                               } )
-                                               .text( mw.msg( 
'tux-editor-message-tools-history' ) )
-                                       ),
-                                       $( '<li>' ).append( $( '<a>' )
-                                               .attr( {
-                                                       href: 
translationsUri.toString(),
-                                                       target: '_blank'
-                                               } )
-                                               .text( mw.msg( 
'tux-editor-message-tools-translations' ) )
-                                       )
-                               );
+                               .append( $historyItem, $translationsItem );
                },
 
                prepareEditorColumn: function () {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35cd21fa7d80d3ff75d1e651178ca08cfa91c9d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>

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

Reply via email to