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';
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') :
23 const mapStateToProps = ({licenseModel: {licenseKeyGroup}}, {licenseModelId}) => {
24 let {licenseKeyGroupToDelete} = licenseKeyGroup;
25 const show = licenseKeyGroupToDelete !== false;
30 msg: renderMsg(licenseKeyGroupToDelete),
31 confirmationDetails: {licenseKeyGroupToDelete, licenseModelId}
35 const mapActionsToProps = (dispatch) => {
37 onConfirmed: ({licenseKeyGroupToDelete, licenseModelId}) => {
39 LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroupToDelete.id});
40 LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch);
43 LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch);
48 export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView);