瀏覽代碼

HUE-6174 [editor] Show the correct editor type in the new button tooltip

Johan Ahlen 8 年之前
父節點
當前提交
5039b12

+ 6 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -2406,7 +2406,12 @@ var EditorViewModel = (function() {
         self.selectedNotebook().fetchHistory(); // Js error if notebook did not have snippets
       }
     });
-    self.editorTypeTitle = ko.observable(options.editor_type);
+    self.editorTypeTitle = ko.pureComputed(function () {
+      var foundInterpreter = $.grep(options.languages, function (interpreter) {
+        return interpreter.type === self.editorType();
+      })
+      return foundInterpreter.length > 0 ? foundInterpreter[0].name : self.editorType();
+    });
     self.useNewAutocompleter = options.useNewAutocompleter || false;
     self.autocompleteTimeout = options.autocompleteTimeout;
     self.selectedNotebook = ko.observable();

+ 2 - 2
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -256,7 +256,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
         <!-- /ko -->
 
         <!-- ko if: editorMode -->
-        <a class="btn" href="javascript:void(0)" data-bind="click: function() { newNotebook(true); }, attr: { 'title': '${ _('New ') }' +  editorTypeTitle() + '${ _('Query') }' }" rel="tooltip" data-placement="bottom">
+        <a class="btn" href="javascript:void(0)" data-bind="click: function() { newNotebook($root.editorType()); }, attr: { 'title': '${ _('New ') }' +  editorTypeTitle() + '${ _(' Query') }' }" rel="tooltip" data-placement="bottom">
           <i class="fa fa-file-o"></i>
         </a>
         <!-- /ko -->
@@ -3196,7 +3196,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
           viewModel.selectedNotebook().newSnippet();
         }
         else {
-          viewModel.newNotebook(true);
+          viewModel.newNotebook(viewModel.editorType());
         }
       }