瀏覽代碼

HUE-7743 [metastore] Use the app parameter for table browser navigation in embedded mode

Johan Ahlen 8 年之前
父節點
當前提交
79f46604c5

+ 22 - 8
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -137,17 +137,22 @@ var MetastoreViewModel = (function () {
 
 
     huePubSub.subscribe('metastore.url.change', function () {
     huePubSub.subscribe('metastore.url.change', function () {
       var prefix = '/metastore/';
       var prefix = '/metastore/';
-      if (self.isHue4()){
+      if (self.isHue4() && !IS_EMBEDDED){
         prefix = '/hue' + prefix;
         prefix = '/hue' + prefix;
       }
       }
+      var newUrl;
       if (self.database() && self.database().table()) {
       if (self.database() && self.database().table()) {
-        hueUtils.changeURL(prefix + 'table/' + self.database().name + '/' + self.database().table().name);
-      }
-      else if (self.database()) {
-        hueUtils.changeURL(prefix + 'tables/' + self.database().name);
+        newUrl = prefix + 'table/' + self.database().name + '/' + self.database().table().name;
+      } else if (self.database()) {
+        newUrl = prefix + 'tables/' + self.database().name;
+      } else {
+        newUrl = prefix + 'databases';
       }
       }
-      else {
-        hueUtils.changeURL(prefix + 'databases');
+
+      if (IS_EMBEDDED) {
+        hueUtils.changeURLParameter('app', newUrl);
+      } else {
+        hueUtils.changeURL(newUrl);
       }
       }
     });
     });
 
 
@@ -296,7 +301,16 @@ var MetastoreViewModel = (function () {
   MetastoreViewModel.prototype.loadURL = function () {
   MetastoreViewModel.prototype.loadURL = function () {
     var self = this;
     var self = this;
 
 
-    var path = (IS_HUE_4 ? window.location.pathname.substr(4) : window.location.pathname);
+    var path;
+
+    if (IS_EMBEDDED) {
+      var appMatch = location.search.match(/app=\/?([^&#]+)/);
+      if (appMatch) {
+        path = '/' + appMatch[1];
+      }
+    } else {
+      path = (IS_HUE_4 ? window.location.pathname.substr(4) : window.location.pathname);
+    }
     if (!path) {
     if (!path) {
       path = '/metastore/tables';
       path = '/metastore/tables';
     }
     }

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

@@ -157,6 +157,8 @@
 
 
   window.HUE_VERSION = '${ hue_version() }';
   window.HUE_VERSION = '${ hue_version() }';
 
 
+  window.IS_EMBEDDED = '${ IS_EMBEDDED.get() }' === 'True';
+
   %if hasattr(ENABLE_NEW_INDEXER, 'get') and ENABLE_NEW_INDEXER.get():
   %if hasattr(ENABLE_NEW_INDEXER, 'get') and ENABLE_NEW_INDEXER.get():
     window.IS_NEW_INDEXER_ENABLED = true;
     window.IS_NEW_INDEXER_ENABLED = true;
   %else:
   %else: