2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import {connect} from 'react-redux';
23 import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
24 import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
25 import SoftwareProductDetailsView from './SoftwareProductDetailsView.jsx';
27 export const mapStateToProps = ({finalizedLicenseModelList, softwareProduct, licenseModel: {licenseAgreement, featureGroup}}) => {
28 let {softwareProductEditor: {data: currentSoftwareProduct}, softwareProductCategories, softwareProductQuestionnaire} = softwareProduct;
29 let {licensingData = {}, licensingVersion} = currentSoftwareProduct;
30 let licenseAgreementList = [], filteredFeatureGroupsList = [];
31 if(licensingVersion && licensingVersion !== '') {
32 licenseAgreementList = licenseAgreement.licenseAgreementList;
33 let selectedLicenseAgreement = licenseAgreementList.find(la => la.id === licensingData.licenseAgreement);
34 if (selectedLicenseAgreement) {
35 let featureGroupsList = featureGroup.featureGroupsList.filter(({referencingLicenseAgreements}) => referencingLicenseAgreements.includes(selectedLicenseAgreement.id));
36 if (featureGroupsList.length) {
37 filteredFeatureGroupsList = featureGroupsList.map(featureGroup => ({enum: featureGroup.id, title: featureGroup.name}));
41 let {qdata, qschema} = softwareProductQuestionnaire;
42 let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct);
45 currentSoftwareProduct,
46 softwareProductCategories,
48 featureGroupsList: filteredFeatureGroupsList,
49 finalizedLicenseModelList,
56 export const mapActionsToProps = (dispatch) => {
58 onDataChanged: deltaData => SoftwareProductActionHelper.softwareProductEditorDataChanged(dispatch, {deltaData}),
59 onVendorParamChanged: deltaData => SoftwareProductActionHelper.softwareProductEditorVendorChanged(dispatch, {deltaData}),
60 onQDataChanged: ({data}) => SoftwareProductActionHelper.softwareProductQuestionnaireUpdate(dispatch, {data}),
61 onValidityChanged: isValidityData => SoftwareProductActionHelper.setIsValidityData(dispatch, {isValidityData}),
62 onSubmit: (softwareProduct, qdata) =>{ return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata});}
66 export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductDetailsView);