Răsfoiți Sursa

HUE-9143 [editor] Enable ctrl-enter execution in the quick query context

Johan Ahlen 5 ani în urmă
părinte
comite
13fae08a1b

+ 3 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.executableActions.js

@@ -17,9 +17,10 @@
 import * as ko from 'knockout';
 
 import componentUtils from 'ko/components/componentUtils';
+import DisposableComponent from 'ko/components/DisposableComponent';
+import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 import { EXECUTABLE_UPDATED_EVENT, EXECUTION_STATUS } from 'apps/notebook2/execution/executable';
-import DisposableComponent from 'ko/components/DisposableComponent';
 
 export const NAME = 'executable-actions';
 
@@ -126,6 +127,7 @@ class ExecutableActions extends DisposableComponent {
   }
 
   async execute() {
+    huePubSub.publish('hue.ace.autocompleter.hide');
     if (this.beforeExecute) {
       await this.beforeExecute();
     }

+ 2 - 1
desktop/core/src/desktop/js/ko/components/contextPopover/ko.quickQueryContext.js

@@ -81,7 +81,8 @@ const TEMPLATE = `
               availableDatabases: $parent.availableDatabases,
               namespace: $parent.namespace,
               compute: $parent.compute,
-              executor: $parent.executor
+              executor: $parent.executor,
+              activeExecutable: $parent.activeExecutable
             }
           }
         "></div>

+ 16 - 0
desktop/core/src/desktop/js/ko/components/simpleAceEditor/ko.simpleAceEditor.js

@@ -20,6 +20,7 @@ import * as ko from 'knockout';
 import AceLocationHandler from 'ko/bindings/ace/aceLocationHandler';
 import componentUtils from 'ko/components/componentUtils';
 import hueUtils from 'utils/hueUtils';
+import huePubSub from 'utils/huePubSub';
 import SolrFormulaAutocompleter from './solrFormulaAutocompleter';
 import SolrQueryAutocompleter from './solrQueryAutocompleter';
 import SqlAutocompleter from 'sql/sqlAutocompleter';
@@ -82,6 +83,21 @@ class SimpleAceEditor {
     editor.setTheme($.totalStorage('hue.ace.theme') || 'ace/theme/hue');
     self.ace(editor);
 
+    if (params.activeExecutable) {
+      editor.commands.addCommand({
+        name: 'execute',
+        bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter|Ctrl-Enter' },
+        exec: async () => {
+          huePubSub.publish('hue.ace.autocompleter.hide');
+          const executable = params.activeExecutable();
+          if (executable) {
+            await executable.reset();
+            executable.execute();
+          }
+        }
+      });
+    }
+
     if (params.autocomplete && ko.unwrap(params.autocomplete)) {
       const autocomplete = ko.unwrap(params.autocomplete);
       const sourceType =