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 i18n from 'nfvo-utils/i18n/i18n.js';
19 import SoftwareProductComponentsActionHelper from '../components/SoftwareProductComponentsActionHelper.js';
20 import { onboardingMethod as onboardingMethodTypes } from '../SoftwareProductConstants.js';
21 import ConfirmationModalConstants from 'nfvo-components/modal/GlobalModalConstants.js';
22 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
23 import { screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
24 import SoftwareProductComponentsView from './SoftwareProductComponentsListView.jsx';
25 import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
27 const generateMessage = name => {
28 return i18n('Are you sure you want to delete {name}?', { name: name });
31 const mapStateToProps = ({
33 currentScreen: { props: { version } }
36 softwareProductEditor: { data: currentSoftwareProduct = {} },
37 softwareProductComponents
39 let { componentsList } = softwareProductComponents;
41 onboardingMethod = onboardingMethodTypes.HEAT
42 } = currentSoftwareProduct;
44 currentSoftwareProduct,
46 isManual: onboardingMethod === onboardingMethodTypes.MANUAL,
51 const mapActionToProps = dispatch => {
53 onComponentSelect: ({ id: softwareProductId, componentId, version }) =>
54 ScreensHelper.loadScreen(dispatch, {
55 screen: screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL,
56 screenType: screenTypes.SOFTWARE_PRODUCT,
57 props: { softwareProductId, version, componentId }
59 onAddComponent: (softwareProductId, version) =>
60 SoftwareProductActionHelper.addComponent(dispatch, {
64 onDeleteComponent: (component, softwareProductId, version) =>
66 type: ConfirmationModalConstants.GLOBAL_MODAL_WARNING,
68 msg: generateMessage(component.displayName),
70 SoftwareProductComponentsActionHelper.deleteComponent(
74 componentId: component.id,
83 export default connect(mapStateToProps, mapActionToProps, null, {
85 })(SoftwareProductComponentsView);