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 | import {doesHeatDataExist} from './softwareProduct/attachments/SoftwareProductAttachmentsUtils.js'; |
| 32 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 33 | import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js'; |
| 34 | import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js'; |
| 35 | import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js'; |
| 36 | import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js'; |
| 37 | import SoftwareProduct from './softwareProduct/SoftwareProduct.js'; |
| 38 | import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js'; |
| 39 | import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js'; |
| 40 | import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js'; |
| 41 | import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 42 | import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 43 | import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 44 | import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 45 | |
| 46 | import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 47 | import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; |
| 48 | import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js'; |
| 49 | import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js'; |
| 50 | import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js'; |
| 51 | import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js'; |
| 52 | import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 53 | import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 54 | import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 55 | import { |
| 56 | navigationItems as SoftwareProductNavigationItems, |
| 57 | onboardingMethod as onboardingMethodTypes, |
| 58 | actionTypes as SoftwareProductActionTypes |
| 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: |
| 317 | OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 318 | break; |
| 319 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES: |
| 320 | OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 321 | break; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 322 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 323 | OnboardingActionHelper.navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 324 | break; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 325 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS: |
| 326 | OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 327 | break; |
| 328 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 329 | OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 330 | break; |
| 331 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
| 332 | OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 333 | break; |
| 334 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
| 335 | OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 336 | dispatch({ |
| 337 | type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, |
| 338 | mapOfExpandedIds: { |
| 339 | [SoftwareProductNavigationItems.COMPONENTS]: true |
| 340 | } |
| 341 | }); |
| 342 | break; |
| 343 | default: |
| 344 | OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); |
| 345 | break; |
| 346 | } |
| 347 | } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 348 | let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; |
| 349 | let softwareProduct = softwareProductId ? |
| 350 | softwareProductList.find(({id}) => id === softwareProductId) : |
| 351 | softwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
| 352 | if (!softwareProductId) { |
| 353 | softwareProductId = softwareProduct.id; |
| 354 | } |
| 355 | if (currentSoftwareProductId !== softwareProductId) { |
| 356 | currentSoftwareProductVersion = softwareProduct.version; |
| 357 | } |
| 358 | OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 359 | } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 360 | let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; |
| 361 | let softwareProduct = softwareProductId ? |
| 362 | softwareProductList.find(({id}) => id === softwareProductId) : |
| 363 | softwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
| 364 | if (!softwareProductId) { |
| 365 | softwareProductId = softwareProduct.id; |
| 366 | } |
| 367 | if (currentSoftwareProductId !== softwareProductId) { |
| 368 | currentSoftwareProductVersion = softwareProduct.version; |
| 369 | } |
| 370 | switch (componentScreen) { |
| 371 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 372 | OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 373 | break; |
| 374 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 375 | OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 376 | break; |
| 377 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 378 | OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 379 | break; |
| 380 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 381 | OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 382 | break; |
| 383 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 384 | OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 385 | break; |
| 386 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 387 | OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 388 | break; |
| 389 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 390 | OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); |
| 391 | break; |
| 392 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
| 393 | OnboardingActionHelper.navigateToComponentImages(dispatch, { |
| 394 | softwareProductId, |
| 395 | componentId, |
| 396 | version: currentSoftwareProductVersion |
| 397 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 398 | break; |
| 399 | } |
| 400 | } else { |
| 401 | console.error('Unknown breadcrumbs path: ', selectedKeys); |
| 402 | } |
| 403 | }).catch(() => { |
| 404 | store.dispatch({ |
| 405 | type: actionTypes.SET_CURRENT_SCREEN, |
| 406 | currentScreen: { |
| 407 | ...currentScreen, |
| 408 | forceBreadCrumbsUpdate: true |
| 409 | } |
| 410 | }); |
| 411 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | |
| 415 | handleStoreChange() { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 416 | let {currentScreen, licenseModelList, softwareProductList, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 417 | softwareProduct: {softwareProductEditor: {data = {onboardingMethod: ''}}, |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 418 | softwareProductComponents: {componentsList}, softwareProductAttachments: {heatSetup}}} = store.getState(); |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 419 | let {onboardingMethod} = data; |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 420 | let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup}; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 421 | if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 422 | this.prevBreadcrumbsData = breadcrumbsData; |
| 423 | this.breadcrumbsPrefixSelected = false; |
| 424 | this.programmaticBreadcrumbsUpdate = true; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 425 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 426 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 427 | store.dispatch({ |
| 428 | type: actionTypes.SET_CURRENT_SCREEN, |
| 429 | currentScreen: { |
| 430 | ...currentScreen, |
| 431 | forceBreadCrumbsUpdate: false |
| 432 | } |
| 433 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 437 | buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, heatSetup}) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 438 | let screenToBreadcrumb; |
| 439 | switch (screen) { |
| 440 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 441 | return []; |
| 442 | |
| 443 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 444 | case enums.SCREEN.FEATURE_GROUPS: |
| 445 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 446 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 447 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 448 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 449 | screenToBreadcrumb = { |
| 450 | [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 451 | [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, |
| 452 | [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 453 | [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 454 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 455 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 456 | }; |
| 457 | return [ |
| 458 | { |
| 459 | selectedKey: props.licenseModelId, |
| 460 | menuItems: licenseModelList.map(({id, vendorName}) => ({ |
| 461 | key: id, |
| 462 | displayText: vendorName |
| 463 | })) |
| 464 | }, |
| 465 | { |
| 466 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 467 | menuItems: [{ |
| 468 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 469 | displayText: i18n('License Model') |
| 470 | }, |
| 471 | ...(softwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ |
| 472 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 473 | displayText: i18n('Software Products') |
| 474 | }])] |
| 475 | }, { |
| 476 | selectedKey: screenToBreadcrumb[screen], |
| 477 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 478 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 479 | displayText: i18n('Overview') |
| 480 | },{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 481 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 482 | displayText: i18n('License Agreements') |
| 483 | }, { |
| 484 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 485 | displayText: i18n('Feature Groups') |
| 486 | }, { |
| 487 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 488 | displayText: i18n('Entitlement Pools') |
| 489 | }, { |
| 490 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 491 | displayText: i18n('License Key Groups') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 492 | }, { |
| 493 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 494 | displayText: i18n('Activity Log') |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 495 | }] |
| 496 | } |
| 497 | ]; |
| 498 | |
| 499 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 500 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 501 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 502 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 503 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 504 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 505 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 506 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 507 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 508 | |
| 509 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 510 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 511 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 512 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 513 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 514 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 515 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 516 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 517 | screenToBreadcrumb = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 518 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 519 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 520 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 521 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 522 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 523 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 524 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 525 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 526 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 527 | }; |
| 528 | let componentScreenToBreadcrumb = { |
| 529 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 530 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 531 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 532 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 533 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 534 | [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] | 535 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 536 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 537 | }; |
| 538 | let licenseModelId = softwareProductList.find(({id}) => id === props.softwareProductId).vendorId; |
| 539 | let returnedBreadcrumb = [ |
| 540 | { |
| 541 | selectedKey: licenseModelId, |
| 542 | menuItems: licenseModelList.map(({id, vendorName}) => ({ |
| 543 | key: id, |
| 544 | displayText: vendorName |
| 545 | })) |
| 546 | }, |
| 547 | { |
| 548 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 549 | menuItems: [{ |
| 550 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 551 | displayText: i18n('License Model') |
| 552 | }, { |
| 553 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 554 | displayText: i18n('Software Products') |
| 555 | }] |
| 556 | }, |
| 557 | { |
| 558 | selectedKey: props.softwareProductId, |
| 559 | menuItems: softwareProductList |
| 560 | .filter(({vendorId}) => vendorId === licenseModelId) |
| 561 | .map(({id, name}) => ({ |
| 562 | key: id, |
| 563 | displayText: name |
| 564 | })) |
| 565 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 566 | ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 567 | selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 568 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 569 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 570 | displayText: i18n('Overview') |
| 571 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 572 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 573 | displayText: i18n('General') |
| 574 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 575 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 576 | displayText: i18n('Deployment Flavors') |
| 577 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 578 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 579 | displayText: i18n('Process Details') |
| 580 | }, { |
| 581 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 582 | displayText: i18n('Networks') |
| 583 | }, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 584 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 585 | displayText: i18n('Components Dependencies') |
| 586 | }, { |
| 587 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 588 | displayText: i18n('Attachments') |
| 589 | }, { |
| 590 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 591 | displayText: i18n('Activity Log') |
| 592 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 593 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 594 | displayText: i18n('Components') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 595 | }].filter(item => { |
| 596 | let isHeatData = doesHeatDataExist(heatSetup); |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 597 | let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 598 | switch (item.key) { |
| 599 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 600 | return isHeatData; |
| 601 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 602 | return (componentsList.length > 0); |
| 603 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 604 | return isManualMode; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 605 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 606 | return (componentsList.length > 1); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 607 | default: |
| 608 | return true; |
| 609 | } |
| 610 | }) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 611 | }]) |
| 612 | ]; |
| 613 | if(props.componentId) { |
| 614 | returnedBreadcrumb = [ |
| 615 | ...returnedBreadcrumb, { |
| 616 | selectedKey: props.componentId, |
| 617 | menuItems: componentsList |
| 618 | .map(({id, displayName}) => ({ |
| 619 | key: id, |
| 620 | displayText: displayName |
| 621 | })) |
| 622 | }, |
| 623 | ...[{ |
| 624 | selectedKey: componentScreenToBreadcrumb[screen], |
| 625 | menuItems: [{ |
| 626 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 627 | displayText: i18n('General') |
| 628 | }, { |
| 629 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 630 | displayText: i18n('Compute') |
| 631 | }, { |
| 632 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 633 | displayText: i18n('High Availability & Load Balancing') |
| 634 | }, { |
| 635 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 636 | displayText: i18n('Networks') |
| 637 | }, { |
| 638 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 639 | displayText: i18n('Storage') |
| 640 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 641 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 642 | displayText: i18n('Images') |
| 643 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 644 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 645 | displayText: i18n('Process Details') |
| 646 | }, { |
| 647 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 648 | displayText: i18n('Monitoring') |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 649 | }] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 650 | }] |
| 651 | ]; |
| 652 | } |
| 653 | return returnedBreadcrumb; |
| 654 | } |
| 655 | } |
| 656 | } |