aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api/quality-gates.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/api/quality-gates.ts')
-rw-r--r--server/sonar-web/src/main/js/api/quality-gates.ts25
1 files changed, 21 insertions, 4 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 b07f1a89104..2839607c23c 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -24,11 +24,21 @@ export function fetchQualityGatesAppDetails(): Promise<any> {
return getJSON('/api/qualitygates/app').catch(throwGlobalError);
}
-export function fetchQualityGates(): Promise<any> {
+export interface QualityGate {
+ isDefault?: boolean;
+ id: string;
+ name: string;
+}
+
+export function fetchQualityGates(): Promise<QualityGate[]> {
return getJSON('/api/qualitygates/list').then(
r =>
r.qualitygates.map((qualityGate: any) => {
- return { ...qualityGate, isDefault: qualityGate.id === r.default };
+ return {
+ ...qualityGate,
+ id: String(qualityGate.id),
+ isDefault: qualityGate.id === r.default
+ };
}),
throwGlobalError
);
@@ -74,8 +84,15 @@ export function deleteCondition(id: string): Promise<void> {
return post('/api/qualitygates/delete_condition', { id });
}
-export function getGateForProject(projectKey: string): Promise<any> {
- return getJSON('/api/qualitygates/get_by_project', { projectKey }).then(r => r.qualityGate);
+export function getGateForProject(projectKey: string): Promise<QualityGate | undefined> {
+ return getJSON('/api/qualitygates/get_by_project', { projectKey }).then(
+ r =>
+ r.qualityGate && {
+ id: r.qualityGate.id,
+ isDefault: r.qualityGate.default,
+ name: r.qualityGate.name
+ }
+ );
}
export function associateGateWithProject(