aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api
diff options
context:
space:
mode:
authorPascal Mugnier <pascal.mugnier@sonarsource.com>2018-03-16 16:21:29 +0100
committerSonarTech <sonartech@sonarsource.com>2018-03-22 12:37:48 +0100
commitaf09abd297eee6694b088437f7f33bea210b82f0 (patch)
tree6aba521089c4228b464154873ca250042560cfe7 /server/sonar-web/src/main/js/api
parent8335168f11c4b8b6bd905e3a883c001352ab234d (diff)
downloadsonarqube-af09abd297eee6694b088437f7f33bea210b82f0.tar.gz
sonarqube-af09abd297eee6694b088437f7f33bea210b82f0.zip
Rewrite SelectList component in React on Quality Page (#3152)
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts16
-rw-r--r--server/sonar-web/src/main/js/api/quality-profiles.ts23
-rw-r--r--server/sonar-web/src/main/js/api/user_groups.ts24
-rw-r--r--server/sonar-web/src/main/js/api/users.ts21
4 files changed, 73 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/api/quality-gates.ts b/server/sonar-web/src/main/js/api/quality-gates.ts
index b40e6130b28..fc72234b27e 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -133,10 +133,21 @@ export function getGateForProject(data: {
);
}
+export function searchGates(data: {
+ gateId: number;
+ organization?: string;
+ page: number;
+ pageSize: number;
+ selected: string;
+}): Promise<void | Response> {
+ return getJSON('/api/qualitygates/search', data).catch(throwGlobalError);
+}
+
export function associateGateWithProject(data: {
gateId: number;
organization?: string;
- projectKey: string;
+ projectKey?: string;
+ projectId?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/select', data).catch(throwGlobalError);
}
@@ -144,7 +155,8 @@ export function associateGateWithProject(data: {
export function dissociateGateWithProject(data: {
gateId: number;
organization?: string;
- projectKey: string;
+ projectKey?: string;
+ projectId?: string;
}): Promise<void | Response> {
return post('/api/qualitygates/deselect', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/api/quality-profiles.ts b/server/sonar-web/src/main/js/api/quality-profiles.ts
index e589638ac76..bf8fc2b3eeb 100644
--- a/server/sonar-web/src/main/js/api/quality-profiles.ts
+++ b/server/sonar-web/src/main/js/api/quality-profiles.ts
@@ -107,7 +107,16 @@ export function restoreQualityProfile(data: RequestData): Promise<any> {
.then(parseJSON);
}
-export function getProfileProjects(data: RequestData): Promise<any> {
+export interface ProfileProject {
+ id: number;
+ key: string;
+ name: string;
+ selected: boolean;
+}
+
+export function getProfileProjects(
+ data: RequestData
+): Promise<{ more: boolean; results: ProfileProject[] }> {
return getJSON('/api/qualityprofiles/projects', data).catch(throwGlobalError);
}
@@ -153,12 +162,16 @@ export function compareProfiles(leftKey: string, rightKey: string): Promise<any>
return getJSON('/api/qualityprofiles/compare', { leftKey, rightKey });
}
-export function associateProject(profileKey: string, projectKey: string): Promise<void> {
- return post('/api/qualityprofiles/add_project', { profileKey, projectKey });
+export function associateProject(profileKey: string, projectKey: string) {
+ return post('/api/qualityprofiles/add_project', { profileKey, projectKey }).catch(
+ throwGlobalError
+ );
}
-export function dissociateProject(profileKey: string, projectKey: string): Promise<void> {
- return post('/api/qualityprofiles/remove_project', { profileKey, projectKey });
+export function dissociateProject(profileKey: string, projectKey: string) {
+ return post('/api/qualityprofiles/remove_project', { profileKey, projectKey }).catch(
+ throwGlobalError
+ );
}
export interface SearchUsersGroupsParameters {
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 2e1b85c5cdf..eadd920a5f0 100644
--- a/server/sonar-web/src/main/js/api/user_groups.ts
+++ b/server/sonar-web/src/main/js/api/user_groups.ts
@@ -28,7 +28,25 @@ export function searchUsersGroups(data: {
ps?: number;
q?: string;
}): Promise<{ groups: Group[]; paging: Paging }> {
- return getJSON('/api/user_groups/search', data);
+ return getJSON('/api/user_groups/search', data).catch(throwGlobalError);
+}
+
+export interface GroupUser {
+ login: string;
+ name: string;
+ selected: boolean;
+}
+
+export function getUsersInGroup(data: {
+ id?: number;
+ name?: string;
+ organization?: string;
+ p?: number;
+ ps?: number;
+ q?: string;
+ selected?: string;
+}): Promise<{ paging: Paging; users: GroupUser[] }> {
+ return getJSON('/api/user_groups/users', data).catch(throwGlobalError);
}
export function addUserToGroup(data: {
@@ -37,7 +55,7 @@ export function addUserToGroup(data: {
login?: string;
organization?: string;
}) {
- return post('/api/user_groups/add_user', data);
+ return post('/api/user_groups/add_user', data).catch(throwGlobalError);
}
export function removeUserFromGroup(data: {
@@ -46,7 +64,7 @@ export function removeUserFromGroup(data: {
login?: string;
organization?: string;
}) {
- return post('/api/user_groups/remove_user', data);
+ return post('/api/user_groups/remove_user', data).catch(throwGlobalError);
}
export function createGroup(data: {
diff --git a/server/sonar-web/src/main/js/api/users.ts b/server/sonar-web/src/main/js/api/users.ts
index b8667f54e38..055be31081f 100644
--- a/server/sonar-web/src/main/js/api/users.ts
+++ b/server/sonar-web/src/main/js/api/users.ts
@@ -33,11 +33,30 @@ export function changePassword(data: {
return post('/api/users/change_password', data);
}
-export function getUserGroups(login: string, organization?: string): Promise<any> {
+export interface UserGroup {
+ default: boolean;
+ description: string;
+ id: number;
+ name: string;
+ selected: boolean;
+}
+
+export function getUserGroups(
+ login: string,
+ organization?: string,
+ query?: string,
+ selected?: string
+): Promise<{ paging: Paging; groups: UserGroup[] }> {
const data: RequestData = { login };
if (organization) {
data.organization = organization;
}
+ if (query) {
+ data.q = query;
+ }
+ if (selected) {
+ data.selected = selected;
+ }
return getJSON('/api/users/groups', data);
}