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 ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
18 import SoftwareProductComponentsImageActionHelper from './SoftwareProductComponentsImageActionHelper.js';
19 import SoftwareProductComponentsImageEditorView from './SoftwareProductComponentsImageEditorView.jsx';
20 import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js';
21 import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
22 import {IMAGE_QUESTIONNAIRE} from './SoftwareProductComponentsImageConstants.js';
24 export const mapStateToProps = ({
26 currentScreen: {props: {isReadOnlyMode}}
29 let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct;
31 let {images: {imageEditor = {}}} = softwareProductComponents;
32 let {data, qdata, genericFieldInfo, qgenericFieldInfo, dataMap, formReady} = imageEditor;
33 let {version, onboardingMethod} = currentSoftwareProduct;
34 let isManual = onboardingMethod === onboardingMethodTypes.MANUAL;
35 let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo) && ValidationHelper.checkFormValid(qgenericFieldInfo);
39 currentSoftwareProduct,
54 const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => {
56 onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: forms.IMAGE_EDIT_FORM}),
57 onSubmit: ({data, qdata}) => SoftwareProductComponentsImageActionHelper.saveImageDataAndQuestionnaire(dispatch, {softwareProductId, componentId, version, data, qdata}),
58 onCancel: () => SoftwareProductComponentsImageActionHelper.closeImageEditor(dispatch),
59 onValidateForm: customValidations => {
60 ValidationHelper.validateForm(dispatch, forms.IMAGE_EDIT_FORM);
61 ValidationHelper.qValidateForm(dispatch, IMAGE_QUESTIONNAIRE, customValidations);
63 onQDataChanged: (deltaData, customValidations) => ValidationHelper.qDataChanged(dispatch, {deltaData,
64 qName: IMAGE_QUESTIONNAIRE, customValidations}),
68 export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductComponentsImageEditorView);