Sfoglia il codice sorgente

HUE-9028 [editor] Disable the execute button when the editor is empty

Johan Ahlen 6 anni fa
parent
commit
2d68f7db06

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

@@ -30,7 +30,7 @@ const TEMPLATE = `
 <div class="snippet-execute-actions" data-test="${ NAME }">
   <div class="btn-group">
     <!-- ko if: status() !== '${ EXECUTION_STATUS.running }' && !waiting() -->
-    <button class="btn btn-primary btn-mini btn-execute disable-feedback" data-test="execute" data-bind="click: execute"><i class="fa fa-play fa-fw"></i> ${I18n(
+    <button class="btn btn-primary btn-mini btn-execute disable-feedback" data-test="execute" data-bind="click: execute, disable: disabled"><i class="fa fa-play fa-fw"></i> ${I18n(
       'Execute'
     )}</button>
     <!-- /ko -->
@@ -53,6 +53,8 @@ const TEMPLATE = `
 </div>
 `;
 
+const WHITE_SPACE_REGEX = /^\s*$/;
+
 class ExecutableActions extends DisposableComponent {
   constructor(params) {
     super();
@@ -69,6 +71,15 @@ class ExecutableActions extends DisposableComponent {
         this.partOfRunningExecution()
     );
 
+    this.disabled = ko.pureComputed(() => {
+      const executable = this.activeExecutable();
+
+      return (
+        !executable ||
+        (executable.parsedStatement && WHITE_SPACE_REGEX.test(executable.parsedStatement.statement))
+      );
+    });
+
     this.subscribe(EXECUTABLE_UPDATED_EVENT, executable => {
       if (this.activeExecutable() === executable) {
         this.updateFromExecutable(executable);

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 4 - 1
desktop/core/src/desktop/static/desktop/less/components/hue-snippet-execute-actions.less

@@ -26,7 +26,10 @@
   .btn-group {
     .btn {
       font-size: 11px;
-      border-bottom-color: @hue-primary-color-dark;
+
+      &:not([disabled]) {
+        border-bottom-color: @hue-primary-color-dark;
+      }
     }
 
     .btn-execute {

Some files were not shown because too many files changed in this diff