blob: b7a7fa5f683bc1cf788779eefb788e506744dad9 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
16import React from 'react';
17import OnboardingCatalogView from './onboardingCatalog/OnboardingCatalogView.jsx';
18import WorkspaceView from './workspace/WorkspaceView.jsx';
19import {tabsMapping} from './OnboardConstants.js';
20import i18n from 'nfvo-utils/i18n/i18n.js';
21import classnames from 'classnames';
22import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx';
23import objectValues from 'lodash/values.js';
24import {catalogItemTypes} from './onboardingCatalog/OnboardingCatalogConstants.js';
25
26const OnboardHeaderTabs = ({onTabClick, activeTab}) => (
27 <div className='onboard-header-tabs'>
28 <div
29 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.WORKSPACE })}
30 onClick={() => onTabClick(tabsMapping.WORKSPACE)}
31 data-test-id='onboard-workspace-tab'>
32 {i18n('WORKSPACE')}
33 </div>
34 <div
35 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.CATALOG })}
36 onClick={() => onTabClick(tabsMapping.CATALOG)}
37 data-test-id='onboard-onboard-tab'>
38 {i18n('ONBOARD CATALOG')}
39 </div>
40 </div>
41);
42
43const OnboardHeader = ({onSearch, activeTab, onTabClick, searchValue}) => (
44 <div className='onboard-header'>
45 <OnboardHeaderTabs activeTab={activeTab} onTabClick={onTabClick} />
46 <ExpandableInput
47 onChange={onSearch}
48 iconType='search'
49 value={searchValue}/>
50 </div>
51);
52
53class OnboardView extends React.Component {
54 static propTypes = {
55 licenseModelList: React.PropTypes.array,
56 softwareProductList: React.PropTypes.array,
57 finalizedLicenseModelList: React.PropTypes.array,
58 finalizedSoftwareProductList: React.PropTypes.array,
59 modalToShow: React.PropTypes.oneOf(objectValues(catalogItemTypes)),
60 onSelectLicenseModel: React.PropTypes.func.isRequired,
61 onSelectSoftwareProduct: React.PropTypes.func.isRequired,
62 onAddLicenseModelClick: React.PropTypes.func.isRequired,
63 onAddSoftwareProductClick: React.PropTypes.func.isRequired,
64 closeVspOverlay: React.PropTypes.func.isRequired,
65 onVspOverlayChange: React.PropTypes.func.isRequired,
66 onTabClick: React.PropTypes.func.isRequired,
67 onCatalogTabClick: React.PropTypes.func.isRequired,
68 onSearch: React.PropTypes.func.isRequired,
69 activeTab: React.PropTypes.number.isRequired,
70 catalogActiveTab: React.PropTypes.number.isRequired,
71 searchValue: React.PropTypes.string.isRequired,
72 onMigrate: React.PropTypes.func.isRequired,
73 };
74 renderViewByTab(activeTab){
75 switch (activeTab){
76 case tabsMapping.WORKSPACE:
77 return <WorkspaceView {...this.props} />;
78 case tabsMapping.CATALOG:
79 default:
80 return <OnboardingCatalogView {...this.props} />;
81 }
82 }
83
84 render() {
85 let {closeVspOverlay, activeTab, onTabClick, onSearch, searchValue} = this.props;
86 return (
87 <div className='catalog-view' onClick={closeVspOverlay}>
88 <OnboardHeader activeTab={activeTab} onTabClick={onTabClick} searchValue={searchValue} onSearch={value => onSearch(value)}/>
89 {this.renderViewByTab(activeTab)}
90 </div>
91 );
92 }
93}
94
95export default OnboardView;