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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
20 import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js';
21 import SoftwareProductComponentsImageListView from './SoftwareProductComponentsImageListView.jsx';
22 import ImageHelper from './SoftwareProductComponentsImageActionHelper.js';
23 import SoftwareProductComponentsImagesActionHelper from './SoftwareProductComponentsImageActionHelper.js';
24 import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js';
25 import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
26 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
28 import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js';
30 export const mapStateToProps = ({softwareProduct}) => {
32 let {softwareProductEditor: {data: currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct;
33 let {images: {imagesList = []}, componentEditor: {data: componentData, qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents;
34 let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct);
35 let {version, onboardingMethod} = currentSoftwareProduct;
36 let isManual = onboardingMethod === onboardingMethodTypes.MANUAL;
51 const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => {
53 onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData,
54 qName: COMPONENTS_QUESTIONNAIRE}),
55 onAddImage: (version, isReadOnlyMode) => {
56 SoftwareProductComponentsImagesActionHelper.openImageEditor(dispatch,
57 {isReadOnlyMode, softwareProductId,
60 onDeleteImage: ((image, version) => {
61 let shortenedFileName = (image.fileName.length > 40) ? image.fileName.substr(0,40) + '...' : image.fileName;
63 type: modalActionTypes.GLOBAL_MODAL_WARNING,
65 msg: i18n(`Are you sure you want to delete "${shortenedFileName}"?`),
66 onConfirmed: () => ImageHelper.deleteImage(dispatch, {
75 onEditImageClick: (image, version, isReadOnlyMode) => {
76 SoftwareProductComponentsImagesActionHelper.openEditImageEditor(dispatch, {
77 image, isReadOnlyMode, softwareProductId, componentId, version, modalClassName: 'image-modal-edit'}
80 onSubmit: ({qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch,
82 vspComponentId: componentId,
88 export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsImageListView);