blob: c045a3739a2259ae8f5ecf22963fd88f53d775da [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,
svishnev091edfd2018-03-19 12:15:19 +020063 archivedSoftwareProductList: PropTypes.array,
64 archivedLicenseModelList: PropTypes.array,
talig8e9c0652017-12-20 14:30:43 +020065 modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)),
66 onSelectLicenseModel: PropTypes.func.isRequired,
67 onSelectSoftwareProduct: PropTypes.func.isRequired,
68 onAddLicenseModelClick: PropTypes.func.isRequired,
69 onAddSoftwareProductClick: PropTypes.func.isRequired,
70 closeVspOverlay: PropTypes.func.isRequired,
71 onVspOverlayChange: PropTypes.func.isRequired,
72 onTabClick: PropTypes.func.isRequired,
73 onCatalogTabClick: PropTypes.func.isRequired,
74 onSearch: PropTypes.func.isRequired,
75 activeTab: PropTypes.number.isRequired,
76 catalogActiveTab: PropTypes.number.isRequired,
77 searchValue: PropTypes.string.isRequired,
78 onMigrate: PropTypes.func.isRequired,
AviZi280f8012017-06-09 02:39:56 +030079 };
80 renderViewByTab(activeTab){
81 switch (activeTab){
82 case tabsMapping.WORKSPACE:
83 return <WorkspaceView {...this.props} />;
84 case tabsMapping.CATALOG:
AviZi280f8012017-06-09 02:39:56 +030085 return <OnboardingCatalogView {...this.props} />;
svishnev091edfd2018-03-19 12:15:19 +020086 default:
87 return <WorkspaceView {...this.props} />;
AviZi280f8012017-06-09 02:39:56 +030088 }
89 }
90
91 render() {
talig8e9c0652017-12-20 14:30:43 +020092 let {activeTab, onTabClick, onSearch, searchValue} = this.props;
AviZi280f8012017-06-09 02:39:56 +030093 return (
talig8e9c0652017-12-20 14:30:43 +020094 <div className='catalog-view'>
svishnev14592282018-02-15 11:00:37 +020095 <Filter/>
96 <div className='catalog-parts'>
97 <OnboardHeader activeTab={activeTab} onTabClick={onTabClick} searchValue={searchValue} onSearch={value => onSearch(value)}/>
98 {this.renderViewByTab(activeTab)}
svishnev091edfd2018-03-19 12:15:19 +020099 </div>
AviZi280f8012017-06-09 02:39:56 +0300100 </div>
101 );
102 }
103}
104
105export default OnboardView;