aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageUploadConfirmationModal.jsx
blob: 4a848834b2c99876e881700a113fb44125873236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {connect} from 'react-redux';
import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx';
import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';

import i18n from 'nfvo-utils/i18n/i18n.js';

const mapStateToProps = ({softwareProduct}) => {
	let {softwareProductEditor} = softwareProduct;
	let {uploadData} = softwareProductEditor;
	const show = uploadData ? true : false;
	return {
		show,
		title: 'Warning!',
		type: 'warning',
		msg: i18n('Upload will erase existing data. Do you want to continue?'),
		confirmationDetails: {uploadData}
	};
};

const mapActionsToProps = (dispatch) => {
	return {
		onConfirmed: ({uploadData}) => {
			let {softwareProductId, formData, failedNotificationTitle} = uploadData;
			SoftwareProductActionHelper.uploadFile(dispatch, {
				softwareProductId,
				formData,
				failedNotificationTitle
			});
			SoftwareProductActionHelper.hideUploadConfirm(dispatch);
		},
		onDeclined: () => {
			SoftwareProductActionHelper.hideUploadConfirm(dispatch);
		}
	};
};

export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView);