react 16 upgrade
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / processes / SoftwareProductProcesses.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
20 import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper.js';
21 import SoftwareProductProcessesView from './SoftwareProductProcessesView.jsx';
22
23 export const mapStateToProps = ({ softwareProduct }) => {
24     let {
25         softwareProductEditor: { data: currentSoftwareProduct = {} },
26         softwareProductProcesses: { processesList, processesEditor }
27     } = softwareProduct;
28     let { data } = processesEditor;
29
30     return {
31         currentSoftwareProduct,
32         processesList,
33         isDisplayEditor: Boolean(data),
34         isModalInEditMode: Boolean(data && data.id)
35     };
36 };
37
38 const mapActionsToProps = (dispatch, { softwareProductId, version }) => {
39     return {
40         onAddProcess: () =>
41             SoftwareProductProcessesActionHelper.openEditor(dispatch, {
42                 softwareProductId,
43                 version,
44                 isReadOnlyMode: false
45             }),
46         onEditProcess: (process, isReadOnlyMode) =>
47             SoftwareProductProcessesActionHelper.openEditor(dispatch, {
48                 process,
49                 softwareProductId,
50                 version,
51                 isReadOnlyMode
52             }),
53         onDeleteProcess: process =>
54             dispatch({
55                 type: modalActionTypes.GLOBAL_MODAL_WARNING,
56                 data: {
57                     msg: i18n('Are you sure you want to delete "{name}"?', {
58                         name: process.name
59                     }),
60                     confirmationButtonText: i18n('Delete'),
61                     title: i18n('Delete'),
62                     onConfirmed: () =>
63                         SoftwareProductProcessesActionHelper.deleteProcess(
64                             dispatch,
65                             {
66                                 process,
67                                 softwareProductId,
68                                 version
69                             }
70                         )
71                 }
72             })
73     };
74 };
75
76 export default connect(mapStateToProps, mapActionsToProps, null, {
77     withRef: true
78 })(SoftwareProductProcessesView);