Quellcode durchsuchen

HUE-7718 [editor] Enable presentation mode just for SQL editors

Enrico Berti vor 8 Jahren
Ursprung
Commit
05d9aba

+ 3 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -2826,6 +2826,9 @@ var EditorViewModel = (function() {
 
     self.combinedContent = ko.observable();
     self.isPresentationMode = ko.observable(false);
+    self.isPresentationModeEnabled = ko.pureComputed(function () {
+      return self.selectedNotebook() && self.selectedNotebook().snippets().length === 1 && self.selectedNotebook().snippets()[0].isSqlDialect()
+    });
     self.isResultFullScreenMode = ko.observable(false);
     self.isHidingCode = ko.observable(false);
     self.successUrl = ko.observable(options.success_url); // Deprecated

+ 4 - 5
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -163,17 +163,16 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
   <div class="navbar-inner">
     <div class="container-fluid">
       <div class="pull-right margin-right-10">
-
+      % if ENABLE_PRESENTATION.get():
+        <!-- ko if: $root.isPresentationModeEnabled -->
         <div class="btn-group">
-
-          % if ENABLE_PRESENTATION.get():
           <a class="btn" title="${ _ko('View as a presentation') }" data-bind="click: function() { $root.isPresentationMode(true); },
             css: {'btn-inverse': $root.isPresentationMode(), 'btn': true}">
             <i class="fa fa-line-chart"></i>
           </a>
-          % endif
-
         </div>
+        <!-- /ko -->
+      % endif
 
         <div class="btn-group">
           <a class="btn" rel="tooltip" data-placement="bottom" data-loading-text="${ _("Saving...") }" data-bind="click: function() { if ($root.canSave() ) { saveNotebook() } else { $('#saveAsModal${ suffix }').modal('show');} }, attr: { title: $root.canSave() ? '${ _ko('Save') }' : '${ _ko('Save As') }' }"><i class="fa fa-save"></i></a>