aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-06-09 14:49:05 +0200
committerStas Vilchik <vilchiks@gmail.com>2016-06-09 14:49:05 +0200
commit9ddbcb00f8f3a6b6a85d4e1bf68d0edea0d45df5 (patch)
tree2e188bff86ed45b3a31b3c414b9862a90dc1d8e0 /server/sonar-web/src/main/js/api
parent6b35da5b5dc82f89d62109a2556ffdc520e7e08e (diff)
downloadsonarqube-9ddbcb00f8f3a6b6a85d4e1bf68d0edea0d45df5.tar.gz
sonarqube-9ddbcb00f8f3a6b6a85d4e1bf68d0edea0d45df5.zip
refactor permission templates page (#1025)
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r--server/sonar-web/src/main/js/api/permissions.js29
1 files changed, 16 insertions, 13 deletions
diff --git a/server/sonar-web/src/main/js/api/permissions.js b/server/sonar-web/src/main/js/api/permissions.js
index 03f723e56d1..4139c0f7c56 100644
--- a/server/sonar-web/src/main/js/api/permissions.js
+++ b/server/sonar-web/src/main/js/api/permissions.js
@@ -19,6 +19,7 @@
*/
import $ from 'jquery';
import _ from 'underscore';
+import { getJSON, post } from '../helpers/request';
function request (options) {
return $.ajax(options);
@@ -102,13 +103,13 @@ export function revokeFromGroup (permission, group, project) {
return request({ type: 'POST', url, data });
}
-export function getPermissionTemplates (query) {
+/**
+ * Get list of permission templates
+ * @returns {Promise}
+ */
+export function getPermissionTemplates () {
const url = window.baseUrl + '/api/permissions/search_templates';
- const data = { };
- if (query) {
- data.q = query;
- }
- return request({ type: 'GET', url, data });
+ return getJSON(url);
}
export function createPermissionTemplate (options) {
@@ -126,14 +127,16 @@ export function deletePermissionTemplate (options) {
return request(_.extend({ type: 'POST', url }, options));
}
-export function setDefaultPermissionTemplate (template, qualifier) {
- if (typeof template !== 'string' || !template.length) {
- return typeError('setDefaultPermissionTemplate', 'please provide permission template ID');
- }
-
+/**
+ * Set default permission template for a given qualifier
+ * @param {string} templateName
+ * @param {string} qualifier
+ * @returns {Promise}
+ */
+export function setDefaultPermissionTemplate (templateName, qualifier) {
const url = window.baseUrl + '/api/permissions/set_default_template';
- const data = { templateId: template, qualifier };
- return request({ type: 'POST', url, data });
+ const data = { templateName, qualifier };
+ return post(url, data);
}
export function applyTemplateToProject (options) {