Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable create new version button while handling submit #836

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading