blob: f31ce4c80583b8d484937051918d2b1688a0f6b6 [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';
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';
AviZi280f8012017-06-09 02:39:56 +030027
28const OnboardHeaderTabs = ({onTabClick, activeTab}) => (
29 <div className='onboard-header-tabs'>
30 <div
31 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.WORKSPACE })}
32 onClick={() => onTabClick(tabsMapping.WORKSPACE)}
33 data-test-id='onboard-workspace-tab'>
34 {i18n('WORKSPACE')}
35 </div>
36 <div
37 className={classnames('onboard-header-tab', {'active': activeTab === tabsMapping.CATALOG })}
38 onClick={() => onTabClick(tabsMapping.CATALOG)}
39 data-test-id='onboard-onboard-tab'>
40 {i18n('ONBOARD CATALOG')}
41 </div>
42 </div>
43);
44
45const OnboardHeader = ({onSearch, activeTab, onTabClick, searchValue}) => (
46 <div className='onboard-header'>
47 <OnboardHeaderTabs activeTab={activeTab} onTabClick={onTabClick} />
48 <ExpandableInput
49 onChange={onSearch}
50 iconType='search'
51 value={searchValue}/>
talig8e9c0652017-12-20 14:30:43 +020052 <NotificationsView />
AviZi280f8012017-06-09 02:39:56 +030053 </div>
54);
55
56class OnboardView extends React.Component {
57 static propTypes = {
talig8e9c0652017-12-20 14:30:43 +020058 licenseModelList: PropTypes.array,
59 softwareProductList: PropTypes.array,
60 finalizedLicenseModelList: PropTypes.array,
61 finalizedSoftwareProductList: PropTypes.array,
62 modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)),
63 onSelectLicenseModel: PropTypes.func.isRequired,
64 onSelectSoftwareProduct: PropTypes.func.isRequired,
65 onAddLicenseModelClick: PropTypes.func.isRequired,
66 onAddSoftwareProductClick: PropTypes.func.isRequired,
67 closeVspOverlay: PropTypes.func.isRequired,
68 onVspOverlayChange: PropTypes.func.isRequired,
69 onTabClick: PropTypes.func.isRequired,
70 onCatalogTabClick: PropTypes.func.isRequired,
71 onSearch: PropTypes.func.isRequired,
72 activeTab: PropTypes.number.isRequired,
73 catalogActiveTab: PropTypes.number.isRequired,
74 searchValue: PropTypes.string.isRequired,
75 onMigrate: PropTypes.func.isRequired,
AviZi280f8012017-06-09 02:39:56 +030076 };
77 renderViewByTab(activeTab){
78 switch (activeTab){
79 case tabsMapping.WORKSPACE:
80 return <WorkspaceView {...this.props} />;
81 case tabsMapping.CATALOG:
82 default:
83 return <OnboardingCatalogView {...this.props} />;
84 }
85 }
86
87 render() {
talig8e9c0652017-12-20 14:30:43 +020088 let {activeTab, onTabClick, onSearch, searchValue} = this.props;
AviZi280f8012017-06-09 02:39:56 +030089 return (
talig8e9c0652017-12-20 14:30:43 +020090 <div className='catalog-view'>
AviZi280f8012017-06-09 02:39:56 +030091 <OnboardHeader activeTab={activeTab} onTabClick={onTabClick} searchValue={searchValue} onSearch={value => onSearch(value)}/>
92 {this.renderViewByTab(activeTab)}
93 </div>
94 );
95 }
96}
97
98export default OnboardView;