diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-09-26 14:41:01 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-02 17:18:15 +0200 |
commit | 6a3ae4ac87b1e12a9bcd496c57bb6e2918cc345e (patch) | |
tree | 38f63a05fdf9797438a600544a3fdacd789c7615 /server/sonar-web/src/main/js/apps/coding-rules/init.js | |
parent | 77d3e365acbfd9095efe4458c643a9e8ccdada13 (diff) | |
download | sonarqube-6a3ae4ac87b1e12a9bcd496c57bb6e2918cc345e.tar.gz sonarqube-6a3ae4ac87b1e12a9bcd496c57bb6e2918cc345e.zip |
SONAR-1330 Allow rule changes only for quality profile admins
Diffstat (limited to 'server/sonar-web/src/main/js/apps/coding-rules/init.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/coding-rules/init.js | 25 |
1 files changed, 13 insertions, 12 deletions
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 36d7f608fda..ed38639c9e0 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 @@ -32,6 +32,8 @@ import Router from '../../components/navigator/router'; import WorkspaceListView from './workspace-list-view'; import WorkspaceHeaderView from './workspace-header-view'; import FacetsView from './facets-view'; +import { searchQualityProfiles } from '../../api/quality-profiles'; +import { getRulesApp } from '../../api/rules'; import { areThereCustomOrganizations } from '../../store/organizations/utils'; const App = new Marionette.Application(); @@ -45,20 +47,16 @@ App.on('start', function( ) { App.organization = options.organization; const data = options.organization ? { organization: options.organization } : {}; - $.get(window.baseUrl + '/api/rules/app', data) - .done(r => { + Promise.all([getRulesApp(data), searchQualityProfiles(data)]) + .then(([appResponse, profilesResponse]) => { App.customRules = !areThereCustomOrganizations(); - App.canWrite = r.canWrite; + App.canWrite = appResponse.canWrite; App.organization = options.organization; - App.qualityProfiles = sortBy(r.qualityprofiles, ['name', 'lang']); - App.languages = { ...r.languages, none: 'None' }; - App.qualityProfiles.forEach(profile => { - profile.language = App.languages[profile.lang]; - }); - App.repositories = r.repositories; - App.statuses = r.statuses; - }) - .done(() => { + App.qualityProfiles = sortBy(profilesResponse.profiles, ['name', 'lang']); + App.languages = { ...appResponse.languages, none: 'None' }; + App.repositories = appResponse.repositories; + App.statuses = appResponse.statuses; + this.layout = new Layout({ el: options.el }); this.layout.render(); $('#footer').addClass('page-footer-with-sidebar'); @@ -109,6 +107,9 @@ App.on('start', function( app: this }); Backbone.history.start(); + }) + .catch(() => { + // do nothing in case of WS error }); }); |