blob: f64c1e55fae1efe989685b251ae9d7daa1fd73e4 [file] [log] [blame]
svishnev14592282018-02-15 11:00:37 +02001/*
2 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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
svishnev14592282018-02-15 11:00:37 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
AviZi280f8012017-06-09 02:39:56 +030010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev14592282018-02-15 11:00:37 +020012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
16import React from 'react';
talig8e9c0652017-12-20 14:30:43 +020017import PropTypes from 'prop-types';
AviZi280f8012017-06-09 02:39:56 +030018import OnboardingCatalogView from './onboardingCatalog/OnboardingCatalogView.jsx';
19import WorkspaceView from './workspace/WorkspaceView.jsx';
20import {tabsMapping} from './OnboardConstants.js';
21import i18n from 'nfvo-utils/i18n/i18n.js';
22import classnames from 'classnames';
23import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx';
24import objectValues from 'lodash/values.js';
25import {catalogItemTypes} from './onboardingCatalog/OnboardingCatalogConstants.js';
talig8e9c0652017-12-20 14:30:43 +020026import NotificationsView from 'sdc-app/onboarding/userNotifications/NotificationsView.jsx';
svishnev14592282018-02-15 11:00:37 +020027import Filter from 'sdc-app/onboarding/onboard/filter/Filter.jsx';
AviZi280f8012017-06-09 02:39:56 +030028
29const OnboardHeaderTabs = ({onTabClick, activeTab}) => (
30 <div className='onboard-header-tabs'>
31 <div
32 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.WORKSPACE })}
33 onClick={() => onTabClick(tabsMapping.WORKSPACE)}
34 data-test-id='onboard-workspace-tab'>
35 {i18n('WORKSPACE')}
36 </div>
37 <div
38 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.CATALOG })}
39 onClick={() => onTabClick(tabsMapping.CATALOG)}
40 data-test-id='onboard-onboard-tab'>
41 {i18n('ONBOARD CATALOG')}
42 </div>
43 </div>
44);
45
46const OnboardHeader = ({onSearch, activeTab, onTabClick, searchValue}) => (
47 <div className='onboard-header'>
48 <OnboardHeaderTabs activeTab={activeTab} onTabClick={onTabClick} />
49 <ExpandableInput
50 onChange={onSearch}
51 iconType='search'
52 value={searchValue}/>
talig8e9c0652017-12-20 14:30:43 +020053 <NotificationsView />
AviZi280f8012017-06-09 02:39:56 +030054 </div>
55);
56
57class OnboardView extends React.Component {
58 static propTypes = {
talig8e9c0652017-12-20 14:30:43 +020059 licenseModelList: PropTypes.array,
60 softwareProductList: PropTypes.array,
61 finalizedLicenseModelList: PropTypes.array,
62 finalizedSoftwareProductList: PropTypes.array,
63 modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)),
64 onSelectLicenseModel: PropTypes.func.isRequired,
65 onSelectSoftwareProduct: PropTypes.func.isRequired,
66 onAddLicenseModelClick: PropTypes.func.isRequired,
67 onAddSoftwareProductClick: PropTypes.func.isRequired,
68 closeVspOverlay: PropTypes.func.isRequired,
69 onVspOverlayChange: PropTypes.func.isRequired,
70 onTabClick: PropTypes.func.isRequired,
71 onCatalogTabClick: PropTypes.func.isRequired,
72 onSearch: PropTypes.func.isRequired,
73 activeTab: PropTypes.number.isRequired,
74 catalogActiveTab: PropTypes.number.isRequired,
75 searchValue: PropTypes.string.isRequired,
76 onMigrate: PropTypes.func.isRequired,
AviZi280f8012017-06-09 02:39:56 +030077 };
78 renderViewByTab(activeTab){
79 switch (activeTab){
80 case tabsMapping.WORKSPACE:
81 return <WorkspaceView {...this.props} />;
82 case tabsMapping.CATALOG:
83 default:
84 return <OnboardingCatalogView {...this.props} />;
85 }
86 }
87
88 render() {
talig8e9c0652017-12-20 14:30:43 +020089 let {activeTab, onTabClick, onSearch, searchValue} = this.props;
AviZi280f8012017-06-09 02:39:56 +030090 return (
talig8e9c0652017-12-20 14:30:43 +020091 <div className='catalog-view'>
svishnev14592282018-02-15 11:00:37 +020092 <Filter/>
93 <div className='catalog-parts'>
94 <OnboardHeader activeTab={activeTab} onTabClick={onTabClick} searchValue={searchValue} onSearch={value => onSearch(value)}/>
95 {this.renderViewByTab(activeTab)}
96 </div>
AviZi280f8012017-06-09 02:39:56 +030097 </div>
98 );
99 }
100}
101
102export default OnboardView;