[sdc] docker file fix for cassandra
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / licenseModel / licenseKeyGroups / LicenseKeyGroupsConfirmationModal.jsx
1 import React from 'react';
2 import {connect} from 'react-redux';
3 import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx';
4 import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js';
5 import i18n from 'nfvo-utils/i18n/i18n.js';
6
7 function renderMsg(licenseKeyGroupToDelete) {
8         let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.name : '';
9         let msg = i18n('Are you sure you want to delete "{name}"?', {name});
10         let subMsg =  licenseKeyGroupToDelete
11                                         && licenseKeyGroupToDelete.referencingFeatureGroups
12                                         && licenseKeyGroupToDelete.referencingFeatureGroups.length > 0 ?
13                                         i18n('This license key group is associated with one or more feature groups') :
14                                         '';
15         return(
16                 <div>
17                         <p>{msg}</p>
18                         <p>{subMsg}</p>
19                 </div>
20         );
21 };
22
23 const mapStateToProps = ({licenseModel: {licenseKeyGroup}}, {licenseModelId}) => {
24         let {licenseKeyGroupToDelete} = licenseKeyGroup;
25         const show = licenseKeyGroupToDelete !== false;
26         return {
27                 show,
28                 title: 'Warning!',
29                 type: 'warning',
30                 msg: renderMsg(licenseKeyGroupToDelete),
31                 confirmationDetails: {licenseKeyGroupToDelete, licenseModelId}
32         };
33 };
34
35 const mapActionsToProps = (dispatch) => {
36         return {
37                 onConfirmed: ({licenseKeyGroupToDelete, licenseModelId}) => {
38
39                         LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroupToDelete.id});
40                         LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch);
41                 },
42                 onDeclined: () => {
43                         LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch);
44                 }
45         };
46 };
47
48 export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView);
49