소스 검색

HUE-9456 [editor] Fix presentation mode variable substitution in editor v2

Johan Ahlen 5 년 전
부모
커밋
79fabac564

+ 5 - 4
desktop/core/src/desktop/js/apps/notebook2/notebook.js

@@ -438,7 +438,6 @@ export default class Notebook {
     if (isPresentationMode) {
       const sourceSnippet = this.snippets()[0];
       this.prePresentationModeSnippet = sourceSnippet;
-      const variables = sourceSnippet.variables();
       const statementKeys = {};
 
       const database = sourceSnippet.database();
@@ -466,9 +465,12 @@ export default class Notebook {
             connector: sourceSnippet.connector(),
             statement_raw: statementLines.join('\n'),
             database: database,
-            name: titleLines.join('\n'),
-            variables: komapping.toJS(variables)
+            name: titleLines.join('\n')
           });
+          presentationSnippet.variableSubstitutionHandler =
+            sourceSnippet.variableSubstitutionHandler;
+          presentationSnippet.executor.variableSubstitionHandler =
+            sourceSnippet.variableSubstitutionHandler;
           window.setTimeout(() => {
             const executableRaw = executable.toJs();
             const reattachedExecutable = SqlExecutable.fromJs(
@@ -484,7 +486,6 @@ export default class Notebook {
         } else {
           presentationSnippet = this.presentationSnippets()[statementKey];
         }
-        presentationSnippet.variables(variables);
         statementKeys[statementKey] = true;
         newSnippets.push(presentationSnippet);
       });

+ 1 - 3
desktop/core/src/desktop/js/apps/notebook2/variableSubstitution.ts

@@ -135,9 +135,7 @@ export class VariableSubstitutionHandler {
       this.variables(rawVariables.map(rawVariable => new Variable(rawVariable)));
     }
 
-    this.variableNames = ko.pureComputed(() => {
-      return this.extractVariables(this.statementRaw());
-    });
+    this.variableNames = ko.pureComputed(() => this.extractVariables(this.statementRaw()));
 
     this.variableNames.extend({ rateLimit: 150 });
 

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

@@ -331,8 +331,8 @@
 
     <div class="margin-left-30 margin-top-10 padding-left-5 margin-bottom-20">
       <!-- ko template: { name: 'notebook-actions' } --><!-- /ko -->
-      <!-- ko if: $root.preEditorTogglingSnippet -->
-      <!-- ko template: { if: $root.isPresentationMode(), name: 'snippet-variables', data: $root.preEditorTogglingSnippet }--><!-- /ko -->
+      <!-- ko if: selectedNotebook().prePresentationModeSnippet -->
+      <!-- ko template: { if: $root.isPresentationMode(), name: 'snippet-variables', data: selectedNotebook().prePresentationModeSnippet }--><!-- /ko -->
       <!-- /ko -->
     </div>