From 16bfb9c30dec69efa9c2e299e659ccc4ad201d54 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Mon, 12 Jun 2023 11:30:28 +0200 Subject: [PATCH] SONAR-19453 Improve async call handling --- .../apps/create/project/CreateProjectPage.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx index afa24320ec4..d2f52c438a6 100644 --- a/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/CreateProjectPage.tsx @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { noop } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { FormattedMessage } from 'react-intl'; @@ -65,6 +64,7 @@ interface State { isProjectSetupDone: boolean; creatingAlmDefinition?: AlmKeys; selectedNcd: NewCodePeriodWithCompliance | null; + submitting: boolean; } const PROJECT_MODE_FOR_ALM_KEY = { @@ -88,6 +88,7 @@ export class CreateProjectPage extends React.PureComponent { + handleProjectCreation = async () => { const { selectedNcd } = this.state; if (this.createProjectFnRef && selectedNcd) { - this.createProjectFnRef(selectedNcd.type, selectedNcd.value).then( - ({ project }) => this.handleProjectCreate(project.key), - noop - ); + this.setState({ submitting: true }); + + const { project } = await this.createProjectFnRef(selectedNcd.type, selectedNcd.value); + this.props.router.push(getProjectUrl(project.key)); + + this.setState({ submitting: false }); } }; @@ -328,10 +331,7 @@ export class CreateProjectPage extends React.PureComponent {translate('back')} - + {translate('onboarding.create_project.new_code_definition.create_project')} -- 2.39.5