aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api/quality-gates.js
blob: edab4f545ea4315979e360a129800272573381e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * SonarQube
 * Copyright (C) 2009-2016 SonarSource SA
 * mailto:contact AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * 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, postJSON } from '../helpers/request';

export function fetchQualityGatesAppDetails () {
  const url = '/api/qualitygates/app';

  return getJSON(url);
}

export function fetchQualityGates () {
  const url = '/api/qualitygates/list';

  return getJSON(url).then(r => r.qualitygates.map(qualityGate => {
    return {
      ...qualityGate,
      isDefault: qualityGate.id === r.default
    };
  }));
}

export function fetchQualityGate (id) {
  const url = '/api/qualitygates/show';
  return getJSON(url, { id });
}

export function createQualityGate (name) {
  const url = '/api/qualitygates/create';
  return postJSON(url, { name });
}

export function deleteQualityGate (id) {
  const url = '/api/qualitygates/destroy';
  return post(url, { id });
}

export function renameQualityGate (id, name) {
  const url = '/api/qualitygates/rename';
  return post(url, { id, name });
}

export function copyQualityGate (id, name) {
  const url = '/api/qualitygates/copy';
  return postJSON(url, { id, name });
}

export function setQualityGateAsDefault (id) {
  const url = '/api/qualitygates/set_as_default';
  return post(url, { id });
}

export function unsetQualityGateAsDefault (id) {
  const url = '/api/qualitygates/unset_default';
  return post(url, { id });
}

export function createCondition (gateId, condition) {
  const url = '/api/qualitygates/create_condition';
  return postJSON(url, { ...condition, gateId });
}

export function updateCondition (condition) {
  const url = '/api/qualitygates/update_condition';
  return postJSON(url, { ...condition });
}

export function deleteCondition (id) {
  const url = '/api/qualitygates/delete_condition';
  return post(url, { id });
}

export function getGateForProject (projectKey) {
  const url = '/api/qualitygates/get_by_project';
  const data = { projectKey };
  return getJSON(url, data).then(r => r.qualityGate);
}

export function associateGateWithProject(gateId, projectKey) {
  const url = '/api/qualitygates/select';
  const data = { gateId, projectKey };
  return post(url, data);
}

export function dissociateGateWithProject(gateId, projectKey) {
  const url = '/api/qualitygates/deselect';
  const data = { gateId, projectKey };
  return post(url, data);
}