diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-14 13:45:40 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-09-28 16:35:02 +0200 |
commit | 24b80b59a96988e27c6aae6234d7d00c22ebc262 (patch) | |
tree | 8dd2a34ce8ed3add3256b391c5113c5f122b1a6d /server/sonar-web/src/main/js/api/permissions.jsx | |
parent | 2634b3b9ed7c5601a886fa7ba8e3ad0cdc76c100 (diff) | |
download | sonarqube-24b80b59a96988e27c6aae6234d7d00c22ebc262.tar.gz sonarqube-24b80b59a96988e27c6aae6234d7d00c22ebc262.zip |
SONAR-6801 rewrite the permission templates page
Diffstat (limited to 'server/sonar-web/src/main/js/api/permissions.jsx')
-rw-r--r-- | server/sonar-web/src/main/js/api/permissions.jsx | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/server/sonar-web/src/main/js/api/permissions.jsx b/server/sonar-web/src/main/js/api/permissions.jsx index 3f4fc520ba7..29f4c4147d9 100644 --- a/server/sonar-web/src/main/js/api/permissions.jsx +++ b/server/sonar-web/src/main/js/api/permissions.jsx @@ -1,24 +1,24 @@ -function _request(options) { +function _request (options) { let $ = jQuery; return $.ajax(options); } -function _url(path) { +function _url (path) { return window.baseUrl + path; } -function _typeError(method, message) { +function _typeError (method, message) { throw new TypeError(`permissions#${method}: ${message}`); } -export function getUsers(data) { +export function getUsers (data) { let url = _url('/api/permissions/users'); return _request({ type: 'GET', url: url, data: data }); } -export function grantToUser(permission, user, project) { +export function grantToUser (permission, user, project) { if (typeof permission !== 'string' || !permission.length) { return _typeError('grantToUser', 'please provide permission'); } @@ -35,7 +35,7 @@ export function grantToUser(permission, user, project) { } -export function revokeFromUser(permission, user, project) { +export function revokeFromUser (permission, user, project) { if (typeof permission !== 'string' || !permission.length) { return _typeError('revokeFromUser', 'please provide permission'); } @@ -52,13 +52,13 @@ export function revokeFromUser(permission, user, project) { } -export function getGroups(data) { +export function getGroups (data) { let url = _url('/api/permissions/groups'); return _request({ type: 'GET', url: url, data: data }); } -export function grantToGroup(permission, group, project) { +export function grantToGroup (permission, group, project) { if (typeof permission !== 'string' || !permission.length) { return _typeError('grantToGroup', 'please provide permission'); } @@ -75,7 +75,7 @@ export function grantToGroup(permission, group, project) { } -export function revokeFromGroup(permission, group, project) { +export function revokeFromGroup (permission, group, project) { if (typeof permission !== 'string' || !permission.length) { return _typeError('revokeFromGroup', 'please provide permission'); } @@ -92,6 +92,44 @@ export function revokeFromGroup(permission, group, project) { } +export function getPermissionTemplates (query) { + let url = _url('/api/permissions/search_templates'); + let data = { }; + if (query) { + data.q = query; + } + return _request({ type: 'GET', url: url, data: data }); +} + + +export function createPermissionTemplate (options) { + let url = _url('/api/permissions/create_template'); + return _request(_.extend({ type: 'POST', url: url }, options)); +} + +export function updatePermissionTemplate (options) { + let url = _url('/api/permissions/update_template'); + return _request(_.extend({ type: 'POST', url: url }, options)); +} + + +export function deletePermissionTemplate (options) { + let url = _url('/api/permissions/delete_template'); + return _request(_.extend({ type: 'POST', url: url }, options)); +} + + +export function setDefaultPermissionTemplate (template, qualifier) { + if (typeof template !== 'string' || !template.length) { + return _typeError('setDefaultPermissionTemplate', 'please provide permission template ID'); + } + + let url = _url('/api/permissions/set_default_template'); + let data = { templateId: template, qualifier }; + return _request({ type: 'POST', url, data }); +} + + export function applyTemplateToProject(options) { let url = _url('/api/permissions/apply_template'); return _request(_.extend({ type: 'POST', url: url }, options)); |