Bläddra i källkod

HUE-8496 [frontend] Switch to using the new multi cluster config flag in the UI

Johan Ahlen 7 år sedan
förälder
incheckning
a81cc59

+ 1 - 1
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -150,7 +150,7 @@ var MetastoreViewModel = (function () {
         var params = {
           source: self.source().type
         };
-        if (self.source().namespaces().length > 1 || self.source().namespaceRefreshEnabled()) {
+        if (window.HAS_MULTI_CLUSTER) {
           params.namespace = self.source().namespace().id
         }
         if (self.source().namespace().database() && self.source().namespace().database().table()) {

+ 0 - 2
apps/metastore/src/metastore/static/metastore/js/metastore.model.js

@@ -28,7 +28,6 @@ var MetastoreSource = (function () {
     self.lastLoadNamespacesDeferred = $.Deferred();
     self.namespace = ko.observable();
     self.namespaces = ko.observableArray();
-    self.namespaceRefreshEnabled = ko.observable();
 
     self.namespace.subscribe(function () {
       if (self.namespace() && self.namespace().databases().length === 0) {
@@ -152,7 +151,6 @@ var MetastoreSource = (function () {
     var self = this;
     self.loading(true);
     ContextCatalog.getNamespaces({ sourceType: self.type }).done(function (context) {
-      self.namespaceRefreshEnabled(context.dynamic);
       self.namespaces($.map(context.namespaces, function (namespace) {
         return new MetastoreNamespace({
           metastoreViewModel: self.metastoreViewModel,

+ 1 - 1
apps/metastore/src/metastore/templates/metastore.mako

@@ -85,7 +85,7 @@ ${ components.menubar(is_embeddable) }
   <div style="font-size: 14px; margin: 0 12px; line-height: 27px;">
     <div data-bind="component: { name: 'hue-drop-down', params: { value: source, entries: sources, onChanged: sourceChanged, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Source') }' } }" style="display: inline-block"></div>
     <!-- ko with: source -->
-    <!-- ko if: namespaces().length > 1 || namespaceRefreshEnabled() -->
+    <!-- ko if: window.HAS_MULTI_CLUSTER -->
     <div class="margin-left-10" data-bind="component: { name: 'hue-drop-down', params: { value: namespace, entries: namespaces, onChanged: namespaceChanged, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Namespace') }' } }" style="display: inline-block"></div>
     <!-- /ko -->
     <!-- /ko -->

+ 0 - 3
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -37,7 +37,6 @@ var AssistDbSource = (function () {
 
     self.selectedNamespace = ko.observable();
     self.namespaces = ko.observableArray();
-    self.namespaceRefreshEnabled = ko.observable(false);
 
     self.loadedDeferred = $.Deferred();
     self.loading = ko.observable(false);
@@ -86,7 +85,6 @@ var AssistDbSource = (function () {
       ContextCatalog.getNamespaces({ sourceType: self.sourceType }).done(function (context) {
         var newNamespaces = [];
         var existingNamespaceIndex = {};
-        self.namespaceRefreshEnabled(context.dynamic);
         self.namespaces().forEach(function (assistNamespace) {
           existingNamespaceIndex[assistNamespace.namespace.id] = assistNamespace;
         });
@@ -124,7 +122,6 @@ var AssistDbSource = (function () {
       var assistNamespaces = [];
       var activeNamespace;
       var activeCompute;
-      self.namespaceRefreshEnabled(context.dynamic);
       context.namespaces.forEach(function (namespace) {
         var assistNamespace = new AssistDbNamespace({
           sourceType: self.sourceType,

+ 5 - 5
desktop/core/src/desktop/templates/assist.mako

@@ -311,14 +311,14 @@ from desktop.views import _ko
       </a>
       <!-- /ko -->
       <!-- ko ifnot: selectedSource().selectedNamespace().selectedDatabase() -->
-      <!-- ko if: selectedSource().namespaceRefreshEnabled() || selectedSource().namespaces().length > 1-->
+      <!-- ko if: window.HAS_MULTI_CLUSTER-->
       <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>
         <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb() + ' (' + selectedSource().sourceType + ')' }"></span>
       </a>
       <!-- /ko -->
-      <!-- ko if: !selectedSource().namespaceRefreshEnabled() && selectedSource().namespaces().length <= 1 -->
+      <!-- ko ifnot: window.HAS_MULTI_CLUSTER -->
       <a data-bind="click: back">
         <i class="fa fa-chevron-left assist-breadcrumb-back"></i>
         <i class="fa fa-server assist-breadcrumb-text"></i>
@@ -861,7 +861,7 @@ from desktop.views import _ko
     <div class="assist-db-header-actions">
       <!-- ko ifnot: loading -->
       <span class="assist-tables-counter">(<span data-bind="text: filteredNamespaces().length"></span>)</span>
-      <!-- ko if: namespaceRefreshEnabled -->
+      <!-- ko if: window.HAS_MULTI_CLUSTER -->
       <a class="inactive-action" href="javascript:void(0)" data-bind="click: triggerRefresh"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }" title="${_('Refresh')}"></i></a>
       <!-- /ko -->
       <!-- /ko -->
@@ -1442,7 +1442,7 @@ from desktop.views import _ko
               if (self.selectedSource().selectedNamespace().selectedDatabase()) {
                 return self.selectedSource().selectedNamespace().selectedDatabase().catalogEntry.name
               }
-              if (self.selectedSource().namespaceRefreshEnabled() || self.selectedSource().namespaces().length > 1) {
+              if (window.HAS_MULTI_CLUSTER) {
                 return self.selectedSource().selectedNamespace().name
               }
             }
@@ -1458,7 +1458,7 @@ from desktop.views import _ko
           if (self.selectedSource() && self.selectedSource().selectedNamespace()) {
             if (self.selectedSource().selectedNamespace().selectedDatabase()) {
               self.selectedSource().selectedNamespace().selectedDatabase(null);
-            } else if (self.selectedSource().namespaceRefreshEnabled() || self.selectedSource().namespaces().length > 1) {
+            } else if (window.HAS_MULTI_CLUSTER) {
               self.selectedSource().selectedNamespace(null)
             } else {
               self.selectedSource(null);

+ 2 - 0
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -40,6 +40,8 @@
     window.CSRF_TOKEN = '';
   %endif
 
+  window.HAS_MULTI_CLUSTER = '${ conf.has_multi_cluster() }' === 'True';
+
   window.DROPZONE_HOME_DIR = '${ user.get_home_directory() if not user.is_anonymous() else "" }';
 
   window.ENABLE_SQL_SYNTAX_CHECK = '${ conf.ENABLE_SQL_SYNTAX_CHECK.get() }' === 'True';

+ 0 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -357,7 +357,6 @@ var EditorViewModel = (function() {
     };
 
     self.loadingNamespaces = ko.observable(true);
-    self.namespaceRefreshEnabled = ko.observable(false);
     self.availableNamespaces = ko.observableArray();
     self.namespace = ko.observable();
 
@@ -365,7 +364,6 @@ var EditorViewModel = (function() {
     self.reloadNamespaces = function () {
       self.loadingNamespaces(true);
       self.lastNamespacePromise = ContextCatalog.getNamespaces({ sourceType: self.type() }).done(function (context) {
-        self.namespaceRefreshEnabled(context.dynamic);
         self.availableNamespaces(context.namespaces);
         if (!snippet.namespace || !context.namespaces.some(function (namespace) {
           if (namespace.id === snippet.namespace.id) {

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

@@ -983,7 +983,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
   <!-- /ko -->
 
   <!-- ko if: !loadingContext() && (isSqlDialect() || type() == 'spark2') -->
-  <!-- ko if: availableComputes().length > 1 || namespaceRefreshEnabled() -->
+  <!-- ko if: window.HAS_MULTI_CLUSTER -->
   <!-- ko if: availableComputes().length > 0 -->
   <span class="editor-header-title">${ _('Compute') }</span>
   <div data-bind="component: { name: 'hue-drop-down', params: { value: compute, entries: availableComputes, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active compute') }' } }" style="display: inline-block"></div>
@@ -993,7 +993,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
   <!-- /ko -->
   <!-- /ko -->
 
-  <!-- ko if: (availableNamespaces().length > 1 || namespaceRefreshEnabled()) -->
+  <!-- ko if: window.HAS_MULTI_CLUSTER -->
   <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 -->