From cf9eb2f6a2bc594e3007eff1494817a42a6f2d35 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 6 Feb 2018 16:11:41 +0100 Subject: rewrite groups app with react (#3017) --- server/sonar-web/src/main/js/api/user_groups.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'server/sonar-web/src/main/js/api') diff --git a/server/sonar-web/src/main/js/api/user_groups.ts b/server/sonar-web/src/main/js/api/user_groups.ts index 7fbddde3133..2e1b85c5cdf 100644 --- a/server/sonar-web/src/main/js/api/user_groups.ts +++ b/server/sonar-web/src/main/js/api/user_groups.ts @@ -17,7 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { getJSON, post } from '../helpers/request'; +import { getJSON, post, postJSON } from '../helpers/request'; +import { Paging, Group } from '../app/types'; +import throwGlobalError from '../app/utils/throwGlobalError'; export function searchUsersGroups(data: { f?: string; @@ -25,7 +27,7 @@ export function searchUsersGroups(data: { p?: number; ps?: number; q?: string; -}) { +}): Promise<{ groups: Group[]; paging: Paging }> { return getJSON('/api/user_groups/search', data); } @@ -46,3 +48,19 @@ export function removeUserFromGroup(data: { }) { return post('/api/user_groups/remove_user', data); } + +export function createGroup(data: { + description?: string; + organization: string | undefined; + name: string; +}): Promise { + return postJSON('/api/user_groups/create', data).then(r => r.group, throwGlobalError); +} + +export function updateGroup(data: { description?: string; id: number; name?: string }) { + return post('/api/user_groups/update', data).catch(throwGlobalError); +} + +export function deleteGroup(data: { name: string; organization: string | undefined }) { + return post('/api/user_groups/delete', data).catch(throwGlobalError); +} -- cgit v1.2.3