]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4407 Refactor the libraries page in order to drop GWT
authorStas Vilchik <vilchiks@gmail.com>
Thu, 21 Aug 2014 11:14:52 +0000 (17:14 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 21 Aug 2014 11:14:52 +0000 (17:14 +0600)
Clean up

server/sonar-web/src/main/coffee/libraries/app.coffee
server/sonar-web/src/main/coffee/libraries/view.coffee
server/sonar-web/src/main/hbs/libraries/libraries.hbs
server/sonar-web/src/main/js/common/handlebars-extensions.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index ee5e8c5d39aa358f6b8d495c11003f3e808d67f3..7d98074346c254b7f2051e65d2e83ed5ada0f33e 100644 (file)
@@ -40,6 +40,10 @@ requirejs [
           component.set 'libraries', data
 
       $.when.apply($, requests).done =>
+        components.reset components.reject (model) ->
+          (model.get('id') == window.resourceKey || model.get('key') == window.resourceKey) &&
+              model.get('libraries').length == 0
+
         @view = new LibrariesView app: @, collection: components
         $('#project-libraries').empty().append @view.render().el
 
index f3d01c9ce308ec5b74b116641c762cb424cfc5fa..6e14ed82df63b390e0505a976a24258411b07bf9 100644 (file)
@@ -74,3 +74,8 @@ define [
       @ui.collapseAll.toggle subTreesCount > subTreesCollapsedCount
       @ui.expandAll.toggle subTreesCollapsedCount > 0
 
+
+    serializeData: ->
+      _.extend super,
+        usagesUrl: "#{baseUrl}/dependencies/index?search=#{window.resourceKey}"
+
index 138dfdfd362409e6ceb547589f913da4a29e3769..1d19c539814377471e81ba52e9d5b487b02325f3 100644 (file)
@@ -1,21 +1,21 @@
 <div class="libraries-header">
   <div class="libraries-header-filter">
-    <label for="libraries-filter">Filter: </label>
+    <label for="libraries-filter">{{t 'libs.filter'}} </label>
     <input id="libraries-filter" type="text" class="js-libraries-filter">
   </div>
 
   <div class="libraries-header-test">
     <input type="checkbox" id="display-test-libraries" class="js-test-libraries">
-    <label for="display-test-libraries">Display test libraries</label>
+    <label for="display-test-libraries">{{t 'libs.displayTests'}}</label>
   </div>
 
   <div class="libraries-header-actions">
-    <a class="js-libraries-collapse-all">Collapse All</a>
-    <a class="js-libraries-expand-all">Expand All</a>
+    <a class="js-libraries-collapse-all">{{t 'libs.collapse'}}</a>
+    <a class="js-libraries-expand-all">{{t 'libs.expand'}}</a>
   </div>
 
   <div class="libraries-header-actions">
-    <a href="#">Usages</a>
+    <a href="{{usagesUrl}}">{{t 'libs.usageLink'}}</a>
   </div>
 </div>
 
       <li>
         {{qualifierIcon qualifier}}
         <span class="libraries-tree-name">{{lname}}</span>
-        <ul>
-          {{#recursive libraries}}
-            <li class="{{#if to}}libraries-tree-with-subtree libraries-tree-subtree-collapsed{{/if}} {{#eq u 'test'}}libraries-tree-test{{/eq}}">
-              <i class="icon-dropdown"></i>&nbsp;
-              {{qualifierIcon q}}
-              <span class="libraries-tree-name">{{n}}</span>
-              {{#if u}}
-                <span class="subtitle">({{u}})</span>
-              {{/if}}
-              {{#if to}}
-                <ul>{{{recursive to}}}</ul>
-              {{/if}}
-            </li>
-          {{/recursive}}
-        </ul>
+        {{#notEmpty libraries}}
+          <ul>
+            {{#recursive libraries}}
+              <li class="{{#if to}}libraries-tree-with-subtree libraries-tree-subtree-collapsed{{/if}} {{#eq u 'test'}}libraries-tree-test{{/eq}}">
+                <i class="icon-dropdown"></i>&nbsp;
+                {{qualifierIcon q}}
+                <span class="libraries-tree-name">{{n}}</span>
+                {{#if u}}
+                  <span class="subtitle">({{u}})</span>
+                {{/if}}
+                {{#if to}}
+                  <ul>{{{recursive to}}}</ul>
+                {{/if}}
+              </li>
+            {{/recursive}}
+          </ul>
+        {{else}}
+          {{t 'libs.noLibraries'}}
+        {{/notEmpty}}
       </li>
     {{/each}}
   </ul>
index 1d3d78bec5089f888be297ec1583bb958930c7dc..ab4329516153fa4368f8ae89bacbcee4e3546f17 100644 (file)
@@ -121,6 +121,11 @@ define(['handlebars'], function (Handlebars) {
     return value != null ? options.fn(this) : options.inverse(this);
   });
 
+  Handlebars.registerHelper('notEmpty', function(array, options) {
+    var cond = _.isArray(array) && array.length > 0;
+    return cond ? options.fn(this) : options.inverse(this);
+  });
+
   Handlebars.registerHelper('all', function() {
     var args = Array.prototype.slice.call(arguments, 0, -1),
         options = arguments[arguments.length - 1],
index 4e9c3d65d216427fd59ea5d4d7b134042ae9b812..1fa950fe99de1d3c3d496a9ae68bbcfce4661a7b 100644 (file)
@@ -2732,3 +2732,17 @@ design.legend.cycles=Suspect dependency (cycle)
 design.legend.uses=- uses >
 design.cellTooltip=Click to highlight, double-click to display more details
 design.rowTooltip=Click to highlight, double-click to zoom
+
+
+
+#------------------------------------------------------------------------------
+#
+# LIBRARIES
+#
+#------------------------------------------------------------------------------
+libs.filter=Filter:
+libs.displayTests=Display Test Libraries
+libs.expand=Expand All
+libs.collapse=Collapse All
+libs.noLibraries=No libraries
+libs.usageLink=Usages