Browse Source

HUE-8447 [editor] Fix DB selection for snippets in notebook mode

Johan Ahlen 7 years ago
parent
commit
6f228eef8b
1 changed files with 31 additions and 29 deletions
  1. 31 29
      desktop/libs/notebook/src/notebook/templates/editor_components.mako

+ 31 - 29
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -926,6 +926,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
     <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
     <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
     <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
     <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
 
 
+    <!-- ko template: { name: 'snippet-header-database-selection' } --><!-- /ko -->
     <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
     <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
 
 
     <a class="inactive-action move-widget" href="javascript:void(0)"><i class="fa fa-arrows"></i></a>
     <a class="inactive-action move-widget" href="javascript:void(0)"><i class="fa fa-arrows"></i></a>
@@ -941,35 +942,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
     <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
     <!-- ko template: { name: 'longer-operation${ suffix }' } --><!-- /ko -->
     <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
     <span class="execution-timer" data-bind="visible: type() != 'text' && status() != 'ready' && status() != 'loading', text: result.executionTime().toHHMMSS()" title="${ _('Execution time') }"></span>
 
 
-    <!-- ko if: loadingContext() && isSqlDialect()  -->
-    <i class="fa fa-spinner fa-spin muted"></i>
-    <!-- /ko -->
-
-    <!-- ko if: !loadingContext() && isSqlDialect() -->
-    <!-- ko if: availableComputes().length > 1 || namespaceRefreshEnabled() -->
-    <!-- ko if: availableComputes().length > 0-->
-    <span class="editor-header-title">${ _('Compute') }</span>
-    <div data-bind="component: { name: 'hue-drop-down', params: { value: compute, entries: availableComputes, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active compute') }' } }" style="display: inline-block"></div>
-    <!-- /ko -->
-    <!-- ko if: availableComputes().length === 0-->
-    <span class="editor-header-title"><i class="fa fa-warning"></i> ${ _('No computes found') }</span>
-    <!-- /ko -->
-    <!-- /ko -->
-
-    <!-- ko if: (availableNamespaces().length > 1 || namespaceRefreshEnabled()) -->
-    <span class="editor-header-title">${ _('Namespace') }</span>
-    <div data-bind="component: { name: 'hue-drop-down', params: { value: namespace, entries: availableNamespaces, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active namespace') }' } }" style="display: inline-block"></div>
-    <!-- /ko -->
-
-    <!-- ko if: availableDatabases().length > 0 -->
-    <span class="editor-header-title">${ _('Database') }</span>
-    <div data-bind="component: { name: 'hue-drop-down', params: { value: database, entries: availableDatabases, foreachVisible: true, searchable: true, linkTitle: '${ _ko('Active database') }' } }" style="display: inline-block"></div>
-    <!-- /ko -->
-    <!-- ko if: availableDatabases().length === 0-->
-    <span class="editor-header-title"><i class="fa fa-warning"></i> ${ _('No databases found') }</span>
-    <!-- /ko -->
-
-    <!-- /ko -->
+    <!-- ko template: { name: 'snippet-header-database-selection' } --><!-- /ko -->
     <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
     <!-- ko template: { name: 'snippet-header-statement-type${ suffix }' } --><!-- /ko -->
 
 
     <a class="inactive-action margin-left-10" href="javascript:void(0)" data-bind="toggle: settingsVisible, visible: hasProperties, css: { 'blue' : settingsVisible }" title="${ _('Query settings') }"><i class="fa fa-cog"></i></a>
     <a class="inactive-action margin-left-10" href="javascript:void(0)" data-bind="toggle: settingsVisible, visible: hasProperties, css: { 'blue' : settingsVisible }" title="${ _('Query settings') }"><i class="fa fa-cog"></i></a>
@@ -977,6 +950,35 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
   </div>
   </div>
 </script>
 </script>
 
 
+<script type="text/html" id="snippet-header-database-selection">
+  <!-- ko if: loadingContext() && isSqlDialect()  -->
+  <i class="fa fa-spinner fa-spin muted"></i>
+  <!-- /ko -->
+  <!-- ko if: !loadingContext() && isSqlDialect() -->
+  <!-- ko if: availableComputes().length > 1 || namespaceRefreshEnabled() -->
+  <!-- ko if: availableComputes().length > 0-->
+  <span class="editor-header-title">${ _('Compute') }</span>
+  <div data-bind="component: { name: 'hue-drop-down', params: { value: compute, entries: availableComputes, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active compute') }' } }" style="display: inline-block"></div>
+  <!-- /ko -->
+  <!-- ko if: availableComputes().length === 0-->
+  <span class="editor-header-title"><i class="fa fa-warning"></i> ${ _('No computes found') }</span>
+  <!-- /ko -->
+  <!-- /ko -->
+
+  <!-- ko if: (availableNamespaces().length > 1 || namespaceRefreshEnabled()) -->
+  <span class="editor-header-title">${ _('Namespace') }</span>
+  <div data-bind="component: { name: 'hue-drop-down', params: { value: namespace, entries: availableNamespaces, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active namespace') }' } }" style="display: inline-block"></div>
+  <!-- /ko -->
+
+  <!-- ko if: availableDatabases().length > 0 -->
+  <span class="editor-header-title">${ _('Database') }</span>
+  <div data-bind="component: { name: 'hue-drop-down', params: { value: database, entries: availableDatabases, foreachVisible: true, searchable: true, linkTitle: '${ _ko('Active database') }' } }" style="display: inline-block"></div>
+  <!-- /ko -->
+  <!-- ko if: availableDatabases().length === 0-->
+  <span class="editor-header-title"><i class="fa fa-warning"></i> ${ _('No databases found') }</span>
+  <!-- /ko -->
+  <!-- /ko -->
+</script>
 
 
 <script type="text/html" id="snippet-header-statement-type${ suffix }">
 <script type="text/html" id="snippet-header-statement-type${ suffix }">
   % if ENABLE_EXTERNAL_STATEMENT.get() and not IS_EMBEDDED.get():
   % if ENABLE_EXTERNAL_STATEMENT.get() and not IS_EMBEDDED.get():