blob: c5cf2926d40721f33119c2d85090226564aaef3e [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';
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,
81 searchValue: PropTypes.string.isRequired,
82 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() {
96 let { activeTab, onTabClick, onSearch, searchValue } = this.props;
97 return (
98 <div className="catalog-view">
99 <Filter />
100 <div className="catalog-parts">
101 <OnboardHeader
102 activeTab={activeTab}
103 onTabClick={onTabClick}
104 searchValue={searchValue}
105 onSearch={value => onSearch(value)}
106 />
107 {this.renderViewByTab(activeTab)}
108 </div>
109 </div>
110 );
111 }
AviZi280f8012017-06-09 02:39:56 +0300112}
113
114export default OnboardView;