Эх сурвалжийг харах

HUE-3743 [editor] Support &new=true to have a blank query

Romain Rigaux 9 жил өмнө
parent
commit
17d5181

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

@@ -1649,8 +1649,12 @@
         directory_uuid: window.location.getParameter('directory_uuid')
       }, function (data) {
         self.loadNotebook(data.notebook);
-        self.selectedNotebook().newSnippet();
         if (self.editorMode) {
+          self.selectedNotebook().newSnippet();
+          if (window.location.getParameter('new') == '') {
+            self.selectedNotebook().snippets()[0].statement_raw($.totalStorage('hue.notebook.lastWrittenSnippet.' + self.user + '.' + window.location.getParameter('type')));
+            $.totalStorage('hue.notebook.lastWrittenSnippet.' + self.user +  '.' + window.location.getParameter('type'), '');
+          }
           hueUtils.changeURL('/notebook/editor');
         } else {
           hueUtils.changeURL('/notebook/notebook');

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

@@ -2844,11 +2844,6 @@ ${ hueIcons.symbols() }
       ko.applyBindings(viewModel);
       viewModel.init();
 
-      if (viewModel.editorMode && window.location.getParameter('type') != '' && window.location.getParameter('new') == '') {
-        viewModel.selectedNotebook().snippets()[0].statement_raw($.totalStorage('hue.notebook.lastWrittenSnippet.${user}.' + window.location.getParameter('type')));
-        $.totalStorage('hue.notebook.lastWrittenSnippet.${user}.' + window.location.getParameter('type'), '');
-      }
-
       if (location.getParameter("github_status") != "") {
         if (location.getParameter("github_status") == "0") {
           $.jHueNotify.info("${ _('User successfully authenticated to GitHub.') }");