From 357f081c442b97df2accd2e860ee8cf1534e8ecb Mon Sep 17 00:00:00 2001 From: Jithmi004 Date: Thu, 7 Nov 2024 10:15:02 +0530 Subject: [PATCH] Disable create new version button while handling submit --- .../Apis/Details/NewVersion/NewVersion.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/NewVersion/NewVersion.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/NewVersion/NewVersion.jsx index 9fac77d9f39..becee9a4bb1 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/NewVersion/NewVersion.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/NewVersion/NewVersion.jsx @@ -137,6 +137,7 @@ class CreateNewVersion extends React.Component { MaxLengthExceeds: false, }, }, + isLoading: false, }; } @@ -200,6 +201,7 @@ class CreateNewVersion extends React.Component { this.setState({ valid: { version: { empty: true } } }); return; } + this.setState({ isLoading: true }); const isDefaultVersionBool = isDefaultVersion === 'yes'; const apiClient = new API(); const { intl } = this.props; @@ -209,6 +211,7 @@ class CreateNewVersion extends React.Component { this.setState({ redirectToReferrer: true, apiId: response.obj.id, + isLoading: false, }); Alert.info(intl.formatMessage({ id: 'Apis.Details.APIProduct.NewVersion.NewVersion.success', @@ -217,8 +220,12 @@ class CreateNewVersion extends React.Component { }) .catch((error) => { if (error.status === 409) { - this.setState({ valid: { version: { alreadyExists: true } } }); + this.setState({ + valid: { version: { alreadyExists: true } }, + isLoading: false, + }); } else { + this.setState({ isLoading: false }); Alert.error(intl.formatMessage({ id: 'Apis.Details.APIProduct.NewVersion.NewVersion.error', defaultMessage: 'Something went wrong while creating a new version!. Error: ', @@ -231,6 +238,7 @@ class CreateNewVersion extends React.Component { this.setState({ redirectToReferrer: true, apiId: response.obj.id, + isLoading: false, }); Alert.info(intl.formatMessage({ id: 'Apis.Details.NewVersion.NewVersion.success', @@ -239,8 +247,12 @@ class CreateNewVersion extends React.Component { }) .catch((error) => { if (error.status === 409) { - this.setState({ valid: { version: { alreadyExists: true } } }); + this.setState({ + valid: { version: { alreadyExists: true } }, + isLoading: false, + }); } else { + this.setState({ isLoading: false }); Alert.error(intl.formatMessage({ id: 'Apis.Details.NewVersion.NewVersion.error', defaultMessage: 'Something went wrong while creating a new version!. Error: ', @@ -279,7 +291,7 @@ class CreateNewVersion extends React.Component { render() { const { api, intl } = this.props; const { - isDefaultVersion, newVersion, redirectToReferrer, apiId, valid, serviceVersion, versionList, + isDefaultVersion, newVersion, redirectToReferrer, apiId, valid, serviceVersion, versionList, isLoading } = this.state; if (redirectToReferrer) { return ; @@ -448,6 +460,7 @@ class CreateNewVersion extends React.Component { || valid.version.hasSpecialChars || valid.version.MaxLengthExceeds || api.isRevision + || isLoading } >