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'; |
| 17 | import ReactDOM from 'react-dom'; |
| 18 | import {connect} from 'react-redux'; |
| 19 | import isEqual from 'lodash/isEqual.js'; |
| 20 | import objectValues from 'lodash/values.js'; |
| 21 | |
| 22 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 23 | import Application from 'sdc-app/Application.jsx'; |
| 24 | import store from 'sdc-app/AppStore.js'; |
| 25 | import Configuration from 'sdc-app/config/Configuration.js'; |
| 26 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 27 | import Onboard from './onboard/Onboard.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 28 | import LicenseModel from './licenseModel/LicenseModel.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 29 | import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 30 | import ActivityLog from 'sdc-app/common/activity-log/ActivityLog.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 31 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 32 | import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js'; |
| 33 | import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js'; |
| 34 | import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js'; |
| 35 | import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js'; |
| 36 | import SoftwareProduct from './softwareProduct/SoftwareProduct.js'; |
| 37 | import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js'; |
| 38 | import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js'; |
| 39 | import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js'; |
| 40 | import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 41 | import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 42 | import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 43 | import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 44 | |
| 45 | import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 46 | import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; |
| 47 | import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js'; |
| 48 | import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js'; |
| 49 | import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js'; |
| 50 | import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js'; |
| 51 | import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 52 | import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 53 | import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 54 | import { |
| 55 | navigationItems as SoftwareProductNavigationItems, |
| 56 | onboardingMethod as onboardingMethodTypes, |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 57 | actionTypes as SoftwareProductActionTypes, |
| 58 | onboardingOriginTypes |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 59 | } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
| 60 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 61 | import {statusEnum as VCItemStatus} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; |
| 62 | import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 63 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 64 | import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; |
| 65 | |
| 66 | import {actionTypes, enums} from './OnboardingConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 67 | import OnboardingActionHelper from './OnboardingActionHelper.js'; |
| 68 | |
| 69 | |
| 70 | class OnboardingView extends React.Component { |
| 71 | static propTypes = { |
| 72 | currentScreen: React.PropTypes.shape({ |
| 73 | screen: React.PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired, |
| 74 | props: React.PropTypes.object.isRequired |
| 75 | }).isRequired |
| 76 | }; |
| 77 | |
| 78 | componentDidMount() { |
| 79 | let element = ReactDOM.findDOMNode(this); |
| 80 | element.addEventListener('click', event => { |
| 81 | if (event.target.tagName === 'A') { |
| 82 | event.preventDefault(); |
| 83 | } |
| 84 | }); |
| 85 | ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => |
| 86 | element.addEventListener(eventType, event => event.stopPropagation()) |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | render() { |
| 91 | let {currentScreen} = this.props; |
| 92 | let {screen, props} = currentScreen; |
| 93 | |
| 94 | return ( |
| 95 | <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'> |
| 96 | {(() => { |
| 97 | switch (screen) { |
| 98 | case enums.SCREEN.ONBOARDING_CATALOG: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 99 | return <Onboard {...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}> |
| 109 | { |
| 110 | (()=>{ |
| 111 | switch(screen) { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 112 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 113 | return <LicenseModelOverview {...props}/>; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 122 | case enums.SCREEN.ACTIVITY_LOG: |
| 123 | return <ActivityLog {...props}/>; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 124 | } |
| 125 | })() |
| 126 | } |
| 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}> |
| 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: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 157 | return <SoftwareProductAttachments className='no-padding-content-area' {...props} />; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 158 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
| 159 | return <SoftwareProductProcesses {...props}/>; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 160 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 161 | return <SoftwareProductDeployment {...props}/>; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 162 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
| 163 | return <SoftwareProductNetworks {...props}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 164 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 165 | return <SoftwareProductDependencies {...props} />; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 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}/>; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 180 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
| 181 | return <SoftwareProductComponentsImageList{...props}/>; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 182 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 183 | return <SoftwareProductComponentsMonitoring {...props}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 184 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
| 185 | return <ActivityLog {...props}/>; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 186 | } |
| 187 | })() |
| 188 | } |
| 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); |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 237 | let {currentScreen, softwareProductList, softwareProduct: {softwareProductEditor: {data: vspData = {}}, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 238 | softwareProductComponents = {}, softwareProductQuestionnaire = {}}, |
| 239 | licenseModelList, licenseModel: {licenseModelEditor: {data: {id: currentLicenseModelId, version: currentLicenseModelVersion} = {}}}} = store.getState(); |
| 240 | let {id: currentSoftwareProductId, version: currentSoftwareProductVersion} = vspData; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 241 | let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 242 | if (this.programmaticBreadcrumbsUpdate) { |
| 243 | this.prevSelectedKeys = selectedKeys; |
| 244 | this.programmaticBreadcrumbsUpdate = false; |
| 245 | return; |
| 246 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 247 | if (!isEqual(selectedKeys, this.prevSelectedKeys)) { |
| 248 | this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length)); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 249 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 250 | const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; |
| 251 | let preNavigate = Promise.resolve(); |
| 252 | if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && vspData.status === VCItemStatus.CHECK_OUT_STATUS && VersionControllerUtils.isCheckedOutByCurrentUser(vspData)) { |
| 253 | let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 254 | preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 255 | softwareProductId: prevVspId, |
| 256 | version: currentSoftwareProductVersion, |
| 257 | vspComponentId: prevComponentId, |
| 258 | dataToSave |
| 259 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 260 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 261 | |
| 262 | let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState(); |
| 263 | let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? |
| 264 | HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : |
| 265 | Promise.resolve(); |
| 266 | Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { |
| 267 | this.prevSelectedKeys = selectedKeys; |
| 268 | if (selectedKeys.length === 0) { |
| 269 | OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); |
| 270 | } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { |
| 271 | let [licenseModelId, , licenseModelScreen] = selectedKeys; |
| 272 | if (!licenseModelScreen) { |
| 273 | licenseModelScreen = enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW; |
| 274 | } |
| 275 | if (currentLicenseModelId !== licenseModelId) { |
| 276 | currentLicenseModelVersion = licenseModelList.find(lm => lm.id === licenseModelId).version; |
| 277 | } |
| 278 | switch (licenseModelScreen) { |
| 279 | case enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW: |
| 280 | OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 281 | break; |
| 282 | case enums.BREADCRUMS.LICENSE_AGREEMENTS: |
| 283 | OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 284 | break; |
| 285 | case enums.BREADCRUMS.FEATURE_GROUPS: |
| 286 | OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 287 | break; |
| 288 | case enums.BREADCRUMS.ENTITLEMENT_POOLS: |
| 289 | OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 290 | break; |
| 291 | case enums.BREADCRUMS.LICENSE_KEY_GROUPS: |
| 292 | OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 293 | break; |
| 294 | case enums.BREADCRUMS.ACTIVITY_LOG: |
| 295 | OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version: currentLicenseModelVersion}); |
| 296 | break; |
| 297 | } |
| 298 | } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { |
| 299 | let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; |
| 300 | let softwareProduct = softwareProductId ? |
| 301 | softwareProductList.find(({id}) => id === softwareProductId) : |
| 302 | softwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
| 303 | if (!softwareProductId) { |
| 304 | softwareProductId = softwareProduct.id; |
| 305 | } |
| 306 | if (currentSoftwareProductId !== softwareProductId) { |
| 307 | currentSoftwareProductVersion = softwareProduct.version; |
| 308 | } |
| 309 | switch (softwareProductScreen) { |
| 310 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 311 | OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 312 | break; |
| 313 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS: |
| 314 | OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 315 | break; |
| 316 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 317 | if(softwareProduct.onboardingOrigin === onboardingOriginTypes.ZIP) { |
| 318 | OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 319 | } |
| 320 | else if(softwareProduct.onboardingOrigin === onboardingOriginTypes.CSAR) { |
| 321 | OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 322 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 323 | break; |
| 324 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES: |
| 325 | OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 326 | break; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 327 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 328 | OnboardingActionHelper.navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 329 | break; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 330 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS: |
| 331 | OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 332 | break; |
| 333 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 334 | OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 335 | break; |
| 336 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
| 337 | OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 338 | break; |
| 339 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
| 340 | OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 341 | dispatch({ |
| 342 | type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, |
| 343 | mapOfExpandedIds: { |
| 344 | [SoftwareProductNavigationItems.COMPONENTS]: true |
| 345 | } |
| 346 | }); |
| 347 | break; |
| 348 | default: |
| 349 | OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 350 | break; |
| 351 | } |
| 352 | } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 353 | let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; |
| 354 | let softwareProduct = softwareProductId ? |
| 355 | softwareProductList.find(({id}) => id === softwareProductId) : |
| 356 | softwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
| 357 | if (!softwareProductId) { |
| 358 | softwareProductId = softwareProduct.id; |
| 359 | } |
| 360 | if (currentSoftwareProductId !== softwareProductId) { |
| 361 | currentSoftwareProductVersion = softwareProduct.version; |
| 362 | } |
| 363 | OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 364 | } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 365 | let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; |
| 366 | let softwareProduct = softwareProductId ? |
| 367 | softwareProductList.find(({id}) => id === softwareProductId) : |
| 368 | softwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
| 369 | if (!softwareProductId) { |
| 370 | softwareProductId = softwareProduct.id; |
| 371 | } |
| 372 | if (currentSoftwareProductId !== softwareProductId) { |
| 373 | currentSoftwareProductVersion = softwareProduct.version; |
| 374 | } |
| 375 | switch (componentScreen) { |
| 376 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 377 | OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 378 | break; |
| 379 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 380 | OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 381 | break; |
| 382 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 383 | OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 384 | break; |
| 385 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 386 | OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 387 | break; |
| 388 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 389 | OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 390 | break; |
| 391 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 392 | OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 393 | break; |
| 394 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 395 | OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 396 | break; |
| 397 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
| 398 | OnboardingActionHelper.navigateToComponentImages(dispatch, { |
| 399 | softwareProductId, |
| 400 | componentId, |
| 401 | version: currentSoftwareProductVersion |
| 402 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 403 | break; |
| 404 | } |
| 405 | } else { |
| 406 | console.error('Unknown breadcrumbs path: ', selectedKeys); |
| 407 | } |
| 408 | }).catch(() => { |
| 409 | store.dispatch({ |
| 410 | type: actionTypes.SET_CURRENT_SCREEN, |
| 411 | currentScreen: { |
| 412 | ...currentScreen, |
| 413 | forceBreadCrumbsUpdate: true |
| 414 | } |
| 415 | }); |
| 416 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | |
| 420 | handleStoreChange() { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 421 | let {currentScreen, licenseModelList, softwareProductList, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 422 | softwareProduct: {softwareProductEditor: {data = {onboardingMethod: ''}}, |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 423 | softwareProductComponents: {componentsList}}} = store.getState(); |
| 424 | let {onboardingMethod, onboardingOrigin} = data; |
| 425 | let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, onboardingOrigin}; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 426 | if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 427 | this.prevBreadcrumbsData = breadcrumbsData; |
| 428 | this.breadcrumbsPrefixSelected = false; |
| 429 | this.programmaticBreadcrumbsUpdate = true; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 430 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 431 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 432 | store.dispatch({ |
| 433 | type: actionTypes.SET_CURRENT_SCREEN, |
| 434 | currentScreen: { |
| 435 | ...currentScreen, |
| 436 | forceBreadCrumbsUpdate: false |
| 437 | } |
| 438 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 439 | } |
| 440 | } |
| 441 | |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 442 | buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, onboardingOrigin}) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 443 | let screenToBreadcrumb; |
| 444 | switch (screen) { |
| 445 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 446 | return []; |
| 447 | |
| 448 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 449 | case enums.SCREEN.FEATURE_GROUPS: |
| 450 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 451 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 452 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 453 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 454 | screenToBreadcrumb = { |
| 455 | [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 456 | [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, |
| 457 | [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 458 | [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 459 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 460 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 461 | }; |
| 462 | return [ |
| 463 | { |
| 464 | selectedKey: props.licenseModelId, |
| 465 | menuItems: licenseModelList.map(({id, vendorName}) => ({ |
| 466 | key: id, |
| 467 | displayText: vendorName |
| 468 | })) |
| 469 | }, |
| 470 | { |
| 471 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 472 | menuItems: [{ |
| 473 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 474 | displayText: i18n('License Model') |
| 475 | }, |
| 476 | ...(softwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ |
| 477 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 478 | displayText: i18n('Software Products') |
| 479 | }])] |
| 480 | }, { |
| 481 | selectedKey: screenToBreadcrumb[screen], |
| 482 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 483 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 484 | displayText: i18n('Overview') |
| 485 | },{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 486 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 487 | displayText: i18n('License Agreements') |
| 488 | }, { |
| 489 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 490 | displayText: i18n('Feature Groups') |
| 491 | }, { |
| 492 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 493 | displayText: i18n('Entitlement Pools') |
| 494 | }, { |
| 495 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 496 | displayText: i18n('License Key Groups') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 497 | }, { |
| 498 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 499 | displayText: i18n('Activity Log') |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 500 | }] |
| 501 | } |
| 502 | ]; |
| 503 | |
| 504 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 505 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 506 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 507 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 508 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 509 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 510 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 511 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 512 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 513 | |
| 514 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 515 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 516 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 517 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 518 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 519 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 520 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 521 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 522 | screenToBreadcrumb = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 523 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 524 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 525 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 526 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 527 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 528 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 529 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 530 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 531 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 532 | }; |
| 533 | let componentScreenToBreadcrumb = { |
| 534 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 535 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 536 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 537 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 538 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 539 | [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] | 540 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 541 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 542 | }; |
| 543 | let licenseModelId = softwareProductList.find(({id}) => id === props.softwareProductId).vendorId; |
| 544 | let returnedBreadcrumb = [ |
| 545 | { |
| 546 | selectedKey: licenseModelId, |
| 547 | menuItems: licenseModelList.map(({id, vendorName}) => ({ |
| 548 | key: id, |
| 549 | displayText: vendorName |
| 550 | })) |
| 551 | }, |
| 552 | { |
| 553 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 554 | menuItems: [{ |
| 555 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 556 | displayText: i18n('License Model') |
| 557 | }, { |
| 558 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 559 | displayText: i18n('Software Products') |
| 560 | }] |
| 561 | }, |
| 562 | { |
| 563 | selectedKey: props.softwareProductId, |
| 564 | menuItems: softwareProductList |
| 565 | .filter(({vendorId}) => vendorId === licenseModelId) |
| 566 | .map(({id, name}) => ({ |
| 567 | key: id, |
| 568 | displayText: name |
| 569 | })) |
| 570 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 571 | ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 572 | selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 573 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 574 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 575 | displayText: i18n('Overview') |
| 576 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 577 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 578 | displayText: i18n('General') |
| 579 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 580 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 581 | displayText: i18n('Deployment Flavors') |
| 582 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 583 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 584 | displayText: i18n('Process Details') |
| 585 | }, { |
| 586 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 587 | displayText: i18n('Networks') |
| 588 | }, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 589 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 590 | displayText: i18n('Components Dependencies') |
| 591 | }, { |
| 592 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 593 | displayText: i18n('Attachments') |
| 594 | }, { |
| 595 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 596 | displayText: i18n('Activity Log') |
| 597 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 598 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 599 | displayText: i18n('Components') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 600 | }].filter(item => { |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 601 | let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 602 | let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 603 | switch (item.key) { |
| 604 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 605 | return isHeatData; |
| 606 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 607 | return (componentsList.length > 0); |
| 608 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 609 | return isManualMode; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 610 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 611 | return (componentsList.length > 1); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 612 | default: |
| 613 | return true; |
| 614 | } |
| 615 | }) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 616 | }]) |
| 617 | ]; |
| 618 | if(props.componentId) { |
| 619 | returnedBreadcrumb = [ |
| 620 | ...returnedBreadcrumb, { |
| 621 | selectedKey: props.componentId, |
| 622 | menuItems: componentsList |
| 623 | .map(({id, displayName}) => ({ |
| 624 | key: id, |
| 625 | displayText: displayName |
| 626 | })) |
| 627 | }, |
| 628 | ...[{ |
| 629 | selectedKey: componentScreenToBreadcrumb[screen], |
| 630 | menuItems: [{ |
| 631 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 632 | displayText: i18n('General') |
| 633 | }, { |
| 634 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 635 | displayText: i18n('Compute') |
| 636 | }, { |
| 637 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 638 | displayText: i18n('High Availability & Load Balancing') |
| 639 | }, { |
| 640 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 641 | displayText: i18n('Networks') |
| 642 | }, { |
| 643 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 644 | displayText: i18n('Storage') |
| 645 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 646 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 647 | displayText: i18n('Images') |
| 648 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 649 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 650 | displayText: i18n('Process Details') |
| 651 | }, { |
| 652 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 653 | displayText: i18n('Monitoring') |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 654 | }] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 655 | }] |
| 656 | ]; |
| 657 | } |
| 658 | return returnedBreadcrumb; |
| 659 | } |
| 660 | } |
| 661 | } |