From 244792e37d7ba0e9a822c5ebbb2a785f63944af5 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 21 Aug 2014 17:14:52 +0600 Subject: [PATCH] SONAR-4407 Refactor the libraries page in order to drop GWT Clean up --- .../src/main/coffee/libraries/app.coffee | 4 ++ .../src/main/coffee/libraries/view.coffee | 5 +++ .../src/main/hbs/libraries/libraries.hbs | 44 ++++++++++--------- .../main/js/common/handlebars-extensions.js | 5 +++ .../resources/org/sonar/l10n/core.properties | 14 ++++++ 5 files changed, 52 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 @@
- +
- +
@@ -25,21 +25,25 @@
  • {{qualifierIcon qualifier}} {{lname}} - + {{#notEmpty libraries}} + + {{else}} + {{t 'libs.noLibraries'}} + {{/notEmpty}}
  • {{/each}} 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], diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 4e9c3d65d21..1fa950fe99d 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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 -- 2.39.5