2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import {connect} from 'react-redux';
17 import SoftwareProductDeploymentEditorView from './SoftwareProductDeploymentEditorView.jsx';
18 import SoftwareProdcutDeploymentActionHelper from '../SoftwareProductDeploymentActionHelper.js';
19 import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
20 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
22 import {DEPLOYMENT_FLAVORS_FORM_NAME} from '../SoftwareProductDeploymentConstants.js';
24 export function mapStateToProps({licenseModel, softwareProduct}) {
26 softwareProductEditor: {
27 data: currentSoftwareProduct = {}
29 softwareProductComponents: {
35 softwareProductDeployment: {
37 deploymentFlavorEditor: {
51 let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct);
52 let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo);
53 let selectedFeatureGroupsIds = currentSoftwareProduct.licensingData ? currentSoftwareProduct.licensingData.featureGroups || [] : [];
54 let selectedFeatureGroupsList = featureGroupsList
55 .filter(featureGroup => selectedFeatureGroupsIds.includes(featureGroup.id))
56 .map(featureGroup => ({value: featureGroup.id, label: featureGroup.name}));
60 deploymentFlavors.map(deployment => {
61 DFNames[deployment.model] = deployment.id;
66 selectedFeatureGroupsList,
74 isEdit: Boolean(data.id)
78 function mapActionsToProps(dispatch, {softwareProductId, version}) {
80 onDataChanged: (deltaData, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: DEPLOYMENT_FLAVORS_FORM_NAME, customValidations}),
81 onClose: () => SoftwareProdcutDeploymentActionHelper.closeDeploymentFlavorEditor(dispatch),
82 onCreate: data => SoftwareProdcutDeploymentActionHelper.createDeploymentFlavor(dispatch, {softwareProductId, data, version}),
83 onEdit: data => SoftwareProdcutDeploymentActionHelper.editDeploymentFlavor(dispatch, {softwareProductId, deploymentFlavorId: data.id, data, version}),
84 onValidateForm: () => ValidationHelper.validateForm(dispatch, DEPLOYMENT_FLAVORS_FORM_NAME)
88 export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductDeploymentEditorView);