svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame^] | 2 | * Copyright © 2016-2018 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 16 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 17 | import React from 'react'; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 18 | |
| 19 | import {render} from 'react-dom'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 20 | import ReactDOM from 'react-dom'; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 21 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 22 | import isEqual from 'lodash/isEqual.js'; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 23 | |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 24 | import lodashUnionBy from 'lodash/unionBy.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 25 | |
| 26 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 27 | import Application from 'sdc-app/Application.jsx'; |
| 28 | import store from 'sdc-app/AppStore.js'; |
| 29 | import Configuration from 'sdc-app/config/Configuration.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 30 | import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 31 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 32 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 33 | import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 34 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 35 | import {itemTypes} from './versionsPage/VersionsPageConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 36 | |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 37 | import {AppContainer} from 'react-hot-loader'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 38 | import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; |
| 39 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 40 | import {actionTypes, enums, screenTypes} from './OnboardingConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 41 | import OnboardingActionHelper from './OnboardingActionHelper.js'; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 42 | import Onboarding from './Onboarding.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 43 | |
| 44 | export default class OnboardingPunchOut { |
| 45 | |
| 46 | render({options: {data, apiRoot, apiHeaders}, onEvent}, element) { |
| 47 | if (!this.unsubscribeFromStore) { |
| 48 | this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange()); |
| 49 | } |
| 50 | |
| 51 | if (!this.isConfigSet) { |
ilanap | 785dc1e | 2018-01-08 15:50:18 +0200 | [diff] [blame] | 52 | Configuration.setCatalogApiRoot(apiRoot); |
| 53 | Configuration.setCatalogApiHeaders(apiHeaders); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 54 | this.isConfigSet = true; |
| 55 | } |
| 56 | |
| 57 | this.onEvent = (...args) => onEvent(...args); |
| 58 | this.handleData(data); |
| 59 | |
| 60 | if (!this.rendered) { |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 61 | render( |
| 62 | <AppContainer> |
| 63 | <Application> |
| 64 | <Onboarding/> |
| 65 | </Application> |
| 66 | </AppContainer>, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 67 | element |
| 68 | ); |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 69 | if (module.hot) { |
| 70 | module.hot.accept('sdc-app/onboarding/Onboarding.js', () => { |
| 71 | const NextOnboarding = require('sdc-app/onboarding/Onboarding.js').default; |
| 72 | render( |
| 73 | <AppContainer> |
| 74 | <Application> |
| 75 | <NextOnboarding/> |
| 76 | </Application> |
| 77 | </AppContainer>, |
| 78 | element |
| 79 | ); |
| 80 | }); |
| 81 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 82 | this.rendered = true; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | unmount(element) { |
| 87 | ReactDOM.unmountComponentAtNode(element); |
| 88 | this.rendered = false; |
| 89 | this.unsubscribeFromStore(); |
| 90 | this.unsubscribeFromStore = null; |
| 91 | } |
| 92 | |
| 93 | handleData(data) { |
| 94 | let {breadcrumbs: {selectedKeys = []} = {}} = data; |
| 95 | let dispatch = action => store.dispatch(action); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 96 | let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList, |
| 97 | softwareProduct: {softwareProductEditor: {data: vspData = {}}, |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame^] | 98 | softwareProductComponents = {}, softwareProductQuestionnaire = {}}, archivedLicenseModelList} = store.getState(); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 99 | const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame^] | 100 | const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList, ...archivedLicenseModelList]; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 101 | |
| 102 | let {props: {version, isReadOnlyMode}, screen} = currentScreen; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 103 | let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 104 | if (this.programmaticBreadcrumbsUpdate) { |
| 105 | this.prevSelectedKeys = selectedKeys; |
| 106 | this.programmaticBreadcrumbsUpdate = false; |
| 107 | return; |
| 108 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 109 | if (!isEqual(selectedKeys, this.prevSelectedKeys)) { |
| 110 | this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length)); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 111 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 112 | const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; |
| 113 | let preNavigate = Promise.resolve(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 114 | if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 115 | let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 116 | preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 117 | softwareProductId: prevVspId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 118 | version, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 119 | vspComponentId: prevComponentId, |
| 120 | dataToSave |
| 121 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 122 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 123 | |
| 124 | let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState(); |
| 125 | let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 126 | HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : |
| 127 | Promise.resolve(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 128 | Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { |
| 129 | this.prevSelectedKeys = selectedKeys; |
| 130 | if (selectedKeys.length === 0) { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 131 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG}); |
| 132 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 133 | } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { |
| 134 | let [licenseModelId, , licenseModelScreen] = selectedKeys; |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 135 | let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 136 | ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL, |
| 137 | props: {licenseModelId, version, licenseModel, usersList}}); |
| 138 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 139 | } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { |
| 140 | let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; |
| 141 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 142 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 143 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 144 | if (!softwareProductId) { |
| 145 | softwareProductId = softwareProduct.id; |
| 146 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 147 | if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) { |
| 148 | softwareProduct = vspData; |
| 149 | //check current vsp fields to determine which file has uploaded |
| 150 | if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) { |
| 151 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; |
| 152 | } |
| 153 | else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) { |
| 154 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; |
| 155 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 156 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 157 | |
| 158 | ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 159 | props: {softwareProductId, softwareProduct, version, usersList}}); |
| 160 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 161 | } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 162 | let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; |
| 163 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 164 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 165 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 166 | if (!softwareProductId) { |
| 167 | softwareProductId = softwareProduct.id; |
| 168 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 169 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 170 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 171 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 172 | } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 173 | let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; |
| 174 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 175 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 176 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 177 | if (!softwareProductId) { |
| 178 | softwareProductId = softwareProduct.id; |
| 179 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 180 | ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 181 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 182 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 183 | } else { |
| 184 | console.error('Unknown breadcrumbs path: ', selectedKeys); |
| 185 | } |
| 186 | }).catch(() => { |
| 187 | store.dispatch({ |
| 188 | type: actionTypes.SET_CURRENT_SCREEN, |
| 189 | currentScreen: { |
| 190 | ...currentScreen, |
| 191 | forceBreadCrumbsUpdate: true |
| 192 | } |
| 193 | }); |
| 194 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 195 | } |
| 196 | } |
| 197 | |
| 198 | handleStoreChange() { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 199 | let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage: |
| 200 | {versionsList: {itemType, itemId}}, |
| 201 | softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}}, |
svishnev | 091edfd | 2018-03-19 12:15:19 +0200 | [diff] [blame^] | 202 | softwareProductComponents: {componentsList}}, archivedLicenseModelList, archivedSoftwareProductList} = store.getState(); |
| 203 | const wholeSoftwareProductList = lodashUnionBy(softwareProductList, [...finalizedSoftwareProductList, ...archivedSoftwareProductList], 'id'); |
| 204 | const wholeLicenseModelList = lodashUnionBy(licenseModelList, [...finalizedLicenseModelList, ...archivedLicenseModelList], 'id'); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 205 | let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList}; |
| 206 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 207 | if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 208 | this.prevBreadcrumbsData = breadcrumbsData; |
| 209 | this.breadcrumbsPrefixSelected = false; |
| 210 | this.programmaticBreadcrumbsUpdate = true; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 211 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 212 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 213 | store.dispatch({ |
| 214 | type: actionTypes.SET_CURRENT_SCREEN, |
| 215 | currentScreen: { |
| 216 | ...currentScreen, |
| 217 | forceBreadCrumbsUpdate: false |
| 218 | } |
| 219 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 223 | buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct, |
| 224 | wholeLicenseModelList, wholeSoftwareProductList, componentsList}) { |
| 225 | let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 226 | let screenToBreadcrumb; |
| 227 | switch (screen) { |
| 228 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 229 | return []; |
| 230 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 231 | case enums.SCREEN.VERSIONS_PAGE: |
| 232 | let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [ |
| 233 | { |
| 234 | selectedKey: itemId, |
| 235 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 236 | key: id, |
| 237 | displayText: name |
| 238 | })) |
| 239 | }] : [ |
| 240 | { |
| 241 | selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId, |
| 242 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 243 | key: id, |
| 244 | displayText: name |
| 245 | })) |
| 246 | }, |
| 247 | { |
| 248 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 249 | menuItems: [{ |
| 250 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 251 | displayText: i18n('License Model') |
| 252 | }, { |
| 253 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 254 | displayText: i18n('Software Products') |
| 255 | }] |
| 256 | }, |
| 257 | { |
| 258 | selectedKey: itemId, |
| 259 | menuItems: wholeSoftwareProductList |
| 260 | .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId) |
| 261 | .map(({id, name}) => ({ |
| 262 | key: id, |
| 263 | displayText: name |
| 264 | })) |
| 265 | }, |
| 266 | ]; |
| 267 | return [ |
| 268 | ...firstMenuItems, |
| 269 | { |
| 270 | selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, |
| 271 | menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}] |
| 272 | } |
| 273 | ]; |
| 274 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 275 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 276 | case enums.SCREEN.FEATURE_GROUPS: |
| 277 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 278 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 279 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 280 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 281 | screenToBreadcrumb = { |
| 282 | [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 283 | [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, |
| 284 | [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 285 | [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 286 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 287 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 288 | }; |
| 289 | return [ |
| 290 | { |
| 291 | selectedKey: props.licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 292 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 293 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 294 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 295 | })) |
| 296 | }, |
| 297 | { |
| 298 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 299 | menuItems: [{ |
| 300 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 301 | displayText: i18n('License Model') |
| 302 | }, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 303 | ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ |
| 304 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 305 | displayText: i18n('Software Products') |
| 306 | }])] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 307 | }, { |
| 308 | selectedKey: screenToBreadcrumb[screen], |
| 309 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 310 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 311 | displayText: i18n('Overview') |
| 312 | },{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 313 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 314 | displayText: i18n('License Agreements') |
| 315 | }, { |
| 316 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 317 | displayText: i18n('Feature Groups') |
| 318 | }, { |
| 319 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 320 | displayText: i18n('Entitlement Pools') |
| 321 | }, { |
| 322 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 323 | displayText: i18n('License Key Groups') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 324 | }, { |
| 325 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 326 | displayText: i18n('Activity Log') |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 327 | }] |
| 328 | } |
| 329 | ]; |
| 330 | |
| 331 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 332 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 333 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 334 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 335 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 336 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 337 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 338 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 339 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 340 | |
| 341 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 342 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 343 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 344 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 345 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 346 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 347 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 348 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 349 | screenToBreadcrumb = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 350 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 351 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 352 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 353 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 354 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 355 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 356 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 357 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 358 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 359 | }; |
| 360 | let componentScreenToBreadcrumb = { |
| 361 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 362 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 363 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 364 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 365 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 366 | [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] | 367 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 368 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 369 | }; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 370 | let licenseModelId = currentSoftwareProduct.vendorId; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 371 | let returnedBreadcrumb = [ |
| 372 | { |
| 373 | selectedKey: licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 374 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 375 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 376 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 377 | })) |
| 378 | }, |
| 379 | { |
| 380 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 381 | menuItems: [{ |
| 382 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 383 | displayText: i18n('License Model') |
| 384 | }, { |
| 385 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 386 | displayText: i18n('Software Products') |
| 387 | }] |
| 388 | }, |
| 389 | { |
| 390 | selectedKey: props.softwareProductId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 391 | menuItems: wholeSoftwareProductList |
| 392 | .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 393 | .map(({id, name}) => ({ |
| 394 | key: id, |
| 395 | displayText: name |
| 396 | })) |
| 397 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 398 | ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 399 | selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 400 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 401 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 402 | displayText: i18n('Overview') |
| 403 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 404 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 405 | displayText: i18n('General') |
| 406 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 407 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 408 | displayText: i18n('Deployment Flavors') |
| 409 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 410 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 411 | displayText: i18n('Process Details') |
| 412 | }, { |
| 413 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 414 | displayText: i18n('Networks') |
| 415 | }, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 416 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 417 | displayText: i18n('Components Dependencies') |
| 418 | }, { |
| 419 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 420 | displayText: i18n('Attachments') |
| 421 | }, { |
| 422 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 423 | displayText: i18n('Activity Log') |
| 424 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 425 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 426 | displayText: i18n('Components') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 427 | }].filter(item => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 428 | switch (item.key) { |
| 429 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 430 | let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 431 | return isHeatData; |
| 432 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 433 | return (componentsList.length > 0); |
| 434 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 435 | let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 436 | return isManualMode; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 437 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 438 | return (componentsList.length > 1); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 439 | default: |
| 440 | return true; |
| 441 | } |
| 442 | }) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 443 | }]) |
| 444 | ]; |
| 445 | if(props.componentId) { |
| 446 | returnedBreadcrumb = [ |
| 447 | ...returnedBreadcrumb, { |
| 448 | selectedKey: props.componentId, |
| 449 | menuItems: componentsList |
| 450 | .map(({id, displayName}) => ({ |
| 451 | key: id, |
| 452 | displayText: displayName |
| 453 | })) |
| 454 | }, |
| 455 | ...[{ |
| 456 | selectedKey: componentScreenToBreadcrumb[screen], |
| 457 | menuItems: [{ |
| 458 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 459 | displayText: i18n('General') |
| 460 | }, { |
| 461 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 462 | displayText: i18n('Compute') |
| 463 | }, { |
| 464 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 465 | displayText: i18n('High Availability & Load Balancing') |
| 466 | }, { |
| 467 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 468 | displayText: i18n('Networks') |
| 469 | }, { |
| 470 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 471 | displayText: i18n('Storage') |
| 472 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 473 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 474 | displayText: i18n('Images') |
| 475 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 476 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 477 | displayText: i18n('Process Details') |
| 478 | }, { |
| 479 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 480 | displayText: i18n('Monitoring') |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 481 | }] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 482 | }] |
| 483 | ]; |
| 484 | } |
| 485 | return returnedBreadcrumb; |
| 486 | } |
| 487 | } |
| 488 | } |