2 * Copyright © 2016-2018 European Support Limited
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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import { connect } from 'react-redux';
17 import SoftwareProductComponentsNetworkActionHelper from './SoftwareProductComponentsNetworkActionHelper.js';
18 import SoftwareProductComponentsNICEditorView from './SoftwareProductComponentsNICEditorView.jsx';
19 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
20 import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
21 import { NIC_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js';
22 import { onboardingMethod as onboardingMethodTypes } from '../../SoftwareProductConstants.js';
24 export const mapStateToProps = ({ softwareProduct, currentScreen }) => {
26 softwareProductEditor: {
27 data: currentSoftwareProduct = {},
30 softwareProductComponents
32 let { network: { nicEditor = {} } } = softwareProductComponents;
41 let { props: { isReadOnlyMode } } = currentScreen;
42 let { onboardingMethod } = currentSoftwareProduct;
47 qdata.protocols.protocols &&
48 qdata.protocols.protocols.length
50 protocols = qdata.protocols.protocols;
52 let { version } = currentSoftwareProduct;
54 ValidationHelper.checkFormValid(genericFieldInfo) &&
55 ValidationHelper.checkFormValid(qgenericFieldInfo);
58 currentSoftwareProduct,
70 isManual: onboardingMethod === onboardingMethodTypes.MANUAL
74 const mapActionsToProps = (
76 { softwareProductId, componentId, version }
79 onDataChanged: deltaData =>
80 ValidationHelper.dataChanged(dispatch, {
82 formName: forms.NIC_EDIT_FORM
84 onSubmit: ({ data, qdata }) =>
85 SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(
87 { softwareProductId, version, componentId, data, qdata }
90 SoftwareProductComponentsNetworkActionHelper.closeNICEditor(
94 ValidationHelper.validateForm(dispatch, forms.NIC_EDIT_FORM),
95 onQDataChanged: deltaData =>
96 ValidationHelper.qDataChanged(dispatch, {
98 qName: NIC_QUESTIONNAIRE
103 export default connect(mapStateToProps, mapActionsToProps)(
104 SoftwareProductComponentsNICEditorView