diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-04-03 17:42:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-03 17:42:32 +0200 |
commit | 43f11774c142d50ad32c6c507d541960f0ffcf4a (patch) | |
tree | b3c52144105a6279c64401c21e677e3c1676cb43 /server/sonar-web/src/main/js/apps | |
parent | 68af82a779fc632759c607d31ed6258a015a35c4 (diff) | |
download | sonarqube-43f11774c142d50ad32c6c507d541960f0ffcf4a.tar.gz sonarqube-43f11774c142d50ad32c6c507d541960f0ffcf4a.zip |
SONAR-9005 disable custom rules for custom orgs (#1895)
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
8 files changed, 35 insertions, 27 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js index de34c58dd33..865341fa43c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesAppContainer.js @@ -49,7 +49,11 @@ class CodingRulesAppContainer extends React.PureComponent { window.location.hash ); } else { - this.stop = init(this.refs.container, this.props.params.organizationKey); + this.stop = init( + this.refs.container, + this.props.params.organizationKey, + this.props.params.organizationKey === this.props.appState.defaultOrganization + ); } } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/init.js b/server/sonar-web/src/main/js/apps/coding-rules/init.js index 1a92814b70c..57e689c5178 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/init.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/init.js @@ -35,12 +35,15 @@ import FiltersView from './filters-view'; const App = new Marionette.Application(); -App.on('start', function(options: { el: HTMLElement, organization: ?string }) { +App.on('start', function(options: { + el: HTMLElement, + organization: ?string, + isDefaultOrganization: boolean +}) { const data = options.organization ? { organization: options.organization } : {}; $.get(window.baseUrl + '/api/rules/app', data) .done(r => { - App.canCreateCustomRule = r.canCreateCustomRule; - App.canCustomizeRule = r.canCustomizeRule; + App.customRules = options.organization == null || options.isDefaultOrganization; App.canWrite = r.canWrite; App.organization = options.organization; App.qualityProfiles = sortBy(r.qualityprofiles, ['name', 'lang']); @@ -56,7 +59,23 @@ App.on('start', function(options: { el: HTMLElement, organization: ?string }) { this.layout.render(); $('#footer').addClass('search-navigator-footer'); - this.state = new State(); + const allFacets = [ + 'q', + 'rule_key', + 'languages', + 'types', + 'tags', + 'repositories', + 'severities', + 'statuses', + 'available_since', + App.customRules ? 'is_template' : null, + 'qprofile', + 'inheritance', + 'active_severities' + ].filter(f => f != null); + + this.state = new State({ allFacets }); this.list = new Rules(); this.facets = new Facets(); @@ -94,8 +113,8 @@ App.on('start', function(options: { el: HTMLElement, organization: ?string }) { }); }); -export default function(el: HTMLElement, organization: ?string) { - App.start({ el, organization }); +export default function(el: HTMLElement, organization: ?string, isDefaultOrganization: boolean) { + App.start({ el, organization, isDefaultOrganization }); return () => { // $FlowFixMe diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/state.js b/server/sonar-web/src/main/js/apps/coding-rules/models/state.js index 301401f84c2..6e03e8df1ac 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/state.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/state.js @@ -25,21 +25,6 @@ export default State.extend({ maxResultsReached: false, query: {}, facets: ['types', 'languages'], - allFacets: [ - 'q', - 'rule_key', - 'languages', - 'types', - 'tags', - 'repositories', - 'severities', - 'statuses', - 'available_since', - 'is_template', - 'qprofile', - 'inheritance', - 'active_severities' - ], facetsFromServer: [ 'languages', 'repositories', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js index 11ed2ef6b74..307765e54c6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js @@ -171,7 +171,7 @@ export default Marionette.LayoutView.extend({ serializeData() { const isCustom = this.model.has('templateKey'); - const isEditable = this.options.app.canCustomizeRule && isCustom; + const isEditable = this.options.app.canWrite && this.options.app.customRules && isCustom; let qualityProfilesVisible = true; if (this.model.get('isTemplate')) { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js index 295590a3bcb..adffbd3f0d1 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js @@ -47,7 +47,7 @@ export default Marionette.ItemView.extend({ serializeData() { return { ...Marionette.ItemView.prototype.serializeData.apply(this, arguments), - canDeleteCustomRule: this.options.app.canCreateCustomRule, + canDeleteCustomRule: this.options.app.customRules && this.options.app.canWrite, templateRule: this.options.templateRule, permalink: window.baseUrl + '/coding_rules/#rule_key=' + encodeURIComponent(this.model.id) }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js index d6ec8a461cd..3fe997dfbf1 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js @@ -56,7 +56,7 @@ export default Marionette.CompositeView.extend({ serializeData() { return { ...Marionette.ItemView.prototype.serializeData.apply(this, arguments), - canCreateCustomRule: this.options.app.canCreateCustomRule + canCreateCustomRule: this.options.app.customRules && this.options.app.canWrite }; } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js index 0e942ef4bfb..b7c512a091b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js @@ -97,7 +97,7 @@ export default Marionette.ItemView.extend({ return { ...Marionette.ItemView.prototype.serializeData.apply(this, arguments), isCustom: this.model.get('isCustom'), - canCustomizeRule: this.options.app.canCustomizeRule + canCustomizeRule: this.options.app.canWrite && this.options.app.customRules }; } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js index 0a0b22ade85..5d33a109a92 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js @@ -112,7 +112,7 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({ return { ...Marionette.ItemView.prototype.serializeData.apply(this, arguments), - canCustomizeRule: this.options.app.canCustomizeRule, + canCustomizeRule: this.options.app.canWrite && this.options.app.customRules, allTags: union(this.model.get('sysTags'), this.model.get('tags')), permalink: window.baseUrl + permalinkPath + '#rule_key=' + encodeURIComponent(this.model.id) }; |