Skip to content

Commit

Permalink
Merge pull request #836 from Jithmi004/main
Browse files Browse the repository at this point in the history
Disable create new version button while handling submit
  • Loading branch information
tharikaGitHub authored Nov 25, 2024
2 parents 5866cbb + 0f3a3fc commit ea4f985
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class CreateNewVersion extends React.Component {
MaxLengthExceeds: false,
},
},
isLoading: false,
};
}

Expand Down Expand Up @@ -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;
Expand All @@ -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',
Expand All @@ -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: ',
Expand All @@ -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',
Expand All @@ -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: ',
Expand Down Expand Up @@ -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 <Redirect to={(api.apiType === 'APIPRODUCT' ? '/api-products/' : '/apis/') + apiId + '/overview'} />;
Expand Down Expand Up @@ -448,6 +460,7 @@ class CreateNewVersion extends React.Component {
|| valid.version.hasSpecialChars
|| valid.version.MaxLengthExceeds
|| api.isRevision
|| isLoading
}
>
<FormattedMessage
Expand Down

0 comments on commit ea4f985

Please sign in to comment.