aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-09-22 10:16:48 +0200
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-09-25 13:40:46 +0200
commit929e5560d960ea4b682852db2187b93926a215e0 (patch)
treeb34131a4226ed076796eaef4a624bd4d148b66d6
parentaa838eba54111b32b619f75e6adb9e1a6c44e9ad (diff)
downloadsonarqube-929e5560d960ea4b682852db2187b93926a215e0.tar.gz
sonarqube-929e5560d960ea4b682852db2187b93926a215e0.zip
delete portfolios with api/views/delete
-rw-r--r--server/sonar-web/src/main/js/api/components.ts8
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js6
2 files changed, 10 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/api/components.ts b/server/sonar-web/src/main/js/api/components.ts
index 42e3b05ea6e..2d03c4f0db4 100644
--- a/server/sonar-web/src/main/js/api/components.ts
+++ b/server/sonar-web/src/main/js/api/components.ts
@@ -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: {
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js
index e07afba43c5..c2dd276e85b 100644
--- a/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js
@@ -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);
};