Просмотр исходного кода

HUE-8615 [frontend] Make sure namespaces and computes always have a name in the context selector

Johan Ahlen 7 лет назад
Родитель
Сommit
45e834e16e

+ 11 - 0
desktop/core/src/desktop/templates/ko_components/ko_context_selector.mako

@@ -276,6 +276,17 @@ from desktop.views import _ko
               available = available.namespaces;
             }
             self[type.available](available);
+
+            // 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) {
+                if (other !== self[type.name]() && other.id === self[type.name]().id) {
+                  self[type.name](other);
+                  return true;
+                }
+              });
+            }
+
             if (!self[type.name]() && self.apiHelper.getFromTotalStorage('contextSelector', type.totalStorageId)) {
               var lastSelected = self.apiHelper.getFromTotalStorage('contextSelector', type.totalStorageId);
               var found = available.some(function (other) {