d78f3bc7bd91c1780b2523515af41649a3a0cb11
[sdc/sdc-workflow-designer.git] / workflow-designer-ui / src / main / frontend / src / features / version / create / CreateVersion.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 import { connect } from 'react-redux';
17 import { withRouter } from 'react-router-dom';
18
19 import { hideModalAction } from 'shared/modal/modalWrapperActions';
20 import CreateVersionView from 'features/version/create/CreateVersionView';
21 import {
22     newVersionAction,
23     submitVersionAction
24 } from 'features/version/create/createVersionConstants';
25 import {
26     getWorkflowId,
27     getLatestBaseId
28 } from 'features/workflow/overview/overviewSelectors';
29
30 function mapStateToProps(state) {
31     return {
32         workflowId: getWorkflowId(state),
33         baseVersionId: getLatestBaseId(state)
34     };
35 }
36
37 function mapDispatchToProps(dispatch) {
38     return {
39         submitNewVersion: payload => {
40             dispatch(submitVersionAction(payload));
41             dispatch(hideModalAction());
42         },
43         closeCreateVersionModal: () => dispatch(hideModalAction()),
44         versionDetailsChanged: payload => dispatch(newVersionAction(payload))
45     };
46 }
47
48 export default withRouter(
49     connect(mapStateToProps, mapDispatchToProps)(CreateVersionView)
50 );