Browse Source

HUE-8330 [assist] Only show namespace selection when there are more than one available

Johan Ahlen 7 years ago
parent
commit
29bce0860b

+ 0 - 17
desktop/core/src/desktop/static/desktop/js/assist/assistDbNamespace.js

@@ -1,17 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-

+ 5 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -102,7 +102,11 @@ var AssistDbSource = (function () {
         assistNamespaces.push(assistNamespace);
       });
       self.namespaces(assistNamespaces);
-      self.selectedNamespace(activeNamespace || assistNamespaces.length && assistNamespaces[0]);
+      if (activeNamespace) {
+        self.selectedNamespace(activeNamespace);
+      } else if (assistNamespaces.length) {
+        self.selectedNamespace(assistNamespaces[0]);
+      }
     }).fail(function () {
       self.hasErrors(true);
     }).always(function () {

+ 7 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -311,7 +311,7 @@ from desktop.views import _ko
       <!-- ko ifnot: selectedSource().selectedNamespace().selectedDatabase() -->
       <a data-bind="click: back">
         <i class="fa fa-chevron-left assist-breadcrumb-back"></i>
-        <i class="fa fa-snowflake-o assist-breadcrumb-text"></i>
+        <i class="fa assist-breadcrumb-text" data-bind="css: { 'fa-snowflake-o': selectedSource().namespaces().length > 1, 'fa-server': selectedSource().namespaces().length <= 1 }"></i>
         <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb() + ' (' + selectedSource().sourceType + ')' }"></span>
       </a>
       <!-- /ko -->
@@ -1336,7 +1336,9 @@ from desktop.views import _ko
               if (self.selectedSource().selectedNamespace().selectedDatabase()) {
                 return self.selectedSource().selectedNamespace().selectedDatabase().catalogEntry.name
               }
-              return self.selectedSource().selectedNamespace().name
+              if (self.selectedSource().namespaces().length > 1) {
+                return self.selectedSource().selectedNamespace().name
+              }
             }
             return self.selectedSource().name;
           }
@@ -1350,8 +1352,10 @@ from desktop.views import _ko
           if (self.selectedSource() && self.selectedSource().selectedNamespace()) {
             if (self.selectedSource().selectedNamespace().selectedDatabase()) {
               self.selectedSource().selectedNamespace().selectedDatabase(null);
-            } else {
+            } else if (self.selectedSource().namespaces().length > 1) {
               self.selectedSource().selectedNamespace(null)
+            } else {
+              self.selectedSource(null);
             }
           } else {
             self.selectedSource(null);

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

@@ -941,7 +941,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
     <!-- 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>
 
-    <!-- ko if: availableComputes().length > 1 -->
+    <!-- ko if: availableNamespaces().length > 1 -->
     <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 -->