Sfoglia il codice sorgente

HUE-9066 [editor] Avoid adding extra snippet when new editor already has one

Romain 6 anni fa
parent
commit
b243231a41

+ 4 - 1
desktop/core/src/desktop/js/apps/notebook/editorViewModel.js

@@ -599,7 +599,10 @@ class EditorViewModel {
         data => {
           self.loadNotebook(data.notebook);
           if (self.editorMode() && !self.isNotificationManager()) {
-            const snippet = self.selectedNotebook().newSnippet(self.editorType());
+            const snippet =
+              self.selectedNotebook().snippets().length == 0
+                ? self.selectedNotebook().newSnippet(self.editorType())
+                : self.selectedNotebook().snippets()[0];
             if (
               queryTab &&
               ['queryHistory', 'savedQueries', 'queryBuilderTab'].indexOf(queryTab) > -1

+ 4 - 1
desktop/core/src/desktop/js/apps/notebook2/editorViewModel.js

@@ -370,7 +370,10 @@ class EditorViewModel {
         .then(data => {
           this.loadNotebook(data.notebook);
           if (this.editorMode() && !this.isNotificationManager()) {
-            const snippet = this.selectedNotebook().newSnippet(this.editorType());
+            const snippet =
+              this.selectedNotebook().snippets().length == 0
+                ? this.selectedNotebook().newSnippet(this.editorType())
+                : this.selectedNotebook().snippets()[0];
             if (
               queryTab &&
               ['queryHistory', 'savedQueries', 'queryBuilderTab'].indexOf(queryTab) > -1