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