]> source.dussan.org Git - sonarqube.git/commitdiff
delete portfolios with api/views/delete
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 22 Sep 2017 08:16:48 +0000 (10:16 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 25 Sep 2017 11:40:46 +0000 (13:40 +0200)
server/sonar-web/src/main/js/api/components.ts
server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js

index 42e3b05ea6ea2cf6f230dcdd8423c8821276ed4d..2d03c4f0db44cb983e03af012f81d57bdf0d5999 100644 (file)
@@ -61,8 +61,12 @@ export function bulkDeleteProjects(parameters: BaseSearchProjectsParameters): Pr
   return post('/api/projects/bulk_delete', parameters);
 }
 
-export function deleteProject(project: string): Promise<void> {
-  return post('/api/projects/delete', { project });
+export function deleteProject(project: string): Promise<void | Response> {
+  return post('/api/projects/delete', { project }).catch(throwGlobalError);
+}
+
+export function deletePortfolio(portfolio: string): Promise<void | Response> {
+  return post('/api/views/delete', { key: portfolio }).catch(throwGlobalError);
 }
 
 export function createProject(data: {
index e07afba43c5915c279418cdafdc771fcb976afda..c2dd276e85b8881af5a3e125c1473a183c163524 100644 (file)
@@ -20,7 +20,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import Modal from 'react-modal';
-import { deleteProject } from '../../../api/components';
+import { deleteProject, deletePortfolio } from '../../../api/components';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 
 export default class Form extends React.PureComponent {
@@ -58,7 +58,9 @@ export default class Form extends React.PureComponent {
   handleSubmit = event => {
     event.preventDefault();
     this.setState({ loading: true });
-    deleteProject(this.props.component.key)
+    const { component } = this.props;
+    const deleteMethod = component.qualifier === 'TRK' ? deleteProject : deletePortfolio;
+    deleteMethod(component.key)
       .then(() => this.context.router.replace('/'))
       .catch(this.stopLoading);
   };