Kaynağa Gözat

[editor] Unify show history logic to only be shown on a new query

As it it preferable to show the previous results of a past query.
Romain Rigaux 10 yıl önce
ebeveyn
işleme
671c7bca04

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

@@ -920,6 +920,9 @@
       $.each(notebook.snippets, function (index, snippet) {
         self.addSnippet(snippet);
       });
+      if (vm.editorMode && ! notebook.snippets.length) {
+        self.showHistory(true); // Show history when new query
+      }      
     }
 
     self.save = function () {

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

@@ -858,7 +858,7 @@ ${ require.config() }
 <script type ="text/html" id="snippet-execution-controls">
   <!-- ko if: $root.editorMode -->
   <div class="snippet-actions" style="position: absolute; bottom: 26px">
-    <a class="snippet-side-btn" data-bind="visible: $parent.history().length > 0, click: function() { $parent.showHistory(! $parent.showHistory()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': $parent.showHistory}" title="${ _('Show history') }">
+    <a class="snippet-side-btn" data-bind="visible: $root.editorMode, click: function() { $parent.showHistory(! $parent.showHistory()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': $parent.showHistory}" title="${ _('Show history') }">
       <i class="fa fa-fw fa-history"></i>
     </a>
   </div>
@@ -1919,10 +1919,6 @@ ${ require.config() }
       ko.applyBindings(viewModel);
       viewModel.init();
 
-      if (viewModel.editorMode && !viewModel.selectedNotebook().snippets()[0].result.hasSomeResults()) {
-        viewModel.selectedNotebook().fetchHistory();
-      }
-
       if (location.getParameter("github_status") != "") {
         if (location.getParameter("github_status") == "0") {
           $.jHueNotify.info("${ _('User successfully authenticated to GitHub.') }");