aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api/quality-gates.ts
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-11-24 11:41:05 +0100
committerEric Hartmann <hartmann.eric@gmail.Com>2017-12-04 13:44:55 +0100
commit2907c50b0aaf6b323ab70b91a3aa4436ef323006 (patch)
tree241ec8fa257b9d55cabece0488d99f00fe72c948 /server/sonar-web/src/main/js/api/quality-gates.ts
parent7674a1465d06a513879ff09e66e0eb8746dcc837 (diff)
downloadsonarqube-2907c50b0aaf6b323ab70b91a3aa4436ef323006.tar.gz
sonarqube-2907c50b0aaf6b323ab70b91a3aa4436ef323006.zip
SONAR-10088 SONAR-10114 Allow/prevent QG actions based on list of authorized actions
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.ts46
1 files changed, 25 insertions, 21 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 325f181c7bb..b7eb009e7f1 100644
--- a/server/sonar-web/src/main/js/api/quality-gates.ts
+++ b/server/sonar-web/src/main/js/api/quality-gates.ts
@@ -20,32 +20,37 @@
import { getJSON, post, postJSON, RequestData } from '../helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
-export function fetchQualityGatesAppDetails(): Promise<any> {
- return getJSON('/api/qualitygates/app').catch(throwGlobalError);
+interface Condition {
+ error?: string;
+ id: number;
+ metric: string;
+ op: string;
+ period?: number;
+ warning?: string;
}
export interface QualityGate {
+ actions?: {
+ associateProjects: boolean;
+ copy: boolean;
+ edit: boolean;
+ setAsDefault: boolean;
+ };
+ conditions?: Condition[];
+ id: number;
isBuiltIn?: boolean;
isDefault?: boolean;
- id: number;
name: string;
}
-export function fetchQualityGates(): Promise<QualityGate[]> {
- return getJSON('/api/qualitygates/list').then(
- r =>
- r.qualitygates.map((qualityGate: any) => {
- return {
- ...qualityGate,
- id: qualityGate.id,
- isDefault: qualityGate.id === r.default
- };
- }),
- throwGlobalError
- );
+export function fetchQualityGates(): Promise<{
+ actions: { create: boolean };
+ qualitygates: QualityGate[];
+}> {
+ return getJSON('/api/qualitygates/list').catch(throwGlobalError);
}
-export function fetchQualityGate(id: string): Promise<any> {
+export function fetchQualityGate(id: string): Promise<QualityGate> {
return getJSON('/api/qualitygates/show', { id }).catch(throwGlobalError);
}
@@ -87,11 +92,10 @@ export function deleteCondition(id: string): Promise<void> {
export function getGateForProject(project: string): Promise<QualityGate | undefined> {
return getJSON('/api/qualitygates/get_by_project', { project }).then(
- r =>
- r.qualityGate && {
- id: r.qualityGate.id,
- isDefault: r.qualityGate.default,
- name: r.qualityGate.name
+ ({ qualityGate }) =>
+ qualityGate && {
+ ...qualityGate,
+ isDefault: qualityGate.default
}
);
}