فهرست منبع

HUE-8654 [editor] Guarantee a namespace and compute is set in single cluster mode

Johan Ahlen 7 سال پیش
والد
کامیت
70d0367
1فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 10 1
      desktop/core/src/desktop/templates/ko_components/ko_context_selector.mako

+ 10 - 1
desktop/core/src/desktop/templates/ko_components/ko_context_selector.mako

@@ -255,7 +255,7 @@ from desktop.views import _ko
         if (self[TYPES_INDEX.compute.name]) {
           // Select the first corresponding compute when a namespace is selected (unless selected)
           self[TYPES_INDEX.compute.lastPromise].done(function () {
-            if (!self[TYPES_INDEX.compute.name]() || self[TYPES_INDEX.compute.name]().namespace !== namespace.id) {
+            if (!self[TYPES_INDEX.compute.name]() || (self[TYPES_INDEX.compute.name]().namespace && self[TYPES_INDEX.compute.name]().namespace !== namespace.id)) {
               var found = self[TYPES_INDEX.compute.available]().some(function (compute) {
                 if (namespace.id === compute.namespace) {
                   self[TYPES_INDEX.compute.name](compute);
@@ -287,6 +287,15 @@ from desktop.views import _ko
             }
             self[type.available](available);
 
+            // If we only get one and hue is not configured for multi-cluster we always fallback to the returned
+            // compute or namespace from the backend. This also guarantees a compute and namespace is always set.
+            if (available.length === 1 && !window.HAS_MULTI_CLUSTER) {
+              if (!self[type.name]() || self[type.name]().id !== available[0].id) {
+                self[type.name](available[0]);
+              }
+              return;
+            }
+
             // In some cases we could have a namespace or compute without the name attribute, or the name might have changed.
             if (self[type.name]() && !self[type.name]().name) {
               available.some(function (other) {