react 16 upgrade
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / onboard / filter / Filter.jsx
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
17 import { connect } from 'react-redux';
18 import React from 'react';
19 import PropTypes from 'prop-types';
20 import { tabsMapping as onboardTabsMapping } from '../OnboardConstants.js';
21 import { actionTypes } from './FilterConstants.js';
22
23 import Panel from 'sdc-ui/lib/react/Panel.js';
24 import {
25     ItemStatus,
26     ByVendorView,
27     EntityType,
28     Permissions,
29     OnboardingProcedure
30 } from './FilterComponents.jsx';
31
32 const mapStateToProps = ({ onboard: { filter, activeTab } }) => {
33     return {
34         data: filter,
35         activeTab
36     };
37 };
38
39 const mapActionsToProps = dispatch => {
40     return {
41         onDataChanged: deltaData => {
42             dispatch({
43                 type: actionTypes.FILTER_DATA_CHANGED,
44                 deltaData
45             });
46         }
47     };
48 };
49
50 const Filter = ({ onDataChanged, data, activeTab }) => {
51     return (
52         <Panel className="catalog-filter">
53             <ItemStatus data={data} onDataChanged={onDataChanged} />
54             <EntityType data={data} onDataChanged={onDataChanged} />
55             <Permissions data={data} onDataChanged={onDataChanged} />
56             <OnboardingProcedure data={data} onDataChanged={onDataChanged} />
57             {activeTab === onboardTabsMapping.CATALOG && (
58                 <ByVendorView data={data} onDataChanged={onDataChanged} />
59             )}
60         </Panel>
61     );
62 };
63
64 Filter.propTypes = {
65     onDataChanged: PropTypes.func,
66     data: PropTypes.object,
67     activeTab: PropTypes.number
68 };
69
70 export default connect(mapStateToProps, mapActionsToProps)(Filter);