svishnev | 1459228 | 2018-02-15 11:00:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2018 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 |
svishnev | 1459228 | 2018-02-15 11:00:37 +0200 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
svishnev | 1459228 | 2018-02-15 11:00:37 +0200 | [diff] [blame] | 12 | * 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
| 16 | import React from 'react'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 17 | import PropTypes from 'prop-types'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | import OnboardingCatalogView from './onboardingCatalog/OnboardingCatalogView.jsx'; |
| 19 | import WorkspaceView from './workspace/WorkspaceView.jsx'; |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 20 | import { tabsMapping } from './OnboardConstants.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 21 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 22 | import classnames from 'classnames'; |
| 23 | import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; |
| 24 | import objectValues from 'lodash/values.js'; |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 25 | import { catalogItemTypes } from './onboardingCatalog/OnboardingCatalogConstants.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 26 | import NotificationsView from 'sdc-app/onboarding/userNotifications/NotificationsView.jsx'; |
svishnev | 1459228 | 2018-02-15 11:00:37 +0200 | [diff] [blame] | 27 | import Filter from 'sdc-app/onboarding/onboard/filter/Filter.jsx'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 28 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 29 | const 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> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 48 | ); |
| 49 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 50 | const 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> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 60 | ); |
| 61 | |
| 62 | class OnboardView extends React.Component { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 63 | 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 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 95 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 96 | 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 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | export default OnboardView; |