Browse Source

HUE-8847 [catalog] Display classification name as tooltip when hovering over properties in the table browser

Johan Ahlen 6 năm trước cách đây
mục cha
commit
f9978a4c3a

+ 20 - 2
desktop/core/src/desktop/js/ko/components/ko.navProperties.js

@@ -63,7 +63,7 @@ const TEMPLATE = `
   <!-- ko if: window.HAS_READ_ONLY_CATALOG && properties().length -->
   <div class="hue-nav-properties">
     <!-- ko foreach: properties -->
-    <div class="hue-nav-property"><div class="hue-nav-property-key" data-bind="text: key, attr: { 'title': key }"></div><div class="hue-nav-property-value" data-bind="text: value, attr: { 'title': value }"></div></div>
+    <div class="hue-nav-property" data-bind="tooltip: { placement: 'bottom' }, attr: { title: title }"><div class="hue-nav-property-key" data-bind="text: key"></div><div class="hue-nav-property-value" data-bind="text: value"></div></div>
     <!-- /ko -->
   </div>
   <!-- /ko -->
@@ -106,6 +106,8 @@ class NavProperty {
 
     self.editPropertyVisible = ko.observable(isNew);
 
+    self.title = ko.observable();
+
     const keySub = self.key.subscribe(() => {
       keySub.dispose();
       self.keyEdited(true);
@@ -140,6 +142,10 @@ class NavProperty {
       );
     });
   }
+
+  setTitle(title) {
+    this.title(title);
+  }
 }
 
 class NavProperties {
@@ -278,7 +284,19 @@ class NavProperties {
       .getNavigatorMeta()
       .done(navigatorMeta => {
         const newProps = [];
-        if (navigatorMeta.properties) {
+
+        if (navigatorMeta.classifications) {
+          navigatorMeta.classifications.forEach(classification => {
+            Object.keys(classification.attributes).forEach(attributeKey => {
+              const property = new NavProperty(
+                attributeKey,
+                classification.attributes[attributeKey]
+              );
+              property.setTitle(classification.typeName);
+              newProps.push(property);
+            });
+          });
+        } else if (navigatorMeta.properties) {
           Object.keys(navigatorMeta.properties).forEach(key => {
             if (!key.startsWith('__cloudera_internal')) {
               newProps.push(new NavProperty(key, navigatorMeta.properties[key]));

+ 2 - 0
desktop/libs/metadata/src/metadata/catalog/atlas_client.py

@@ -108,6 +108,7 @@ class AtlasApi(Api):
       "parentPath": '', # Set below
       "properties": {}, # Set below
       "sourceType": '', # Set below
+      "classifications": [],
       "tags": atlas_entity['classificationNames'],
       "type": self.ATLAS_TO_NAV_TYPE.get(atlas_entity['typeName'].lower()) or atlas_entity['typeName']
     }
@@ -120,6 +121,7 @@ class AtlasApi(Api):
       nav_entity['parentPath'] = '/' + '/'.join(qualified_path_parts)
 
     if 'classifications' in atlas_entity:
+      nav_entity['classifications'] = atlas_entity['classifications']
       for atlas_classification in atlas_entity['classifications']:
         if 'attributes' in atlas_classification:
           for key, value in atlas_classification['attributes'].iteritems():