summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-08-21 17:14:52 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-08-21 17:14:52 +0600
commit244792e37d7ba0e9a822c5ebbb2a785f63944af5 (patch)
tree69b5cd76d5ece96ce6539c0b442231efb0af6236 /server
parent5092b1b8d1630382d6e3c37e6a6b2dab51304eca (diff)
downloadsonarqube-244792e37d7ba0e9a822c5ebbb2a785f63944af5.tar.gz
sonarqube-244792e37d7ba0e9a822c5ebbb2a785f63944af5.zip
SONAR-4407 Refactor the libraries page in order to drop GWT
Clean up
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/coffee/libraries/app.coffee4
-rw-r--r--server/sonar-web/src/main/coffee/libraries/view.coffee5
-rw-r--r--server/sonar-web/src/main/hbs/libraries/libraries.hbs44
-rw-r--r--server/sonar-web/src/main/js/common/handlebars-extensions.js5
4 files changed, 38 insertions, 20 deletions
diff --git a/server/sonar-web/src/main/coffee/libraries/app.coffee b/server/sonar-web/src/main/coffee/libraries/app.coffee
index ee5e8c5d39a..7d98074346c 100644
--- a/server/sonar-web/src/main/coffee/libraries/app.coffee
+++ b/server/sonar-web/src/main/coffee/libraries/app.coffee
@@ -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
diff --git a/server/sonar-web/src/main/coffee/libraries/view.coffee b/server/sonar-web/src/main/coffee/libraries/view.coffee
index f3d01c9ce30..6e14ed82df6 100644
--- a/server/sonar-web/src/main/coffee/libraries/view.coffee
+++ b/server/sonar-web/src/main/coffee/libraries/view.coffee
@@ -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}"
+
diff --git a/server/sonar-web/src/main/hbs/libraries/libraries.hbs b/server/sonar-web/src/main/hbs/libraries/libraries.hbs
index 138dfdfd362..1d19c539814 100644
--- a/server/sonar-web/src/main/hbs/libraries/libraries.hbs
+++ b/server/sonar-web/src/main/hbs/libraries/libraries.hbs
@@ -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>
@@ -25,21 +25,25 @@
<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>
diff --git a/server/sonar-web/src/main/js/common/handlebars-extensions.js b/server/sonar-web/src/main/js/common/handlebars-extensions.js
index 1d3d78bec50..ab432951615 100644
--- a/server/sonar-web/src/main/js/common/handlebars-extensions.js
+++ b/server/sonar-web/src/main/js/common/handlebars-extensions.js
@@ -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],