From 37458df7c84716dc31ef3546932f78ea6904a750 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 6 Jul 2015 11:20:20 +0200 Subject: [PATCH] SONAR-6661 move system upgrades into separate tab --- .../main/js/apps/update-center/controller.js | 5 +++++ .../src/main/js/apps/update-center/plugins.js | 11 ++++++++-- .../src/main/js/apps/update-center/router.js | 7 +++++- .../templates/update-center-search.hbs | 22 ++++++++++++++----- .../sonar-web/src/main/less/init/forms.less | 1 + .../updatecenter_new_controller.rb | 4 ++++ .../test/medium/update-center.spec.js | 15 ++++++++----- 7 files changed, 50 insertions(+), 15 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/update-center/controller.js b/server/sonar-web/src/main/js/apps/update-center/controller.js index bc05151bab7..a8f069c9dc0 100644 --- a/server/sonar-web/src/main/js/apps/update-center/controller.js +++ b/server/sonar-web/src/main/js/apps/update-center/controller.js @@ -19,6 +19,11 @@ define(function () { showAvailable: function () { this.state.set({ section: 'available' }); this.collection.fetchAvailable(); + }, + + showSystemUpgrades: function () { + this.state.set({ section: 'system' }); + this.collection.fetchSystemUpgrades(); } }); diff --git a/server/sonar-web/src/main/js/apps/update-center/plugins.js b/server/sonar-web/src/main/js/apps/update-center/plugins.js index 6763c04e250..f81c7702a38 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugins.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugins.js @@ -110,7 +110,7 @@ define([ return Backbone.ajax(opts); }, - _fetchSystemUpdates: function () { + _fetchSystemUpgrades: function () { if (this._systemUpdates) { return $.Deferred().resolve().promise(); } @@ -140,7 +140,7 @@ define([ fetchUpdates: function () { var that = this; - return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending(), this._fetchSystemUpdates()) + return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()) .done(function () { var plugins = new Plugins(); plugins.set(that._installed); @@ -161,6 +161,13 @@ define([ }); }, + fetchSystemUpgrades: function () { + var that = this; + return $.when(this._fetchSystemUpgrades()).done(function () { + that.reset(that._systemUpdates); + }); + }, + search: function (query) { this.filter(function (model) { model.set({ _hidden: !model.match(query) }); diff --git a/server/sonar-web/src/main/js/apps/update-center/router.js b/server/sonar-web/src/main/js/apps/update-center/router.js index b35b12df39e..0a9af1440cc 100644 --- a/server/sonar-web/src/main/js/apps/update-center/router.js +++ b/server/sonar-web/src/main/js/apps/update-center/router.js @@ -5,7 +5,8 @@ define(function () { '': 'index', 'installed': 'showInstalled', 'updates': 'showUpdates', - 'available': 'showAvailable' + 'available': 'showAvailable', + 'system': 'showSystemUpgrades' }, initialize: function (options) { @@ -26,6 +27,10 @@ define(function () { showAvailable: function () { this.controller.showAvailable(); + }, + + showSystemUpgrades: function () { + this.controller.showSystemUpgrades(); } }); diff --git a/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs b/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs index c4801a0ae05..2ab5f06fc6c 100644 --- a/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs +++ b/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs @@ -1,5 +1,5 @@
-
+
  • Available
+ +
    +
  • + + +
  • +
- + {{#notEq state.section 'system'}} + + {{/notEq}}
diff --git a/server/sonar-web/src/main/less/init/forms.less b/server/sonar-web/src/main/less/init/forms.less index 1eba5126fe0..20599a63a0c 100644 --- a/server/sonar-web/src/main/less/init/forms.less +++ b/server/sonar-web/src/main/less/init/forms.less @@ -222,6 +222,7 @@ label[for] { } .radio-toggle { + display: inline-block; font-size: 0; & > li { diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/updatecenter_new_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/updatecenter_new_controller.rb index 35f22971fef..14185ad966a 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/updatecenter_new_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/updatecenter_new_controller.rb @@ -37,4 +37,8 @@ class UpdatecenterNewController < ApplicationController def available render :action => 'index' end + + def system + render :action => 'index' + end end diff --git a/server/sonar-web/test/medium/update-center.spec.js b/server/sonar-web/test/medium/update-center.spec.js index 6ef19879e78..f0bc650ab9e 100644 --- a/server/sonar-web/test/medium/update-center.spec.js +++ b/server/sonar-web/test/medium/update-center.spec.js @@ -30,12 +30,10 @@ define(function (require) { .checkElementNotExist('li[data-id="scmgit"] .js-install'); }); - bdd.it('should show system update', function () { + bdd.it('should show system upgrade', function () { return this.remote - .open('#updates') + .open('#system') .mockFromString('/api/l10n/index', '{}') - .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json') - .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json') .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json') .mockFromFile('/api/system/upgrades', 'update-center-spec/system-updates.json') .startApp('update-center', { urlRoot: '/test/medium/base.html' }) @@ -71,7 +69,6 @@ define(function (require) { .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json') .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json') .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json') - .mockFromFile('/api/system/upgrades', 'update-center-spec/system-updates.json') .startApp('update-center', { urlRoot: '/test/medium/base.html' }) .checkElementExist('.js-plugin-name') .checkElementCount('li[data-id]', 4) @@ -116,6 +113,9 @@ define(function (require) { .checkElementCount('li[data-id]', 4) .checkElementExist('li[data-id="scmgit"]') .checkElementExist('#update-center-filter-updates:checked') + .clickElement('[for="update-center-filter-system"]') + .checkElementExist('li[data-system]') + .checkElementExist('#update-center-filter-system:checked') .clickElement('[for="update-center-filter-installed"]') .checkElementExist('li[data-id="javascript"]') .checkElementCount('li[data-id]', 5) @@ -130,7 +130,10 @@ define(function (require) { .checkElementExist('li[data-id="scmgit"]') .checkElementCount('li[data-id]', 4) .checkElementExist('li[data-id="scmgit"]') - .checkElementExist('#update-center-filter-updates:checked'); + .checkElementExist('#update-center-filter-updates:checked') + .clickElement('[for="update-center-filter-system"]') + .checkElementExist('li[data-system]') + .checkElementExist('#update-center-filter-system:checked'); }); bdd.it('should search', function () { -- 2.39.5