[cluster] Refresh the context selector when namespaces are refreshed
@@ -173,6 +173,8 @@ from desktop.views import _ko
self.compute = params.compute;
self.hideComputes = params.hideComputes || !self.compute;
+ self.lastComputesPromise = undefined;
+ self.reloadComputes = function () {
if (params.compute) {
self.loadingComputes(true);
self.lastComputesPromise = ContextCatalog.getComputes({ sourceType: ko.unwrap(self.sourceType) }).done(function (computes) {
@@ -216,7 +218,8 @@ from desktop.views import _ko
} else {
self.lastComputesPromise = $.Deferred().resolve().promise();
}
-
+ };
+ self.reloadComputes();
self.loadingNamespaces = ko.observable(false);
self.availableNamespaces = ko.observableArray();
@@ -254,6 +257,19 @@ from desktop.views import _ko
};
self.reloadNamespaces();
+ var refreshNamespacesThrottle = -1;
+ var namespaceRefreshSub = huePubSub.subscribe('context.catalog.namespaces.refreshed', function () {
+ window.clearTimeout(refreshNamespacesThrottle);
+ refreshNamespacesThrottle = window.setTimeout(function () {
+ self.reloadComputes();
+ self.reloadNamespaces();
+ }, 100)
+ });
+ self.disposals.push(function () {
+ window.clearTimeout(refreshNamespacesThrottle);
+ namespaceRefreshSub.remove();
+ });
+
self.loadingDatabases = ko.observable(false);
self.availableDatabases = params.availableDatabases || ko.observableArray();
self.database = params.database;
