From: Wouter Admiraal Date: Mon, 8 Jun 2020 12:46:55 +0000 (+0200) Subject: SONAR-13355 Deleting an Application should redirect to the homepage X-Git-Tag: 8.4.0.35506~101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9266050ff354fe508082c7930538d5a2702fcd26;p=sonarqube.git SONAR-13355 Deleting an Application should redirect to the homepage --- diff --git a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx index 86af7437951..f179ec2fed2 100644 --- a/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx +++ b/server/sonar-web/src/main/js/apps/projectDeletion/Form.tsx @@ -24,6 +24,7 @@ import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n import { deletePortfolio, deleteProject } from '../../api/components'; import addGlobalSuccessMessage from '../../app/utils/addGlobalSuccessMessage'; import { Router, withRouter } from '../../components/hoc/withRouter'; +import { ComponentQualifier, isPortfolioLike } from '../../types/component'; interface Props { component: Pick; @@ -31,17 +32,18 @@ interface Props { } export class Form extends React.PureComponent { - handleDelete = () => { + handleDelete = async () => { const { component } = this.props; - const isProject = component.qualifier === 'TRK'; - const deleteMethod = isProject ? deleteProject : deletePortfolio; - const redirectTo = isProject ? '/' : '/portfolios'; - return deleteMethod(component.key).then(() => { - addGlobalSuccessMessage( - translateWithParameters('project_deletion.resource_deleted', component.name) - ); - this.props.router.replace(redirectTo); - }); + const deleteMethod = + component.qualifier === ComponentQualifier.Project ? deleteProject : deletePortfolio; + const redirectTo = isPortfolioLike(component.qualifier) ? '/portfolios' : '/'; + + await deleteMethod(component.key); + + addGlobalSuccessMessage( + translateWithParameters('project_deletion.resource_deleted', component.name) + ); + this.props.router.replace(redirectTo); }; render() {