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 i18n from 'nfvo-utils/i18n/i18n.js';
19 import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js';
20 import SoftwareProductComponentsImageListView from './SoftwareProductComponentsImageListView.jsx';
21 import ImageHelper from './SoftwareProductComponentsImageActionHelper.js';
22 import SoftwareProductComponentsImagesActionHelper from './SoftwareProductComponentsImageActionHelper.js';
23 import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js';
24 import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
25 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
27 import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js';
29 export const mapStateToProps = ({softwareProduct}) => {
31 let {softwareProductEditor: {data: currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct;
32 let {images: {imagesList = []}, componentEditor: {data: componentData, qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents;
33 let {onboardingMethod} = currentSoftwareProduct;
34 let isManual = onboardingMethod === onboardingMethodTypes.MANUAL;
47 const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => {
49 onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData,
50 qName: COMPONENTS_QUESTIONNAIRE}),
51 onAddImage: (isReadOnlyMode) => {
52 SoftwareProductComponentsImagesActionHelper.openImageEditor(dispatch,
53 {isReadOnlyMode, softwareProductId,
56 onDeleteImage: (image) => {
57 let shortenedFileName = (image.fileName.length > 40) ? image.fileName.substr(0,40) + '...' : image.fileName;
59 type: modalActionTypes.GLOBAL_MODAL_WARNING,
61 msg: i18n('Are you sure you want to delete "{shortenedFileName}"?', {shortenedFileName: shortenedFileName}),
62 onConfirmed: () => ImageHelper.deleteImage(dispatch, {
71 onEditImageClick: (image, isReadOnlyMode) => {
72 SoftwareProductComponentsImagesActionHelper.openEditImageEditor(dispatch, {
73 image, isReadOnlyMode, softwareProductId, componentId, version, modalClassName: 'image-modal-edit'}
76 onSubmit: (qdata) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch,
78 vspComponentId: componentId,
85 export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsImageListView);