blob: b21ea3ee809be5f0dbccce1427e7112135b307d0 [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
Yarin Dekel811fb482018-11-04 15:00:34 +02007 *
svishnev14592282018-02-15 11:00:37 +02008 * http://www.apache.org/licenses/LICENSE-2.0
Yarin Dekel811fb482018-11-04 15:00:34 +02009 *
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';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020020import { tabsMapping } from './OnboardConstants.js';
AviZi280f8012017-06-09 02:39:56 +030021import 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';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020025import { 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';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020028const OnboardHeaderTabs = ({ onTabClick, activeTab }) => (
29 <div className="onboard-header-tabs">
30 <div
31 className={classnames('onboard-header-tab', {
32 active: activeTab === tabsMapping.WORKSPACE
33 })}
34 onClick={() => onTabClick(tabsMapping.WORKSPACE)}
35 data-test-id="onboard-workspace-tab">
36 {i18n('WORKSPACE')}
37 </div>
38 <div
39 className={classnames('onboard-header-tab', {
40 active: activeTab === tabsMapping.CATALOG
41 })}
42 onClick={() => onTabClick(tabsMapping.CATALOG)}
43 data-test-id="onboard-onboard-tab">
44 {i18n('ONBOARD CATALOG')}
45 </div>
46 </div>
AviZi280f8012017-06-09 02:39:56 +030047);
48
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020049const OnboardHeader = ({ onSearch, activeTab, onTabClick, searchValue }) => (
50 <div className="onboard-header">
51 <OnboardHeaderTabs activeTab={activeTab} onTabClick={onTabClick} />
52 <ExpandableInput
53 onChange={onSearch}
54 iconType="search"
55 value={searchValue}
56 />
57 <NotificationsView />
58 </div>
AviZi280f8012017-06-09 02:39:56 +030059);
60
61class OnboardView extends React.Component {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020062 static propTypes = {
63 licenseModelList: PropTypes.array,
64 softwareProductList: PropTypes.array,
65 finalizedLicenseModelList: PropTypes.array,
66 finalizedSoftwareProductList: PropTypes.array,
67 archivedSoftwareProductList: PropTypes.array,
68 archivedLicenseModelList: PropTypes.array,
69 modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)),
70 onSelectLicenseModel: PropTypes.func.isRequired,
71 onSelectSoftwareProduct: PropTypes.func.isRequired,
72 onAddLicenseModelClick: PropTypes.func.isRequired,
73 onAddSoftwareProductClick: PropTypes.func.isRequired,
74 closeVspOverlay: PropTypes.func.isRequired,
75 onVspOverlayChange: PropTypes.func.isRequired,
76 onTabClick: PropTypes.func.isRequired,
77 onCatalogTabClick: PropTypes.func.isRequired,
78 onSearch: PropTypes.func.isRequired,
79 activeTab: PropTypes.number.isRequired,
80 catalogActiveTab: PropTypes.number.isRequired,
Yarin Dekel811fb482018-11-04 15:00:34 +020081 searchValue: PropTypes.object.isRequired,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020082 onMigrate: PropTypes.func.isRequired
83 };
84 renderViewByTab(activeTab) {
85 switch (activeTab) {
86 case tabsMapping.WORKSPACE:
svishnev8ae8f7e2018-07-02 14:05:17 +030087 return <WorkspaceView {...this.props} />;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020088 case tabsMapping.CATALOG:
svishnev8ae8f7e2018-07-02 14:05:17 +030089 return <OnboardingCatalogView {...this.props} />;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020090 default:
svishnev8ae8f7e2018-07-02 14:05:17 +030091 return <WorkspaceView {...this.props} />;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020092 }
93 }
AviZi280f8012017-06-09 02:39:56 +030094
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020095 render() {
Yarin Dekel811fb482018-11-04 15:00:34 +020096 let {
97 activeTab,
98 activeTabName,
99 onTabClick,
100 onSearch,
101 searchValue
102 } = this.props;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200103 return (
104 <div className="catalog-view">
105 <Filter />
106 <div className="catalog-parts">
107 <OnboardHeader
108 activeTab={activeTab}
109 onTabClick={onTabClick}
Yarin Dekel811fb482018-11-04 15:00:34 +0200110 searchValue={searchValue[activeTabName]}
111 onSearch={value => onSearch(value, activeTabName)}
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200112 />
113 {this.renderViewByTab(activeTab)}
114 </div>
115 </div>
116 );
117 }
AviZi280f8012017-06-09 02:39:56 +0300118}
119
120export default OnboardView;