]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8865 allow to change rules inside organization
authorStas Vilchik <vilchiks@gmail.com>
Wed, 3 May 2017 07:57:12 +0000 (09:57 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 3 May 2017 08:34:32 +0000 (10:34 +0200)
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js
server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-rule-meta.hbs

index b7c512a091b0a1f1322eca6e05fc4bc6bb9e3588..6bca7d2b32bad4298a1bdf1ce118e1e4223f7fed 100644 (file)
@@ -61,14 +61,18 @@ export default Marionette.ItemView.extend({
   submitExtendDescription() {
     const that = this;
     this.ui.extendDescriptionForm.addClass('hidden');
+    const data = {
+      key: this.model.get('key'),
+      markdown_note: this.ui.extendDescriptionText.val()
+    };
+    if (this.options.app.organization) {
+      data.organization = this.options.app.organization;
+    }
     return $.ajax({
       type: 'POST',
       url: window.baseUrl + '/api/rules/update',
       dataType: 'json',
-      data: {
-        key: this.model.get('key'),
-        markdown_note: this.ui.extendDescriptionText.val()
-      }
+      data
     })
       .done(r => {
         that.model.set({
@@ -97,7 +101,7 @@ export default Marionette.ItemView.extend({
     return {
       ...Marionette.ItemView.prototype.serializeData.apply(this, arguments),
       isCustom: this.model.get('isCustom'),
-      canCustomizeRule: this.options.app.canWrite && this.options.app.customRules
+      canCustomizeRule: this.options.app.canWrite
     };
   }
 });
index 5d33a109a92c66a42633a4cbcf9185d04e1aa2c9..68c9748e386f9744864419503f8fdcbdac2c95e6 100644 (file)
@@ -58,7 +58,10 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
 
   requestTags() {
     const url = window.baseUrl + '/api/rules/tags';
-    return $.get(url);
+    const data = this.options.app.organization
+      ? { organization: this.options.app.organization }
+      : undefined;
+    return $.get(url, data);
   },
 
   changeTags() {
@@ -88,13 +91,14 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
   editDone() {
     const that = this;
     const tags = this.ui.tagInput.val();
+    const data = { key: this.model.get('key'), tags };
+    if (this.options.app.organization) {
+      data.organization = this.options.app.organization;
+    }
     return $.ajax({
       type: 'POST',
       url: window.baseUrl + '/api/rules/update',
-      data: {
-        key: this.model.get('key'),
-        tags
-      }
+      data
     })
       .done(r => {
         that.model.set('tags', r.rule.tags);
@@ -112,7 +116,7 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
 
     return {
       ...Marionette.ItemView.prototype.serializeData.apply(this, arguments),
-      canCustomizeRule: this.options.app.canWrite && this.options.app.customRules,
+      canCustomizeRule: this.options.app.canWrite,
       allTags: union(this.model.get('sysTags'), this.model.get('tags')),
       permalink: window.baseUrl + permalinkPath + '#rule_key=' + encodeURIComponent(this.model.id)
     };
index 255f97fea0887e59a735e81ea8bfa8c832fd31aa..1b3603cdef449dacf543cfd638760ba38121576b 100644 (file)
@@ -38,7 +38,7 @@
       data-toggle="tooltip" data-placement="bottom" title="Rule tags">
     <i class="icon-tags"></i>
     <span>{{#if allTags}}{{join allTags ', '}}{{else}}{{t 'coding_rules.no_tags'}}{{/if}}</span>
-    {{#if canWrite}}<i class="icon-dropdown"></i>{{/if}}
+    {{#if canCustomizeRule}}<i class="icon-dropdown"></i>{{/if}}
   </li>
 
   {{#if canCustomizeRule}}