From 139facb4c713471036fe72f00bdfa1e86ee33f5e Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 12 Oct 2017 16:03:13 +0200 Subject: [PATCH] SONAR-8303 Create new rule from template with custom rule type --- .../coding-rules/rule/custom-rule-creation-view.js | 12 +++++++++++- .../rule/coding-rules-custom-rule-creation.hbs | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js index 194bb2cf823..7e95d520be4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js @@ -33,6 +33,7 @@ export default ModalFormView.extend({ customRuleCreationKey: '#coding-rules-custom-rule-creation-key', customRuleCreationName: '#coding-rules-custom-rule-creation-name', customRuleCreationHtmlDescription: '#coding-rules-custom-rule-creation-html-description', + customRuleCreationType: '#coding-rules-custom-rule-creation-type', customRuleCreationSeverity: '#coding-rules-custom-rule-creation-severity', customRuleCreationStatus: '#coding-rules-custom-rule-creation-status', customRuleCreationParameters: '[name]', @@ -85,11 +86,18 @@ export default ModalFormView.extend({ return ` ${state.text}`; } }; + const type = (this.model && this.model.get('type')) || this.options.templateRule.get('type'); const severity = (this.model && this.model.get('severity')) || this.options.templateRule.get('severity'); const status = (this.model && this.model.get('status')) || this.options.templateRule.get('status'); + this.ui.customRuleCreationType.val(type); + this.ui.customRuleCreationType.select2({ + width: '250px', + minimumResultsForSearch: 999 + }); + this.ui.customRuleCreationSeverity.val(severity); this.ui.customRuleCreationSeverity.select2({ width: '250px', @@ -111,6 +119,7 @@ export default ModalFormView.extend({ const options = { name: this.ui.customRuleCreationName.val(), markdown_description: this.ui.customRuleCreationHtmlDescription.val(), + type: this.ui.customRuleCreationType.val(), severity: this.ui.customRuleCreationSeverity.val(), status: this.ui.customRuleCreationStatus.val() }; @@ -208,7 +217,8 @@ export default ModalFormView.extend({ params, statuses, change: this.model && this.model.has('key'), - severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'] + severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'], + types: ['BUG', 'VULNERABILITY', 'CODE_SMELL'] }; } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-custom-rule-creation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-custom-rule-creation.hbs index 93f2a770390..389522453af 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-custom-rule-creation.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-custom-rule-creation.hbs @@ -37,6 +37,16 @@ {{> '../../../../components/common/templates/_markdown-tips' }} + +

{{t 'type'}}

+ + + +

{{t 'severity'}}