You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

application.ts 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import throwGlobalError from '../app/utils/throwGlobalError';
  21. import { getJSON, post, postJSON } from '../helpers/request';
  22. import { Application, ApplicationPeriod, ApplicationProject } from '../types/application';
  23. import { Visibility } from '../types/component';
  24. export function getApplicationLeak(
  25. application: string,
  26. branch?: string
  27. ): Promise<ApplicationPeriod[]> {
  28. return getJSON('/api/applications/show_leak', { application, branch }).then(
  29. r => r.leaks,
  30. throwGlobalError
  31. );
  32. }
  33. export function getApplicationDetails(application: string, branch?: string): Promise<Application> {
  34. return getJSON('/api/applications/show', { application, branch }).then(
  35. r => r.application,
  36. throwGlobalError
  37. );
  38. }
  39. export function addApplicationBranch(data: {
  40. application: string;
  41. branch: string;
  42. project: string[];
  43. projectBranch: string[];
  44. }) {
  45. return post('/api/applications/create_branch', data).catch(throwGlobalError);
  46. }
  47. export function updateApplicationBranch(data: {
  48. application: string;
  49. branch: string;
  50. name: string;
  51. project: string[];
  52. projectBranch: string[];
  53. }) {
  54. return post('/api/applications/update_branch', data).catch(throwGlobalError);
  55. }
  56. export function deleteApplicationBranch(application: string, branch: string) {
  57. return post('/api/applications/delete_branch', { application, branch }).catch(throwGlobalError);
  58. }
  59. export function getApplicationProjects(data: {
  60. application: string;
  61. p?: number;
  62. ps?: number;
  63. q?: string;
  64. selected: string;
  65. }): Promise<{ paging: T.Paging; projects: ApplicationProject[] }> {
  66. return getJSON('/api/applications/search_projects', data).catch(throwGlobalError);
  67. }
  68. export function addProjectToApplication(application: string, project: string) {
  69. return post('/api/applications/add_project', { application, project }).catch(throwGlobalError);
  70. }
  71. export function removeProjectFromApplication(application: string, project: string) {
  72. return post('/api/applications/remove_project', { application, project }).catch(throwGlobalError);
  73. }
  74. export function refreshApplication(key: string) {
  75. return post('/api/applications/refresh', { key }).catch(throwGlobalError);
  76. }
  77. export function createApplication(
  78. name: string,
  79. description: string,
  80. key: string | undefined,
  81. visibility: string
  82. ): Promise<{
  83. application: {
  84. description?: string;
  85. key: string;
  86. name: string;
  87. visibility: Visibility;
  88. };
  89. }> {
  90. return postJSON('/api/applications/create', { description, key, name, visibility }).catch(
  91. throwGlobalError
  92. );
  93. }
  94. export function deleteApplication(application: string) {
  95. return post('/api/applications/delete', { application }).catch(throwGlobalError);
  96. }
  97. export function editApplication(application: string, name: string, description: string) {
  98. return post('/api/applications/update', { name, description, application }).catch(
  99. throwGlobalError
  100. );
  101. }