Browse Source

[frontend] Hue at env level hue UI changes

* Hue at env level hue UI changes

1. Changes on the editor
  a. renamed compute -> virtual warehouse
  b. removed cluster selector
2. Removed the mini job-browser when running in computes mode

Change-Id: Ie2fc671487e22376a1d32d2d7635a4fba0c8af08

* Addressing review comments

* Fixing broken promise resolution

* [frontend] Fix linting and unit test issues

* [frontend] Only show the "Active Database" label when configured with computes

---------

Co-authored-by: Venkat Sairam <vsairam@MacBook-Pro.local>
Co-authored-by: Rajeshwari <rajeshwarikanchamreddy@gmail.com>
Co-authored-by: Johan Åhlén <johan@johanahlen.com>
Amit S 2 years ago
parent
commit
aac3643548

+ 1 - 1
desktop/core/src/desktop/js/ko/components/__snapshots__/ko.jobBrowserLinks.test.js.snap

@@ -3,6 +3,6 @@
 exports[`ko.jobBrowserLinks.js should render component 1`] = `
 exports[`ko.jobBrowserLinks.js should render component 1`] = `
 "<div data-bind=\\"descendantsComplete: descendantsComplete, component: { name: &quot;hue-job-browser-links&quot;, params: params }\\"><div class=\\"btn-group pull-right\\">
 "<div data-bind=\\"descendantsComplete: descendantsComplete, component: { name: &quot;hue-job-browser-links&quot;, params: params }\\"><div class=\\"btn-group pull-right\\">
     <!-- ko if: window.IS_K8S_ONLY --><!-- /ko -->
     <!-- ko if: window.IS_K8S_ONLY --><!-- /ko -->
-    <!-- ko if: window.HAS_JOB_BROWSER --><!-- /ko -->
+    <!-- ko if: window.HAS_JOB_BROWSER && !window.getLastKnownConfig().has_computes --><!-- /ko -->
   </div></div>"
   </div></div>"
 `;
 `;

+ 49 - 41
desktop/core/src/desktop/js/ko/components/ko.contextSelector.js

@@ -63,7 +63,7 @@ const TEMPLATE = `
     )}</span>
     )}</span>
     <!-- /ko -->
     <!-- /ko -->
 
 
-    <!-- ko if: availableNamespaces().length > 0 && !hideNamespaces -->
+    <!-- ko if: availableNamespaces().length > 1 && !hideNamespaces && !window.getLastKnownConfig().has_computes -->
     <!-- ko ifnot: hideLabels --><span class="editor-header-title">${I18n(
     <!-- ko ifnot: hideLabels --><span class="editor-header-title">${I18n(
       'Namespace'
       'Namespace'
     )}</span><!-- /ko -->
     )}</span><!-- /ko -->
@@ -79,6 +79,9 @@ const TEMPLATE = `
     <!-- /ko -->
     <!-- /ko -->
 
 
     <!-- ko if: availableDatabases().length > 0 && !hideDatabases-->
     <!-- ko if: availableDatabases().length > 0 && !hideDatabases-->
+    <!-- ko if: window.getLastKnownConfig().has_computes && !hideLabels --><span class="editor-header-title">${I18n(
+      'Active database'
+    )}</span><!-- /ko -->
     <div data-bind="component: { name: 'hue-drop-down', params: { titleName: 'Database', value: database, entries: availableDatabases, foreachVisible: true, searchable: true, linkTitle: '${I18n(
     <div data-bind="component: { name: 'hue-drop-down', params: { titleName: 'Database', value: database, entries: availableDatabases, foreachVisible: true, searchable: true, linkTitle: '${I18n(
       'Active database'
       'Active database'
     )}' } }" style="display: inline-block"></div>
     )}' } }" style="display: inline-block"></div>
@@ -248,13 +251,12 @@ const HueContextSelector = function (params) {
   }
   }
 
 
   self.loadingContext = ko.pureComputed(() => {
   self.loadingContext = ko.pureComputed(() => {
-    /*return (
+    return (
       self[TYPES_INDEX.cluster.loading]() ||
       self[TYPES_INDEX.cluster.loading]() ||
       self[TYPES_INDEX.namespace.loading]() ||
       self[TYPES_INDEX.namespace.loading]() ||
       self[TYPES_INDEX.compute.loading]() ||
       self[TYPES_INDEX.compute.loading]() ||
       self.loadingDatabases()
       self.loadingDatabases()
-    );*/
-    return false;
+    );
   });
   });
 };
 };
 
 
