AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 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 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import React from 'react'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 17 | import PropTypes from 'prop-types'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 18 | import ReactDOM from 'react-dom'; |
| 19 | import {connect} from 'react-redux'; |
| 20 | import isEqual from 'lodash/isEqual.js'; |
| 21 | import objectValues from 'lodash/values.js'; |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 22 | import lodashUnionBy from 'lodash/unionBy.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 23 | |
| 24 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 25 | import Application from 'sdc-app/Application.jsx'; |
| 26 | import store from 'sdc-app/AppStore.js'; |
| 27 | import Configuration from 'sdc-app/config/Configuration.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 28 | import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 29 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 30 | import Onboard from './onboard/Onboard.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 31 | import VersionsPage from './versionsPage/VersionsPage.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 32 | import LicenseModel from './licenseModel/LicenseModel.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 33 | import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 34 | import ActivityLog from 'sdc-app/common/activity-log/ActivityLog.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 35 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 36 | import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js'; |
| 37 | import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js'; |
| 38 | import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js'; |
| 39 | import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js'; |
| 40 | import SoftwareProduct from './softwareProduct/SoftwareProduct.js'; |
| 41 | import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js'; |
| 42 | import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js'; |
| 43 | import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js'; |
| 44 | import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 45 | import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 46 | import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 47 | import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 48 | |
| 49 | import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 50 | import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; |
| 51 | import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js'; |
| 52 | import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js'; |
| 53 | import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js'; |
| 54 | import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js'; |
| 55 | import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 56 | import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 57 | import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 58 | import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 59 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 60 | import {itemTypes} from './versionsPage/VersionsPageConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 61 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 62 | import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; |
| 63 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 64 | import {actionTypes, enums, screenTypes} from './OnboardingConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 65 | import OnboardingActionHelper from './OnboardingActionHelper.js'; |
| 66 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 67 | class OnboardingView extends React.Component { |
| 68 | static propTypes = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 69 | currentScreen: PropTypes.shape({ |
| 70 | screen: PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired, |
| 71 | props: PropTypes.object.isRequired, |
| 72 | itemPermission: PropTypes.object |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 73 | }).isRequired |
| 74 | }; |
| 75 | |
| 76 | componentDidMount() { |
| 77 | let element = ReactDOM.findDOMNode(this); |
| 78 | element.addEventListener('click', event => { |
| 79 | if (event.target.tagName === 'A') { |
| 80 | event.preventDefault(); |
| 81 | } |
| 82 | }); |
| 83 | ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => |
| 84 | element.addEventListener(eventType, event => event.stopPropagation()) |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | render() { |
| 89 | let {currentScreen} = this.props; |
| 90 | let {screen, props} = currentScreen; |
| 91 | |
| 92 | return ( |
| 93 | <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'> |
| 94 | {(() => { |
| 95 | switch (screen) { |
| 96 | case enums.SCREEN.ONBOARDING_CATALOG: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 97 | return <Onboard {...props}/>; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 98 | case enums.SCREEN.VERSIONS_PAGE: |
| 99 | return <VersionsPage {...props} />; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 100 | |
| 101 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 102 | case enums.SCREEN.FEATURE_GROUPS: |
| 103 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 104 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 105 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 106 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 107 | return ( |
| 108 | <LicenseModel currentScreen={currentScreen}> |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 109 | { |
| 110 | (()=>{ |
| 111 | switch(screen) { |
| 112 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 113 | return <LicenseModelOverview {...props}/>; |
| 114 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 115 | return <LicenseAgreementListEditor {...props}/>; |
| 116 | case enums.SCREEN.FEATURE_GROUPS: |
| 117 | return <FeatureGroupListEditor {...props}/>; |
| 118 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 119 | return <EntitlementPoolsListEditor {...props}/>; |
| 120 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
| 121 | return <LicenseKeyGroupsListEditor {...props}/>; |
| 122 | case enums.SCREEN.ACTIVITY_LOG: |
| 123 | return <ActivityLog {...props}/>; |
| 124 | } |
| 125 | })() |
| 126 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 127 | </LicenseModel> |
| 128 | ); |
| 129 | |
| 130 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 131 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 132 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 133 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 134 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 135 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 136 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 137 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 138 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 139 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 140 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 141 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 142 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 143 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 144 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 145 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 146 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 147 | return ( |
| 148 | <SoftwareProduct currentScreen={currentScreen}> |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 149 | { |
| 150 | (()=>{ |
| 151 | switch(screen) { |
| 152 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 153 | return <SoftwareProductLandingPage {...props}/>; |
| 154 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 155 | return <SoftwareProductDetails {...props}/>; |
| 156 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 157 | return <SoftwareProductAttachments className='no-padding-content-area' {...props} />; |
| 158 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
| 159 | return <SoftwareProductProcesses {...props}/>; |
| 160 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 161 | return <SoftwareProductDeployment {...props}/>; |
| 162 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
| 163 | return <SoftwareProductNetworks {...props}/>; |
| 164 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 165 | return <SoftwareProductDependencies {...props} />; |
| 166 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 167 | return <SoftwareProductComponentsList {...props}/>; |
| 168 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 169 | return <SoftwareProductComponentProcessesList {...props}/>; |
| 170 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 171 | return <SoftwareProductComponentStorage {...props}/>; |
| 172 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 173 | return <SoftwareProductComponentsNetworkList {...props}/>; |
| 174 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 175 | return <SoftwareProductComponentsGeneral{...props}/>; |
| 176 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 177 | return <SoftwareProductComponentsCompute {...props}/>; |
| 178 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
| 179 | return <SoftwareProductComponentLoadBalancing{...props}/>; |
| 180 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
| 181 | return <SoftwareProductComponentsImageList{...props}/>; |
| 182 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 183 | return <SoftwareProductComponentsMonitoring {...props}/>; |
| 184 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
| 185 | return <ActivityLog {...props}/>; |
| 186 | } |
| 187 | })() |
| 188 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 189 | </SoftwareProduct> |
| 190 | ); |
| 191 | } |
| 192 | })()} |
| 193 | </div> |
| 194 | ); |
| 195 | } |
| 196 | } |
| 197 | const mapStateToProps = ({currentScreen}) => ({currentScreen}); |
| 198 | let Onboarding = connect(mapStateToProps, null)(OnboardingView); |
| 199 | |
| 200 | export default class OnboardingPunchOut { |
| 201 | |
| 202 | render({options: {data, apiRoot, apiHeaders}, onEvent}, element) { |
| 203 | if (!this.unsubscribeFromStore) { |
| 204 | this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange()); |
| 205 | } |
| 206 | |
| 207 | if (!this.isConfigSet) { |
| 208 | Configuration.setATTApiRoot(apiRoot); |
| 209 | Configuration.setATTApiHeaders(apiHeaders); |
| 210 | this.isConfigSet = true; |
| 211 | } |
| 212 | |
| 213 | this.onEvent = (...args) => onEvent(...args); |
| 214 | this.handleData(data); |
| 215 | |
| 216 | if (!this.rendered) { |
| 217 | ReactDOM.render( |
| 218 | <Application> |
| 219 | <Onboarding/> |
| 220 | </Application>, |
| 221 | element |
| 222 | ); |
| 223 | this.rendered = true; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | unmount(element) { |
| 228 | ReactDOM.unmountComponentAtNode(element); |
| 229 | this.rendered = false; |
| 230 | this.unsubscribeFromStore(); |
| 231 | this.unsubscribeFromStore = null; |
| 232 | } |
| 233 | |
| 234 | handleData(data) { |
| 235 | let {breadcrumbs: {selectedKeys = []} = {}} = data; |
| 236 | let dispatch = action => store.dispatch(action); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 237 | let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList, |
| 238 | softwareProduct: {softwareProductEditor: {data: vspData = {}}, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 239 | softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState(); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 240 | const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; |
| 241 | const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList]; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 242 | |
| 243 | let {props: {version, isReadOnlyMode}, screen} = currentScreen; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 244 | let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 245 | if (this.programmaticBreadcrumbsUpdate) { |
| 246 | this.prevSelectedKeys = selectedKeys; |
| 247 | this.programmaticBreadcrumbsUpdate = false; |
| 248 | return; |
| 249 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 250 | if (!isEqual(selectedKeys, this.prevSelectedKeys)) { |
| 251 | this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length)); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 252 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 253 | const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; |
| 254 | let preNavigate = Promise.resolve(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 255 | if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 256 | let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 257 | preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 258 | softwareProductId: prevVspId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 259 | version, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 260 | vspComponentId: prevComponentId, |
| 261 | dataToSave |
| 262 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 263 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 264 | |
| 265 | let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState(); |
| 266 | let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 267 | HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : |
| 268 | Promise.resolve(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 269 | Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { |
| 270 | this.prevSelectedKeys = selectedKeys; |
| 271 | if (selectedKeys.length === 0) { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 272 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG}); |
| 273 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 274 | } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { |
| 275 | let [licenseModelId, , licenseModelScreen] = selectedKeys; |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 276 | let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 277 | ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL, |
| 278 | props: {licenseModelId, version, licenseModel, usersList}}); |
| 279 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 280 | } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { |
| 281 | let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; |
| 282 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 283 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 284 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 285 | if (!softwareProductId) { |
| 286 | softwareProductId = softwareProduct.id; |
| 287 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 288 | if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) { |
| 289 | softwareProduct = vspData; |
| 290 | //check current vsp fields to determine which file has uploaded |
| 291 | if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) { |
| 292 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; |
| 293 | } |
| 294 | else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) { |
| 295 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; |
| 296 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 297 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 298 | |
| 299 | ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 300 | props: {softwareProductId, softwareProduct, version, usersList}}); |
| 301 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 302 | } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 303 | let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; |
| 304 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 305 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 306 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 307 | if (!softwareProductId) { |
| 308 | softwareProductId = softwareProduct.id; |
| 309 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 310 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 311 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 312 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 313 | } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 314 | let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; |
| 315 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 316 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 317 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 318 | if (!softwareProductId) { |
| 319 | softwareProductId = softwareProduct.id; |
| 320 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 321 | ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 322 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 323 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 324 | } else { |
| 325 | console.error('Unknown breadcrumbs path: ', selectedKeys); |
| 326 | } |
| 327 | }).catch(() => { |
| 328 | store.dispatch({ |
| 329 | type: actionTypes.SET_CURRENT_SCREEN, |
| 330 | currentScreen: { |
| 331 | ...currentScreen, |
| 332 | forceBreadCrumbsUpdate: true |
| 333 | } |
| 334 | }); |
| 335 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 336 | } |
| 337 | } |
| 338 | |
| 339 | handleStoreChange() { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 340 | let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage: |
| 341 | {versionsList: {itemType, itemId}}, |
| 342 | softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}}, |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 343 | softwareProductComponents: {componentsList}}} = store.getState(); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame^] | 344 | const wholeSoftwareProductList = lodashUnionBy(softwareProductList, finalizedSoftwareProductList, 'id'); |
| 345 | const wholeLicenseModelList = lodashUnionBy(licenseModelList, finalizedLicenseModelList, 'id'); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 346 | let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList}; |
| 347 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 348 | if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 349 | this.prevBreadcrumbsData = breadcrumbsData; |
| 350 | this.breadcrumbsPrefixSelected = false; |
| 351 | this.programmaticBreadcrumbsUpdate = true; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 352 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 353 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 354 | store.dispatch({ |
| 355 | type: actionTypes.SET_CURRENT_SCREEN, |
| 356 | currentScreen: { |
| 357 | ...currentScreen, |
| 358 | forceBreadCrumbsUpdate: false |
| 359 | } |
| 360 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 364 | buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct, |
| 365 | wholeLicenseModelList, wholeSoftwareProductList, componentsList}) { |
| 366 | let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 367 | let screenToBreadcrumb; |
| 368 | switch (screen) { |
| 369 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 370 | return []; |
| 371 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 372 | case enums.SCREEN.VERSIONS_PAGE: |
| 373 | let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [ |
| 374 | { |
| 375 | selectedKey: itemId, |
| 376 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 377 | key: id, |
| 378 | displayText: name |
| 379 | })) |
| 380 | }] : [ |
| 381 | { |
| 382 | selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId, |
| 383 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 384 | key: id, |
| 385 | displayText: name |
| 386 | })) |
| 387 | }, |
| 388 | { |
| 389 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 390 | menuItems: [{ |
| 391 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 392 | displayText: i18n('License Model') |
| 393 | }, { |
| 394 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 395 | displayText: i18n('Software Products') |
| 396 | }] |
| 397 | }, |
| 398 | { |
| 399 | selectedKey: itemId, |
| 400 | menuItems: wholeSoftwareProductList |
| 401 | .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId) |
| 402 | .map(({id, name}) => ({ |
| 403 | key: id, |
| 404 | displayText: name |
| 405 | })) |
| 406 | }, |
| 407 | ]; |
| 408 | return [ |
| 409 | ...firstMenuItems, |
| 410 | { |
| 411 | selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, |
| 412 | menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}] |
| 413 | } |
| 414 | ]; |
| 415 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 416 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 417 | case enums.SCREEN.FEATURE_GROUPS: |
| 418 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 419 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 420 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 421 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 422 | screenToBreadcrumb = { |
| 423 | [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 424 | [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, |
| 425 | [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 426 | [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 427 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 428 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 429 | }; |
| 430 | return [ |
| 431 | { |
| 432 | selectedKey: props.licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 433 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 434 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 435 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 436 | })) |
| 437 | }, |
| 438 | { |
| 439 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 440 | menuItems: [{ |
| 441 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 442 | displayText: i18n('License Model') |
| 443 | }, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 444 | ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ |
| 445 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 446 | displayText: i18n('Software Products') |
| 447 | }])] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 448 | }, { |
| 449 | selectedKey: screenToBreadcrumb[screen], |
| 450 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 451 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 452 | displayText: i18n('Overview') |
| 453 | },{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 454 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 455 | displayText: i18n('License Agreements') |
| 456 | }, { |
| 457 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 458 | displayText: i18n('Feature Groups') |
| 459 | }, { |
| 460 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 461 | displayText: i18n('Entitlement Pools') |
| 462 | }, { |
| 463 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 464 | displayText: i18n('License Key Groups') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 465 | }, { |
| 466 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 467 | displayText: i18n('Activity Log') |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 468 | }] |
| 469 | } |
| 470 | ]; |
| 471 | |
| 472 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 473 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 474 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 475 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 476 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 477 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 478 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 479 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 480 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 481 | |
| 482 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 483 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 484 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 485 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 486 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 487 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 488 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 489 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 490 | screenToBreadcrumb = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 491 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 492 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 493 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 494 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 495 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 496 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 497 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 498 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 499 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 500 | }; |
| 501 | let componentScreenToBreadcrumb = { |
| 502 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 503 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 504 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 505 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 506 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 507 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 508 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 509 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 510 | }; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 511 | let licenseModelId = currentSoftwareProduct.vendorId; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 512 | let returnedBreadcrumb = [ |
| 513 | { |
| 514 | selectedKey: licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 515 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 516 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 517 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 518 | })) |
| 519 | }, |
| 520 | { |
| 521 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 522 | menuItems: [{ |
| 523 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 524 | displayText: i18n('License Model') |
| 525 | }, { |
| 526 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 527 | displayText: i18n('Software Products') |
| 528 | }] |
| 529 | }, |
| 530 | { |
| 531 | selectedKey: props.softwareProductId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 532 | menuItems: wholeSoftwareProductList |
| 533 | .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 534 | .map(({id, name}) => ({ |
| 535 | key: id, |
| 536 | displayText: name |
| 537 | })) |
| 538 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 539 | ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 540 | selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 541 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 542 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 543 | displayText: i18n('Overview') |
| 544 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 545 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 546 | displayText: i18n('General') |
| 547 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 548 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 549 | displayText: i18n('Deployment Flavors') |
| 550 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 551 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 552 | displayText: i18n('Process Details') |
| 553 | }, { |
| 554 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 555 | displayText: i18n('Networks') |
| 556 | }, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 557 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 558 | displayText: i18n('Components Dependencies') |
| 559 | }, { |
| 560 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 561 | displayText: i18n('Attachments') |
| 562 | }, { |
| 563 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 564 | displayText: i18n('Activity Log') |
| 565 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 566 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 567 | displayText: i18n('Components') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 568 | }].filter(item => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 569 | switch (item.key) { |
| 570 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 571 | let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 572 | return isHeatData; |
| 573 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 574 | return (componentsList.length > 0); |
| 575 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 576 | let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 577 | return isManualMode; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 578 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 579 | return (componentsList.length > 1); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 580 | default: |
| 581 | return true; |
| 582 | } |
| 583 | }) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 584 | }]) |
| 585 | ]; |
| 586 | if(props.componentId) { |
| 587 | returnedBreadcrumb = [ |
| 588 | ...returnedBreadcrumb, { |
| 589 | selectedKey: props.componentId, |
| 590 | menuItems: componentsList |
| 591 | .map(({id, displayName}) => ({ |
| 592 | key: id, |
| 593 | displayText: displayName |
| 594 | })) |
| 595 | }, |
| 596 | ...[{ |
| 597 | selectedKey: componentScreenToBreadcrumb[screen], |
| 598 | menuItems: [{ |
| 599 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 600 | displayText: i18n('General') |
| 601 | }, { |
| 602 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 603 | displayText: i18n('Compute') |
| 604 | }, { |
| 605 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 606 | displayText: i18n('High Availability & Load Balancing') |
| 607 | }, { |
| 608 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 609 | displayText: i18n('Networks') |
| 610 | }, { |
| 611 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 612 | displayText: i18n('Storage') |
| 613 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 614 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 615 | displayText: i18n('Images') |
| 616 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 617 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 618 | displayText: i18n('Process Details') |
| 619 | }, { |
| 620 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 621 | displayText: i18n('Monitoring') |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 622 | }] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 623 | }] |
| 624 | ]; |
| 625 | } |
| 626 | return returnedBreadcrumb; |
| 627 | } |
| 628 | } |
| 629 | } |