summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/onboarding/softwareProduct
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-02-23 21:09:56 +0000
committerandre.schmid <andre.schmid@est.tech>2022-03-03 10:41:23 +0000
commit3dcbae860f1a4bc8e6596cddc9cb19611d0c3dc7 (patch)
tree01a34ad9bdc56a437632752ba3d1aedcaf5d0db2 /openecomp-ui/src/sdc-app/onboarding/softwareProduct
parentc4a8271d664deb39e69fbba329b11ff57b9b276b (diff)
Obtain upload lock before uploading
Before uploading, the system will now set the status as uploading in order to have more control of the upload process and status. Without that the UI status updates could show up incorrectly. Also, this behaviour removes the need to upload a file to set the upload in progress, which avoids a concurrent upload try to upload a file if there is another upload in progress. Change-Id: Ic008560aa57e1ee7a50389ad26f1a8890f1cf198 Issue-ID: SDC-3888 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct')
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js10
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js81
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx9
3 files changed, 76 insertions, 24 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js
index 3364edfe11..90bf9f9f08 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js
@@ -366,6 +366,16 @@ const SoftwareProductActionHelper = {
);
},
+ createUploadStatus(vspId, versionId) {
+ const options = {
+ noLoading: true
+ };
+ return RestAPIUtil.post(
+ `${baseUrl()}${vspId}/versions/${versionId}/orchestration-template-candidate/upload`,
+ options
+ );
+ },
+
loadSoftwareProductAssociatedData(dispatch) {
fetchSoftwareProductCategories(dispatch);
fetchModelList(dispatch);
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js
index 4b4c2fa86b..07a59eded3 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js
@@ -22,6 +22,7 @@ import { onboardingMethod } from '../SoftwareProductConstants.js';
import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
import VNFImportActionHelper from '../vnfMarketPlace/VNFImportActionHelper.js';
+import VspUploadStatus from 'sdc-app/onboarding/softwareProduct/landingPage/VspUploadStatus';
export const mapStateToProps = ({
features,
@@ -120,16 +121,34 @@ const mapActionsToProps = (dispatch, { version }) => {
// do nothing by default
}
) => {
- SoftwareProductActionHelper.uploadFile(dispatch, {
+ SoftwareProductActionHelper.createUploadStatus(
softwareProductId,
- formData,
- failedNotificationTitle: i18n('Upload validation failed'),
- version,
- onUploadProgress
- }).finally(() => {
- onUploadFinished();
- });
- onUploadStart();
+ version.id
+ )
+ .then(response => {
+ const vspUploadStatus = new VspUploadStatus(response);
+ onUploadStart(vspUploadStatus);
+ SoftwareProductActionHelper.uploadFile(dispatch, {
+ softwareProductId,
+ formData,
+ failedNotificationTitle: i18n(
+ 'Upload validation failed'
+ ),
+ version,
+ onUploadProgress
+ }).finally(() => {
+ onUploadFinished();
+ });
+ })
+ .catch(error => {
+ dispatch({
+ type: modalActionTypes.GLOBAL_MODAL_ERROR,
+ data: {
+ title: i18n('upload.failed'),
+ msg: error.message
+ }
+ });
+ });
},
onUploadConfirmation: (
@@ -152,19 +171,39 @@ const mapActionsToProps = (dispatch, { version }) => {
confirmationButtonText: i18n('Continue'),
title: i18n('Warning'),
onConfirmed: () => {
- SoftwareProductActionHelper.uploadFile(dispatch, {
+ SoftwareProductActionHelper.createUploadStatus(
softwareProductId,
- formData,
- failedNotificationTitle: i18n(
- 'Upload validation failed'
- ),
- version,
- onUploadProgress
- }).finally(value => {
- console.log('upload finished', value);
- onUploadFinished();
- });
- onUploadStart();
+ version.id
+ )
+ .then(response => {
+ const vspUploadStatus = new VspUploadStatus(
+ response
+ );
+ onUploadStart(vspUploadStatus);
+ SoftwareProductActionHelper.uploadFile(
+ dispatch,
+ {
+ softwareProductId,
+ formData,
+ failedNotificationTitle: i18n(
+ 'Upload validation failed'
+ ),
+ version,
+ onUploadProgress
+ }
+ ).finally(() => {
+ onUploadFinished();
+ });
+ })
+ .catch(error => {
+ dispatch({
+ type: modalActionTypes.GLOBAL_MODAL_ERROR,
+ data: {
+ title: i18n('upload.failed'),
+ msg: error.message
+ }
+ });
+ });
},
onDeclined: () =>
dispatch({
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx
index c560a73db3..64032863c7 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx
@@ -261,7 +261,10 @@ class SoftwareProductLandingPageView extends React.Component {
}
}
- onUploadStart = () => {
+ onUploadStart = vspUploadStatus => {
+ this.setState({
+ uploadStatus: vspUploadStatus
+ });
this.stopUploadStatusChecking();
this.showProgressBar();
};
@@ -324,7 +327,7 @@ class SoftwareProductLandingPageView extends React.Component {
onUploadConfirmation(
currentSoftwareProduct.id,
formData,
- () => this.onUploadStart(),
+ vspUploadStatus => this.onUploadStart(vspUploadStatus),
this.onUploadProgress,
this.onUploadFinished
);
@@ -332,7 +335,7 @@ class SoftwareProductLandingPageView extends React.Component {
onUpload(
currentSoftwareProduct.id,
formData,
- () => this.onUploadStart(),
+ vspUploadStatus => this.onUploadStart(vspUploadStatus),
this.onUploadProgress,
this.onUploadFinished
);