]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6852 Improve display of package names inside word cloud widget
authorStas Vilchik <vilchiks@gmail.com>
Tue, 15 Sep 2015 14:45:39 +0000 (16:45 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 15 Sep 2015 14:45:39 +0000 (16:45 +0200)
server/sonar-web/src/main/js/libs/widgets/word-cloud.js

index c12e02390e4bafa808c465c85faba50764c6494a..15fd7e9e96e47fea86d1dd9d1c30b3c674499f9c 100644 (file)
 
   WordCloud.prototype.sizeLow = 10;
 
+  WordCloud.prototype.formatDirectory = function (path) {
+    var dirs = path.split('/');
+    if (dirs.length > 2) {
+      return '.../' + dirs[dirs.length - 1];
+    } else {
+      return path;
+    }
+  };
+
   WordCloud.prototype.renderWords = function () {
     var that = this;
     var words = this.wordContainer.selectAll('.cloud-word').data(this.components()),
         wordsEnter = words.enter().append('a').classed('cloud-word', true);
     wordsEnter.text(function (d) {
-      return d.name;
+      return d.qualifier === 'DIR' ? that.formatDirectory(d.name) : d.name;
     });
     wordsEnter.attr('href', function (d) {
       return that.options().baseUrl + '?id=' + encodeURIComponent(d.key);