From e72ebb2c71eb46abda41ec2203185ce934c0d1bf Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Sep 2015 11:51:55 +0200 Subject: [PATCH] SONAR-6209 While in the profile context, activation modal should suggest selected profile first --- .../rule/profile-activation-view.js | 4 +++- .../rule/coding-rules-profile-activation.hbs | 3 ++- .../test/medium/coding-rules.spec.js | 24 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 87296ca2e0f..ab7a8ab4de8 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -144,12 +144,14 @@ define([ } } - var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); + var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')), + contextProfile = this.options.app.state.get('query').qprofile; return _.extend(this._super(), { change: this.model && this.model.has('severity'), params: params, qualityProfiles: availableProfiles, + contextProfile: contextProfile, severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'], saveEnabled: !_.isEmpty(availableProfiles) || (this.model && this.model.get('qProfile')), isCustomRule: (this.model && this.model.has('templateKey')) || this.options.rule.has('templateKey') diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs index e7a7164d4c4..f41709fe397 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs @@ -25,7 +25,8 @@ {{else}} {{/any}} diff --git a/server/sonar-web/test/medium/coding-rules.spec.js b/server/sonar-web/test/medium/coding-rules.spec.js index 1247b6cb763..849496b6ff6 100644 --- a/server/sonar-web/test/medium/coding-rules.spec.js +++ b/server/sonar-web/test/medium/coding-rules.spec.js @@ -971,5 +971,29 @@ define(function (require) { .checkElementExist('.coding-rules-detail-quality-profile-activate') .checkElementNotExist('.coding-rules-detail-quality-profile-deactivate'); }); + + bdd.it('should pre-select context profile in the activation modal', function () { + return this.remote + .open() + .mockFromString('/api/l10n/index', '{}') + .mockFromFile('/api/rules/app', 'coding-rules-spec/app.json') + .mockFromFile('/api/rules/search', 'coding-rules-spec/search.json') + .startApp('coding-rules') + .clickElement('[data-property="qprofile"] .js-facet-toggle') + .checkElementExist('.js-facet[data-value="java-default-with-mojo-conventions-49307"]') + .clearMocks() + .mockFromFile('/api/rules/search', 'coding-rules-spec/search-inactive.json') + .mockFromFile('/api/rules/show', 'coding-rules-spec/show-activate-profile.json') + .clickElement('.js-facet[data-value="java-findbugs-14954"]') + .clickElement('.js-facet[data-value="java-findbugs-14954"] .js-inactive') + .checkElementExist('.coding-rule.selected') + .clickElement('.coding-rule.selected .js-rule') + .checkElementExist('.coding-rules-detail-header') + .checkElementNotExist('.coding-rules-detail-quality-profile-name') + .checkElementExist('#coding-rules-quality-profile-activate') + .clickElement('#coding-rules-quality-profile-activate') + .checkElementExist('.modal') + .checkElementInclude('#coding-rules-quality-profile-activation-select option[selected]', 'FindBugs'); + }); }); }); -- 2.39.5