blob: dcaeaa787d029dc49c910582144b250b5d961227 [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';
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';
AviZi280f8012017-06-09 02:39:56 +030028
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020029const OnboardHeaderTabs = ({ onTabClick, activeTab }) => (
30 <div className="onboard-header-tabs">
31 <div
32 className={classnames('onboard-header-tab', {
33 active: activeTab === tabsMapping.WORKSPACE
34 })}
35 onClick={() => onTabClick(tabsMapping.WORKSPACE)}
36 data-test-id="onboard-workspace-tab">
37 {i18n('WORKSPACE')}
38 </div>
39 <div
40 className={classnames('onboard-header-tab', {
41 active: activeTab === tabsMapping.CATALOG
42 })}
43 onClick={() => onTabClick(tabsMapping.CATALOG)}
44 data-test-id="onboard-onboard-tab">
45 {i18n('ONBOARD CATALOG')}
46 </div>
47 </div>
AviZi280f8012017-06-09 02:39:56 +030048);
49
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020050const OnboardHeader = ({ onSearch, activeTab, onTabClick, searchValue }) => (
51 <div className="onboard-header">
52 <OnboardHeaderTabs activeTab={activeTab} onTabClick={onTabClick} />
53 <ExpandableInput
54 onChange={onSearch}
55 iconType="search"
56 value={searchValue}
57 />
58 <NotificationsView />
59 </div>
AviZi280f8012017-06-09 02:39:56 +030060);
61
62class OnboardView extends React.Component {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020063 static propTypes = {
64 licenseModelList: PropTypes.array,
65 softwareProductList: PropTypes.array,
66 finalizedLicenseModelList: PropTypes.array,
67 finalizedSoftwareProductList: PropTypes.array,
68 archivedSoftwareProductList: PropTypes.array,
69 archivedLicenseModelList: PropTypes.array,
70 modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)),
71 onSelectLicenseModel: PropTypes.func.isRequired,
72 onSelectSoftwareProduct: PropTypes.func.isRequired,
73 onAddLicenseModelClick: PropTypes.func.isRequired,
74 onAddSoftwareProductClick: PropTypes.func.isRequired,
75 closeVspOverlay: PropTypes.func.isRequired,
76 onVspOverlayChange: PropTypes.func.isRequired,
77 onTabClick: PropTypes.func.isRequired,
78 onCatalogTabClick: PropTypes.func.isRequired,
79 onSearch: PropTypes.func.isRequired,
80 activeTab: PropTypes.number.isRequired,
81 catalogActiveTab: PropTypes.number.isRequired,
82 searchValue: PropTypes.string.isRequired,
83 onMigrate: PropTypes.func.isRequired
84 };
85 renderViewByTab(activeTab) {
86 switch (activeTab) {
87 case tabsMapping.WORKSPACE:
88 return <WorkspaceView {...this.props} />;
89 case tabsMapping.CATALOG:
90 return <OnboardingCatalogView {...this.props} />;
91 default:
92 return <WorkspaceView {...this.props} />;
93 }
94 }
AviZi280f8012017-06-09 02:39:56 +030095
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020096 render() {
97 let { activeTab, onTabClick, onSearch, searchValue } = this.props;
98 return (
99 <div className="catalog-view">
100 <Filter />
101 <div className="catalog-parts">
102 <OnboardHeader
103 activeTab={activeTab}
104 onTabClick={onTabClick}
105 searchValue={searchValue}
106 onSearch={value => onSearch(value)}
107 />
108 {this.renderViewByTab(activeTab)}
109 </div>
110 </div>
111 );
112 }
AviZi280f8012017-06-09 02:39:56 +0300113}
114
115export default OnboardView;