Browse Source

HUE-8155 [metastore] Make sure navigator metadata is cleared on refresh in the table browser

Johan Ahlen 7 years ago
parent
commit
3715873f85

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

@@ -538,7 +538,7 @@ var MetastoreTable = (function () {
       $.post('/metadata/api/navigator/lineage', {
         id: self.navigatorMeta().identity
       }, function(data) {
-        if (data && data.status == 0) {
+        if (data && data.status === 0) {
           self.relationshipsDetails(ko.mapping.fromJS(data));
         } else {
           $(document).trigger("error", data.message);

+ 6 - 0
apps/metastore/src/metastore/templates/metastore.mako

@@ -1230,9 +1230,15 @@ ${ components.menubar(is_embeddable) }
               % if has_write_access:
                 <a href="#dropSingleTable" data-toggle="modal" class="btn btn-default" data-bind="attr: { 'title' : tableDetails() && tableDetails().is_view ? '${_('Drop View')}' : '${_('Drop Table')}' }"><i class="fa fa-times fa-fw"></i> ${_('Drop')}</a>
               % endif
+              <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh the table')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }"></i> ${_('Refresh')}</a>
               <!-- /ko -->
+              <!-- ko if: !table() -->
+              <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh the database')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }"></i> ${_('Refresh')}</a>
               <!-- /ko -->
+              <!-- /ko -->
+              <!-- ko if: !database() -->
               <a href="javascript: void(0);" class="btn btn-default" data-bind="click: reload" title="${_('Refresh')}"><i class="fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }"></i> ${_('Refresh')}</a>
+              <!-- /ko -->
             </div>
 
             <!-- ko template: 'metastore-breadcrumbs' --><!-- /ko -->

+ 20 - 0
desktop/core/src/desktop/static/desktop/js/dataCatalog.js

@@ -316,6 +316,17 @@ var DataCatalog = (function () {
       mergeAttribute('navOptPopularity', CACHEABLE_TTL.optimizer);
     };
 
+    /**
+     * @param {Object} options
+     * @param {string|string[]} options.path
+     * @return {DataCatalogEntry}
+     */
+    DataCatalog.prototype.getKnownEntry = function (options) {
+      var self = this;
+      var identifier = typeof options.path === 'string' ? options.path : options.path.join('.');
+      return self.entries[identifier];
+    };
+
     /**
      * @param {Object} options
      * @param {string|string[]} options.path
@@ -615,6 +626,14 @@ var DataCatalog = (function () {
       self.navOptPopularityForChildrenPromise = undefined;
 
       self.childrenPromise = undefined;
+      
+      if (self.path.length) {
+        var parent = self.dataCatalog.getKnownEntry({ path: self.path.slice(0, self.path.length - 1) });
+        if (parent) {
+          parent.navigatorMetaForChildrenPromise = undefined;
+          parent.navOptPopularityForChildrenPromise = undefined;
+        }
+      }
     };
 
     /**
@@ -864,6 +883,7 @@ var DataCatalog = (function () {
               var matchingChildEntry = childEntryIndex[(entity.original_name || entity.originalName).toLowerCase()];
               if (matchingChildEntry) {
                 matchingChildEntry.navigatorMeta = entity;
+                entity.hueTimestamp = Date.now();
                 matchingChildEntry.navigatorMetaPromise = $.Deferred().resolve(matchingChildEntry.navigatorMeta).promise();
                 if (entity && matchingChildEntry.commentObservable) {
                   matchingChildEntry.commentObservable(matchingChildEntry.getResolvedComment());

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

@@ -297,22 +297,22 @@ from desktop.views import _ko
 
   <script type="text/html" id="assist-db-breadcrumb">
     <div class="assist-flex-header assist-breadcrumb">
-      <!-- ko if: selectedSource()  && ! selectedSource().selectedDatabase() && sources().length === 1 -->
+      <!-- ko if: selectedSource() && !selectedSource().selectedDatabase() && sources().length === 1 -->
       <i class="fa fa-server assist-breadcrumb-text"></i>
-      <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb }"></span>
+      <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb() + ' (' + selectedSource().sourceType + ')' }"></span>
       <!-- /ko -->
-      <!-- ko if: selectedSource()  && ! selectedSource().selectedDatabase() && sources().length > 1 -->
+      <!-- ko if: selectedSource() && !selectedSource().selectedDatabase() && sources().length > 1 -->
       <a data-bind="click: back">
         <i class="fa fa-chevron-left assist-breadcrumb-back"></i>
         <i class="fa fa-server assist-breadcrumb-text"></i>
-        <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb }"></span>
+        <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb() + ' (' + selectedSource().sourceType + ')' }"></span>
       </a>
       <!-- /ko -->
-      <!-- ko if: selectedSource()  && selectedSource().selectedDatabase() -->
+      <!-- ko if: selectedSource() && selectedSource().selectedDatabase() -->
       <a data-bind="click: back, appAwareTemplateContextMenu: { template: 'sql-context-items', viewModel: selectedSource().selectedDatabase() }">
         <i class="fa fa-chevron-left assist-breadcrumb-back" ></i>
         <i class="fa fa-database assist-breadcrumb-text"></i>
-        <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb }"></span>
+        <span class="assist-breadcrumb-text" data-bind="text: breadcrumb, attr: {'title': breadcrumb() + ' (' + selectedSource().sourceType + ')' }"></span>
       </a>
       <!-- /ko -->
     </div>

+ 12 - 1
desktop/core/src/desktop/templates/ko_components/ko_nav_properties.mako

@@ -22,7 +22,7 @@ from django.utils.translation import ugettext as _
 <%def name="navProperties()">
   <script type="text/html" id="nav-properties-template">
      <!-- ko if: loading -->
-     <div data-bind="hueSpinner: { spin: loading }"></div>
+     <div class="hue-nav-properties"><div data-bind="hueSpinner: { spin: loading, inline: true }"></div></div>
      <!-- /ko -->
      <!-- ko ifnot: loading -->
      <div class="hue-nav-properties" data-bind="foreach: properties">
@@ -56,8 +56,19 @@ from django.utils.translation import ugettext as _
         self.catalogEntry = params.catalogEntry;
 
         self.loadProperties();
+
+        self.refreshSub = huePubSub.subscribe('data.catalog.entry.refreshed', function (details) {
+          if (details.entry === self.catalogEntry) {
+            self.loadProperties();
+          }
+        });
       }
 
+      NavProperties.prototype.dispose = function () {
+        var self = this;
+        self.refreshSub.remove();
+      };
+
       NavProperties.prototype.loadProperties = function () {
         var self = this;
         self.loading(true);

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

@@ -72,8 +72,19 @@ from django.utils.translation import ugettext as _
         };
 
         self.loadTags();
+
+        self.refreshSub = huePubSub.subscribe('data.catalog.entry.refreshed', function (details) {
+          if (details.entry === self.catalogEntry) {
+            self.loadTags();
+          }
+        });
       }
 
+      NavTags.prototype.dispose = function () {
+        var self = this;
+        self.refreshSub.remove();
+      };
+
       NavTags.prototype.loadTags = function () {
         var self = this;
         self.loading(true);