react 16 upgrade
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / components / processes / SoftwareProductComponentProcessesList.js
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 import { connect } from 'react-redux';
17 import i18n from 'nfvo-utils/i18n/i18n.js';
18 import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
19 import SoftwareProductComponentProcessesActionHelper from './SoftwareProductComponentProcessesActionHelper.js';
20
21 import SoftwareProductComponentsProcessesListView from './SoftwareProductComponentsProcessesListView.jsx';
22
23 export const mapStateToProps = ({ softwareProduct }) => {
24     let {
25         softwareProductEditor: {
26             data: currentSoftwareProduct = {},
27             isValidityData = true
28         },
29         softwareProductComponents: { componentProcesses = {} }
30     } = softwareProduct;
31     let { processesList = [] } = componentProcesses;
32
33     return {
34         currentSoftwareProduct,
35         isValidityData,
36         processesList
37     };
38 };
39
40 const mapActionsToProps = (
41     dispatch,
42     { componentId, softwareProductId, version }
43 ) => {
44     return {
45         onAddProcess: () =>
46             SoftwareProductComponentProcessesActionHelper.openEditor(dispatch, {
47                 isReadOnlyMode: false,
48                 componentId,
49                 softwareProductId,
50                 version
51             }),
52         onEditProcess: (process, isReadOnlyMode) =>
53             SoftwareProductComponentProcessesActionHelper.openEditor(dispatch, {
54                 process,
55                 isReadOnlyMode,
56                 componentId,
57                 softwareProductId,
58                 version
59             }),
60         onDeleteProcess: process =>
61             dispatch({
62                 type: modalActionTypes.GLOBAL_MODAL_WARNING,
63                 data: {
64                     msg: i18n('Are you sure you want to delete "{name}"?', {
65                         name: process.name
66                     }),
67                     confirmationButtonText: i18n('Delete'),
68                     title: i18n('Delete'),
69                     onConfirmed: () =>
70                         SoftwareProductComponentProcessesActionHelper.deleteProcess(
71                             dispatch,
72                             { process, softwareProductId, version, componentId }
73                         )
74                 }
75             })
76     };
77 };
78
79 export default connect(mapStateToProps, mapActionsToProps, null, {
80     withRef: true
81 })(SoftwareProductComponentsProcessesListView);