Browse Source

HUE-4855 [notebook] Offer batch submission only when all the snippets support it

Romain Rigaux 9 years ago
parent
commit
256e573

+ 5 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1368,6 +1368,11 @@
 
 
     self.schedulerViewModel = null;
     self.schedulerViewModel = null;
     self.schedulerViewerViewModel = ko.observable();
     self.schedulerViewerViewModel = ko.observable();
+    self.isBatchable = ko.computed(function() {
+      return $.grep(self.snippets(), function (snippet) {
+        return snippet.type() == 'hive' || snippet.interface() == 'oozie';
+      }).length == self.snippets().length;
+    });
 
 
     self.retryModalConfirm = null;
     self.retryModalConfirm = null;
     self.retryModalCancel = null;
     self.retryModalCancel = null;

+ 5 - 5
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1970,18 +1970,18 @@ ${ hueIcons.symbols() }
     </a>
     </a>
 
 
     <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': statement() === '' || status() === 'running' || status() === 'loading' }">
     <div class="inactive-action dropdown hover-actions pointer" data-bind="css: {'disabled': statement() === '' || status() === 'running' || status() === 'loading' }">
-      <!-- ko if: type() == 'hive' && wasBatchExecuted() -->
+      <!-- ko if: $parent.isBatchable() && wasBatchExecuted() -->
       <a class="snippet-side-btn" style="padding-right:0; padding-left: 2px" href="javascript: void(0)" title="${ _('Submit all the queries as a background batch job.') }" data-bind="click: function() { wasBatchExecuted(true); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': statement() === '' }">
       <a class="snippet-side-btn" style="padding-right:0; padding-left: 2px" href="javascript: void(0)" title="${ _('Submit all the queries as a background batch job.') }" data-bind="click: function() { wasBatchExecuted(true); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': statement() === '' }">
         <i class="fa fa-fw fa-send"></i>
         <i class="fa fa-fw fa-send"></i>
       </a>
       </a>
       <!-- /ko -->
       <!-- /ko -->
-      <!-- ko if: type() != 'hive' || ! wasBatchExecuted() -->
-      <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="attr: {'title': $root.editorMode() && result.statements_count() > 1 ? '${ _ko('Execute next statement')}' : '${ _ko('Execute or CTRL + ENTER') }'}, click: function() { wasBatchExecuted(false); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }, style: {'padding-left': type() == 'hive' ? '2px' : '0' }">
-        <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : type() !== 'hive' }"></i>
+      <!-- ko if: ! $parent.isBatchable() || ! wasBatchExecuted() -->
+      <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="attr: {'title': $root.editorMode() && result.statements_count() > 1 ? '${ _ko('Execute next statement')}' : '${ _ko('Execute or CTRL + ENTER') }'}, click: function() { wasBatchExecuted(false); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }, style: {'padding-left': $parent.isBatchable() ? '2px' : '0' }">
+        <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : ! $parent.isBatchable() }"></i>
       </a>
       </a>
       <!-- /ko -->
       <!-- /ko -->
       % if ENABLE_BATCH_EXECUTE.get():
       % if ENABLE_BATCH_EXECUTE.get():
-      <!-- ko if: type() == 'hive' && status() != 'running' && status() != 'loading' -->
+      <!-- ko if: $parent.isBatchable() && status() != 'running' && status() != 'loading' -->
         <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'disabled': statement() === '', 'blue': currentQueryTab() == 'queryExplain' }">
         <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'disabled': statement() === '', 'blue': currentQueryTab() == 'queryExplain' }">
           <i class="fa fa-caret-down"></i>
           <i class="fa fa-caret-down"></i>
         </a>
         </a>