@@ -262,26 +264,31 @@ HueContextSelector.prototype.setMatchingNamespace = function (compute) {
   const self = this;
   const self = this;
   if (self[TYPES_INDEX.namespace.name]) {
   if (self[TYPES_INDEX.namespace.name]) {
     // Select the first corresponding namespace when a compute is selected (unless selected)
     // Select the first corresponding namespace when a compute is selected (unless selected)
-    self[TYPES_INDEX.namespace.lastPromise].done(() => {
-      if (
-        !self[TYPES_INDEX.namespace.name]() ||
-        self[TYPES_INDEX.namespace.name]().id !== compute.namespace
-      ) {
-        const found = self[TYPES_INDEX.namespace.available]().some(namespace => {
-          if (compute.namespace === namespace.id) {
-            self[TYPES_INDEX.namespace.name](namespace);
-            setInLocalStorage('contextSelector.' + TYPES_INDEX.namespace.localStorageId, namespace);
-            return true;
-          }
-        });
+    try {
+      self[TYPES_INDEX.namespace.lastPromise].done(() => {
+        if (
+          !self[TYPES_INDEX.namespace.name]() ||
+          self[TYPES_INDEX.namespace.name]().id !== compute.namespace
+        ) {
+          const found = self[TYPES_INDEX.namespace.available]().some(namespace => {
+            if (compute.namespace === namespace.id) {
+              self[TYPES_INDEX.namespace.name](namespace);
+              setInLocalStorage(
+                'contextSelector.' + TYPES_INDEX.namespace.localStorageId,
+                namespace
+              );
+              return true;
+            }
+          });
 
 
-        if (!found) {
-          // This can happen when a compute refers to a namespace that isn't returned by the namespaces call
-          // TODO: What should we do?
-          self[TYPES_INDEX.namespace.name](undefined);
+          if (!found) {
+            // This can happen when a compute refers to a namespace that isn't returned by the namespaces call
+            // TODO: What should we do?
+            self[TYPES_INDEX.namespace.name](undefined);
+          }
         }
         }
-      }
-    });
+      });
+    } catch (e) {}
   }
   }
 };
 };
 
 
@@ -289,27 +296,28 @@ HueContextSelector.prototype.setMatchingCompute = function (namespace) {
   const self = this;
   const self = this;
   if (self[TYPES_INDEX.compute.name]) {
   if (self[TYPES_INDEX.compute.name]) {
     // Select the first corresponding compute when a namespace is selected (unless selected)
     // Select the first corresponding compute when a namespace is selected (unless selected)
-    self[TYPES_INDEX.compute.lastPromise].done(() => {
-      if (
-        !self[TYPES_INDEX.compute.name]() ||
-        (self[TYPES_INDEX.compute.name]().namespace &&
-          self[TYPES_INDEX.compute.name]().namespace !== namespace.id)
-      ) {
-        const found = self[TYPES_INDEX.compute.available]().some(compute => {
-          if (namespace.id === compute.namespace) {
-            self[TYPES_INDEX.compute.name](compute);
-            setInLocalStorage('contextSelector.' + TYPES_INDEX.compute.localStorageId, namespace);
-            return true;
+    try {
+      self[TYPES_INDEX.compute.lastPromise].done(() => {
+        if (
+          !self[TYPES_INDEX.compute.name]() ||
+          (self[TYPES_INDEX.compute.name]().namespace &&
+            self[TYPES_INDEX.compute.name]().namespace !== namespace.id)
+        ) {
+          const found = self[TYPES_INDEX.compute.available]().some(compute => {
+            if (namespace.id === compute.namespace) {
+              self[TYPES_INDEX.compute.name](compute);
+              setInLocalStorage('contextSelector.' + TYPES_INDEX.compute.localStorageId, namespace);
+              return true;
+            }
+          });
+          if (!found) {
+            // This can happen when a namespace refers to a compute that isn't returned by the computes call
+            // TODO: What should we do?
+            self[TYPES_INDEX.compute.name](undefined);
           }
           }
-        });
-
-        if (!found) {
-          // This can happen when a namespace refers to a compute that isn't returned by the computes call
-          // TODO: What should we do?
-          self[TYPES_INDEX.compute.name](undefined);
         }
         }
-      }
-    });
+      });
+    } catch (e) {}
   }
   }
 };
 };
 
 

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.jobBrowserLinks.js

@@ -32,7 +32,7 @@ const TEMPLATE = `
         <span>${I18n('Queries')}</span>
         <span>${I18n('Queries')}</span>
       </a>
       </a>
     <!-- /ko -->
     <!-- /ko -->
-    <!-- ko if: window.HAS_JOB_BROWSER -->
+    <!-- ko if: window.HAS_JOB_BROWSER && !window.getLastKnownConfig().has_computes -->
     <!-- ko ifnot: window.IS_K8S_ONLY -->
     <!-- ko ifnot: window.IS_K8S_ONLY -->
       <a class="btn btn-flat" style="padding-right: 4px" title="${I18n(
       <a class="btn btn-flat" style="padding-right: 4px" title="${I18n(
         'Job browser'
         'Job browser'

+ 1 - 1
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -237,7 +237,7 @@
     'Columns': '${ _('Columns') }',
     'Columns': '${ _('Columns') }',
     'columns': '${ _('columns') }',
     'columns': '${ _('columns') }',
     'Compilation': '${ _('Compilation') }',
     'Compilation': '${ _('Compilation') }',
-    'Compute': '${ _('Compute') }',
+    'Compute': '${ _('Virtual Warehouse') }',
     'condition': '${ _('condition') }',
     'condition': '${ _('condition') }',
     'Confirm History Clearing': '${ _('Confirm History Clearing') }',
     'Confirm History Clearing': '${ _('Confirm History Clearing') }',
     'Confirm the deletion?': '${ _('Confirm the deletion?') }',
     'Confirm the deletion?': '${ _('Confirm the deletion?') }',