Upgrade Eslint & Prettier
[sdc/sdc-workflow-designer.git] / workflow-designer-ui / src / main / frontend / src / features / version / inputOutput / InputOutput.js
1 /*
2 * Copyright © 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
17 import { connect } from 'react-redux';
18 import {
19     showAlertModalAction,
20     hideModalAction
21 } from 'shared/modal/modalWrapperActions';
22
23 import {
24     getIsShowInputs,
25     getSearch,
26     getDataRows,
27     getTypes,
28     getError
29 } from 'features/version/inputOutput/inputOutputSelectors';
30 import { getIsCertified } from 'features/version/general/generalSelectors';
31 import {
32     changeError,
33     showInputs,
34     showOutputs,
35     search,
36     add,
37     changeName,
38     changeType,
39     changeMandatory,
40     remove
41 } from 'features/version/inputOutput/inputOutputActions';
42
43 import InputOutputView from 'features/version/inputOutput/InputOutputView';
44
45 const mapStateToProps = state => ({
46     isShowInputs: getIsShowInputs(state),
47     search: getSearch(state),
48     dataRows: getDataRows(state),
49     types: getTypes(state),
50     error: getError(state),
51     isCertified: getIsCertified(state)
52 });
53
54 const mapDispatchToProps = dispatch => ({
55     handleChangeError: payload => dispatch(changeError(payload)),
56     handleShowInputs: () => dispatch(showInputs()),
57     handleShowOutputs: () => dispatch(showOutputs()),
58     handleSearch: value => dispatch(search(value)),
59     handleAdd: () => dispatch(add()),
60     handleNameChange: (name, key) => dispatch(changeName(name, key)),
61     handleTypeChange: (type, key) => dispatch(changeType(type, key)),
62     handleMandatoryChange: (mandatory, key) =>
63         dispatch(changeMandatory(mandatory, key)),
64     handleRemove: (alertProps, key) => {
65         if (alertProps) {
66             return dispatch(
67                 showAlertModalAction({
68                     ...alertProps,
69                     withButtons: true,
70                     actionButtonClick: () =>
71                         dispatch(hideModalAction()) && dispatch(remove(key))
72                 })
73             );
74         }
75
76         return dispatch(remove(key));
77     }
78 });
79
80 export default connect(
81     mapStateToProps,
82     mapDispatchToProps
83 )(InputOutputView);