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

HUE-9456 [editor] Send the actual snippet and notebook for executables in the editor

This will save the actual snippet state in the history and not just the executable data.
Johan Ahlen 5 жил өмнө
parent
commit
85c6f5f386

+ 8 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/executable.ts

@@ -428,6 +428,14 @@ export default abstract class Executable {
 
 
   async toContext(id?: string): Promise<ExecutableContext> {
   async toContext(id?: string): Promise<ExecutableContext> {
     const session = await sessionManager.getSession({ type: this.executor.connector().id });
     const session = await sessionManager.getSession({ type: this.executor.connector().id });
+    if (this.executor.snippet) {
+      return {
+        operationId: this.operationId,
+        snippet: this.executor.snippet.toContextJson(),
+        notebook: JSON.stringify(await this.executor.snippet.parentNotebook.toJs())
+      };
+    }
+
     const snippet = {
     const snippet = {
       type: this.executor.connector().id,
       type: this.executor.connector().id,
       result: {
       result: {

+ 4 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/executor.ts

@@ -14,6 +14,7 @@
 // See the License for the specific language governing permissions and
 // See the License for the specific language governing permissions and
 // limitations under the License.
 // limitations under the License.
 
 
+import Snippet from 'apps/notebook2/snippet';
 import Executable, { ExecutableRaw } from 'apps/notebook2/execution/executable';
 import Executable, { ExecutableRaw } from 'apps/notebook2/execution/executable';
 import { syncSqlExecutables } from 'apps/notebook2/execution/utils';
 import { syncSqlExecutables } from 'apps/notebook2/execution/utils';
 import { VariableSubstitutionHandler } from 'apps/notebook2/variableSubstitution';
 import { VariableSubstitutionHandler } from 'apps/notebook2/variableSubstitution';
@@ -34,6 +35,7 @@ export default class Executor {
   isOptimizerEnabled?: boolean;
   isOptimizerEnabled?: boolean;
   executables: Executable[] = [];
   executables: Executable[] = [];
   variableSubstitionHandler?: VariableSubstitutionHandler;
   variableSubstitionHandler?: VariableSubstitutionHandler;
+  snippet?: Snippet;
 
 
   constructor(options: {
   constructor(options: {
     connector: () => Connector;
     connector: () => Connector;
@@ -42,6 +44,7 @@ export default class Executor {
     database: () => string;
     database: () => string;
     defaultLimit?: () => number;
     defaultLimit?: () => number;
     isSqlEngine?: boolean;
     isSqlEngine?: boolean;
+    snippet?: Snippet;
     isOptimizerEnabled?: boolean;
     isOptimizerEnabled?: boolean;
     executables: Executable[];
     executables: Executable[];
     variableSubstitionHandler?: VariableSubstitutionHandler;
     variableSubstitionHandler?: VariableSubstitutionHandler;
@@ -54,6 +57,7 @@ export default class Executor {
     this.isOptimizerEnabled = options.isOptimizerEnabled;
     this.isOptimizerEnabled = options.isOptimizerEnabled;
     this.executables = [];
     this.executables = [];
     this.defaultLimit = options.defaultLimit;
     this.defaultLimit = options.defaultLimit;
+    this.snippet = options.snippet;
     this.variableSubstitionHandler = options.variableSubstitionHandler;
     this.variableSubstitionHandler = options.variableSubstitionHandler;
   }
   }
 
 

+ 1 - 0
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -1135,6 +1135,7 @@ export default class Snippet {
       id: this.id(),
       id: this.id(),
       type: this.dialect(),
       type: this.dialect(),
       connector: this.connector(),
       connector: this.connector(),
+      defaultLimit: this.defaultLimit(),
       status: this.status(),
       status: this.status(),
       statementType: this.statementType(),
       statementType: this.statementType(),
       statement: this.statement(),
       statement: this.statement(),