summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-15 11:51:55 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-15 11:52:06 +0200
commite72ebb2c71eb46abda41ec2203185ce934c0d1bf (patch)
treeec4770cdfb839333f94f1ce98f91b8e29755d64e
parent32dcee49dc835eaeb9345c6558198f33f5d9efc7 (diff)
downloadsonarqube-e72ebb2c71eb46abda41ec2203185ce934c0d1bf.tar.gz
sonarqube-e72ebb2c71eb46abda41ec2203185ce934c0d1bf.zip
SONAR-6209 While in the profile context, activation modal should suggest selected profile first
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs3
-rw-r--r--server/sonar-web/test/medium/coding-rules.spec.js24
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}}
<select id="coding-rules-quality-profile-activation-select">
{{#each qualityProfiles}}
- <option value="{{key}}">{{name}}</option>
+ {{log ../contextProfile}}
+ <option value="{{key}}" {{#eq key ../contextProfile}}selected{{/eq}}>{{name}}</option>
{{/each}}
</select>
{{/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');
+ });
});
});