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 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 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 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 24 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 25 | import Application from 'sdc-app/Application.jsx'; |
| 26 | import store from 'sdc-app/AppStore.js'; |
| 27 | import Configuration from 'sdc-app/config/Configuration.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 28 | import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 29 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 30 | import { |
| 31 | onboardingMethod as onboardingMethodTypes, |
| 32 | onboardingOriginTypes |
| 33 | } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 34 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 35 | import { itemTypes } from './versionsPage/VersionsPageConstants.js'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 36 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +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 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +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 { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 45 | render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) { |
| 46 | if (!this.unsubscribeFromStore) { |
| 47 | this.unsubscribeFromStore = store.subscribe(() => |
| 48 | this.handleStoreChange() |
| 49 | ); |
| 50 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 51 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 52 | if (!this.isConfigSet) { |
| 53 | Configuration.setCatalogApiRoot(apiRoot); |
| 54 | Configuration.setCatalogApiHeaders(apiHeaders); |
| 55 | this.isConfigSet = true; |
| 56 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 57 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 58 | this.onEvent = (...args) => onEvent(...args); |
| 59 | this.handleData(data); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 60 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 61 | if (!this.rendered) { |
| 62 | render( |
| 63 | <AppContainer> |
| 64 | <Application> |
| 65 | <Onboarding /> |
| 66 | </Application> |
| 67 | </AppContainer>, |
| 68 | element |
| 69 | ); |
| 70 | if (module.hot) { |
| 71 | module.hot.accept('sdc-app/onboarding/Onboarding.js', () => { |
| 72 | const NextOnboarding = require('sdc-app/onboarding/Onboarding.js') |
| 73 | .default; |
| 74 | render( |
| 75 | <AppContainer> |
| 76 | <Application> |
| 77 | <NextOnboarding /> |
| 78 | </Application> |
| 79 | </AppContainer>, |
| 80 | element |
| 81 | ); |
| 82 | }); |
| 83 | } |
| 84 | this.rendered = true; |
| 85 | } |
| 86 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 87 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 88 | unmount(element) { |
| 89 | ReactDOM.unmountComponentAtNode(element); |
| 90 | this.rendered = false; |
| 91 | this.unsubscribeFromStore(); |
| 92 | this.unsubscribeFromStore = null; |
| 93 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 94 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 95 | handleData(data) { |
| 96 | let { breadcrumbs: { selectedKeys = [] } = {} } = data; |
| 97 | let dispatch = action => store.dispatch(action); |
| 98 | let { |
| 99 | currentScreen, |
| 100 | users: { usersList }, |
| 101 | softwareProductList, |
| 102 | finalizedSoftwareProductList, |
| 103 | licenseModelList, |
| 104 | finalizedLicenseModelList, |
| 105 | softwareProduct: { |
| 106 | softwareProductEditor: { data: vspData = {} }, |
| 107 | softwareProductComponents = {}, |
| 108 | softwareProductQuestionnaire = {} |
| 109 | }, |
| 110 | archivedLicenseModelList |
| 111 | } = store.getState(); |
| 112 | const wholeSoftwareProductList = [ |
| 113 | ...softwareProductList, |
| 114 | ...finalizedSoftwareProductList |
| 115 | ]; |
| 116 | const wholeLicenseModelList = [ |
| 117 | ...licenseModelList, |
| 118 | ...finalizedLicenseModelList, |
| 119 | ...archivedLicenseModelList |
| 120 | ]; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 121 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 122 | let { props: { version, isReadOnlyMode }, screen } = currentScreen; |
| 123 | let { |
| 124 | componentEditor: { |
| 125 | data: componentData = {}, |
| 126 | qdata: componentQData = {} |
| 127 | } |
| 128 | } = softwareProductComponents; |
| 129 | if (this.programmaticBreadcrumbsUpdate) { |
| 130 | this.prevSelectedKeys = selectedKeys; |
| 131 | this.programmaticBreadcrumbsUpdate = false; |
| 132 | return; |
| 133 | } |
| 134 | if (!isEqual(selectedKeys, this.prevSelectedKeys)) { |
| 135 | this.breadcrumbsPrefixSelected = isEqual( |
| 136 | selectedKeys, |
| 137 | this.prevSelectedKeys && |
| 138 | this.prevSelectedKeys.slice(0, selectedKeys.length) |
| 139 | ); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 140 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 141 | const [, screenType, prevVspId, , prevComponentId] = |
| 142 | this.prevSelectedKeys || []; |
| 143 | let preNavigate = Promise.resolve(); |
| 144 | if ( |
| 145 | screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && |
| 146 | screen !== 'VERSIONS_PAGE' && |
| 147 | !isReadOnlyMode |
| 148 | ) { |
| 149 | let dataToSave = prevVspId |
| 150 | ? prevComponentId |
| 151 | ? { componentData, qdata: componentQData } |
| 152 | : { |
| 153 | softwareProduct: vspData, |
| 154 | qdata: softwareProductQuestionnaire.qdata |
| 155 | } |
| 156 | : {}; |
| 157 | preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate( |
| 158 | dispatch, |
| 159 | { |
| 160 | softwareProductId: prevVspId, |
| 161 | version, |
| 162 | vspComponentId: prevComponentId, |
| 163 | dataToSave |
| 164 | } |
| 165 | ); |
| 166 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 167 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 168 | let { |
| 169 | currentScreen: { props: { softwareProductId } }, |
| 170 | softwareProduct: { |
| 171 | softwareProductAttachments: { heatSetup, heatSetupCache } |
| 172 | } |
| 173 | } = store.getState(); |
| 174 | let heatSetupPopupPromise = |
| 175 | currentScreen.screen === |
| 176 | enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS |
| 177 | ? HeatSetupActionHelper.heatSetupLeaveConfirmation( |
| 178 | dispatch, |
| 179 | { softwareProductId, heatSetup, heatSetupCache } |
| 180 | ) |
| 181 | : Promise.resolve(); |
| 182 | Promise.all([preNavigate, heatSetupPopupPromise]) |
| 183 | .then(() => { |
| 184 | this.prevSelectedKeys = selectedKeys; |
| 185 | if (selectedKeys.length === 0) { |
| 186 | ScreensHelper.loadScreen(dispatch, { |
| 187 | screen: enums.SCREEN.ONBOARDING_CATALOG |
| 188 | }); |
| 189 | } else if ( |
| 190 | selectedKeys.length === 1 || |
| 191 | selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL |
| 192 | ) { |
| 193 | let [ |
| 194 | licenseModelId, |
| 195 | , |
| 196 | licenseModelScreen |
| 197 | ] = selectedKeys; |
| 198 | let licenseModel = wholeLicenseModelList.find( |
| 199 | vlm => vlm.id === licenseModelId |
| 200 | ); |
| 201 | ScreensHelper.loadScreen(dispatch, { |
| 202 | screen: licenseModelScreen, |
| 203 | screenType: screenTypes.LICENSE_MODEL, |
| 204 | props: { |
| 205 | licenseModelId, |
| 206 | version, |
| 207 | licenseModel, |
| 208 | usersList |
| 209 | } |
| 210 | }); |
| 211 | } else if ( |
| 212 | selectedKeys.length <= 4 && |
| 213 | selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT |
| 214 | ) { |
| 215 | let [ |
| 216 | licenseModelId, |
| 217 | , |
| 218 | softwareProductId, |
| 219 | softwareProductScreen |
| 220 | ] = selectedKeys; |
| 221 | let softwareProduct = softwareProductId |
| 222 | ? wholeSoftwareProductList.find( |
| 223 | ({ id }) => id === softwareProductId |
| 224 | ) |
| 225 | : wholeSoftwareProductList.find( |
| 226 | ({ vendorId }) => vendorId === licenseModelId |
| 227 | ); |
| 228 | if (!softwareProductId) { |
| 229 | softwareProductId = softwareProduct.id; |
| 230 | } |
| 231 | if ( |
| 232 | softwareProductScreen === |
| 233 | enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS |
| 234 | ) { |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 235 | softwareProduct = { ...vspData }; |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 236 | //check current vsp fields to determine which file has uploaded |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 237 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 238 | if ( |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 239 | vspData.onboardingOrigin.toLowerCase() === |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 240 | onboardingOriginTypes.ZIP || |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 241 | vspData.candidateOnboardingOrigin.toLowerCase() === |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 242 | onboardingOriginTypes.ZIP |
| 243 | ) { |
| 244 | softwareProductScreen = |
| 245 | enums.SCREEN |
| 246 | .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; |
| 247 | } else if ( |
| 248 | vspData.onboardingOrigin === |
| 249 | onboardingOriginTypes.CSAR |
| 250 | ) { |
| 251 | softwareProductScreen = |
| 252 | enums.SCREEN |
| 253 | .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; |
| 254 | } |
| 255 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 256 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 257 | ScreensHelper.loadScreen(dispatch, { |
| 258 | screen: softwareProductScreen, |
| 259 | screenType: screenTypes.SOFTWARE_PRODUCT, |
| 260 | props: { |
| 261 | softwareProductId, |
| 262 | softwareProduct, |
| 263 | version, |
| 264 | usersList |
| 265 | } |
| 266 | }); |
| 267 | } else if ( |
| 268 | selectedKeys.length === 5 && |
| 269 | selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && |
| 270 | selectedKeys[3] === |
| 271 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS |
| 272 | ) { |
| 273 | let [ |
| 274 | licenseModelId, |
| 275 | , |
| 276 | softwareProductId, |
| 277 | , |
| 278 | componentId |
| 279 | ] = selectedKeys; |
| 280 | let softwareProduct = softwareProductId |
| 281 | ? wholeSoftwareProductList.find( |
| 282 | ({ id }) => id === softwareProductId |
| 283 | ) |
| 284 | : wholeSoftwareProductList.find( |
| 285 | ({ vendorId }) => vendorId === licenseModelId |
| 286 | ); |
| 287 | if (!softwareProductId) { |
| 288 | softwareProductId = softwareProduct.id; |
| 289 | } |
| 290 | ScreensHelper.loadScreen(dispatch, { |
| 291 | screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, |
| 292 | screenType: screenTypes.SOFTWARE_PRODUCT, |
| 293 | props: { |
| 294 | softwareProductId, |
| 295 | softwareProduct, |
| 296 | componentId, |
| 297 | version, |
| 298 | usersList |
| 299 | } |
| 300 | }); |
| 301 | } else if ( |
| 302 | selectedKeys.length === 6 && |
| 303 | selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && |
| 304 | selectedKeys[3] === |
| 305 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS |
| 306 | ) { |
| 307 | let [ |
| 308 | licenseModelId, |
| 309 | , |
| 310 | softwareProductId, |
| 311 | , |
| 312 | componentId, |
| 313 | componentScreen |
| 314 | ] = selectedKeys; |
| 315 | let softwareProduct = softwareProductId |
| 316 | ? wholeSoftwareProductList.find( |
| 317 | ({ id }) => id === softwareProductId |
| 318 | ) |
| 319 | : wholeSoftwareProductList.find( |
| 320 | ({ vendorId }) => vendorId === licenseModelId |
| 321 | ); |
| 322 | if (!softwareProductId) { |
| 323 | softwareProductId = softwareProduct.id; |
| 324 | } |
| 325 | ScreensHelper.loadScreen(dispatch, { |
| 326 | screen: componentScreen, |
| 327 | screenType: screenTypes.SOFTWARE_PRODUCT, |
| 328 | props: { |
| 329 | softwareProductId, |
| 330 | softwareProduct, |
| 331 | componentId, |
| 332 | version, |
| 333 | usersList |
| 334 | } |
| 335 | }); |
| 336 | } else { |
| 337 | console.error( |
| 338 | 'Unknown breadcrumbs path: ', |
| 339 | selectedKeys |
| 340 | ); |
| 341 | } |
| 342 | }) |
| 343 | .catch(() => { |
| 344 | store.dispatch({ |
| 345 | type: actionTypes.SET_CURRENT_SCREEN, |
| 346 | currentScreen: { |
| 347 | ...currentScreen, |
| 348 | forceBreadCrumbsUpdate: true |
| 349 | } |
| 350 | }); |
| 351 | }); |
| 352 | } |
| 353 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 354 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 355 | handleStoreChange() { |
| 356 | let { |
| 357 | currentScreen, |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 358 | versionsPage: { versionsList: { itemType, itemId } }, |
| 359 | softwareProduct: { |
| 360 | softwareProductEditor: { |
| 361 | data: currentSoftwareProduct = { onboardingMethod: '' } |
| 362 | }, |
| 363 | softwareProductComponents: { componentsList } |
| 364 | }, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 365 | licenseModel: { |
| 366 | licenseModelEditor: { data: currentLicenseModel = {} } |
| 367 | } |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 368 | } = store.getState(); |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 369 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 370 | let breadcrumbsData = { |
| 371 | itemType, |
| 372 | itemId, |
| 373 | currentScreen, |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 374 | currentSoftwareProduct, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 375 | currentLicenseModel, |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 376 | componentsList |
| 377 | }; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 378 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 379 | if ( |
| 380 | currentScreen.forceBreadCrumbsUpdate || |
| 381 | !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || |
| 382 | this.breadcrumbsPrefixSelected |
| 383 | ) { |
| 384 | this.prevBreadcrumbsData = breadcrumbsData; |
| 385 | this.breadcrumbsPrefixSelected = false; |
| 386 | this.programmaticBreadcrumbsUpdate = true; |
| 387 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 388 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
| 389 | store.dispatch({ |
| 390 | type: actionTypes.SET_CURRENT_SCREEN, |
| 391 | currentScreen: { |
| 392 | ...currentScreen, |
| 393 | forceBreadCrumbsUpdate: false |
| 394 | } |
| 395 | }); |
| 396 | } |
| 397 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 398 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 399 | buildBreadcrumbs({ |
| 400 | currentScreen: { screen, props }, |
| 401 | itemType, |
| 402 | itemId, |
| 403 | currentSoftwareProduct, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 404 | currentLicenseModel, |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 405 | componentsList |
| 406 | }) { |
| 407 | let { |
| 408 | onboardingMethod, |
| 409 | onboardingOrigin, |
| 410 | candidateOnboardingOrigin |
| 411 | } = currentSoftwareProduct; |
| 412 | let screenToBreadcrumb; |
| 413 | switch (screen) { |
| 414 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 415 | return []; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 416 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 417 | case enums.SCREEN.VERSIONS_PAGE: |
| 418 | let firstMenuItems = |
| 419 | itemType === itemTypes.LICENSE_MODEL |
| 420 | ? [ |
| 421 | { |
| 422 | selectedKey: itemId, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 423 | menuItems: [ |
| 424 | { |
| 425 | key: itemId, |
| 426 | displayText: props.itemName |
| 427 | } |
| 428 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 429 | } |
| 430 | ] |
| 431 | : [ |
| 432 | { |
| 433 | selectedKey: |
| 434 | props.additionalProps.licenseModelId || |
| 435 | currentSoftwareProduct.vendorId, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 436 | menuItems: [ |
| 437 | { |
| 438 | key: props.vendorId, |
| 439 | displayText: props.vendorName |
| 440 | } |
| 441 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 442 | }, |
| 443 | { |
| 444 | selectedKey: |
| 445 | enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 446 | menuItems: [ |
| 447 | { |
| 448 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 449 | displayText: i18n('License Model') |
| 450 | }, |
| 451 | { |
| 452 | key: |
| 453 | enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 454 | displayText: i18n('Software Products') |
| 455 | } |
| 456 | ] |
| 457 | }, |
| 458 | { |
| 459 | selectedKey: itemId, |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 460 | menuItems: [ |
| 461 | { |
| 462 | key: itemId, |
| 463 | displayText: props.itemName |
| 464 | } |
| 465 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 466 | } |
| 467 | ]; |
| 468 | return [ |
| 469 | ...firstMenuItems, |
| 470 | { |
| 471 | selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, |
| 472 | menuItems: [ |
| 473 | { |
| 474 | key: enums.BREADCRUMS.VERSIONS_PAGE, |
| 475 | displayText: i18n('Versions Page') |
| 476 | } |
| 477 | ] |
| 478 | } |
| 479 | ]; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 480 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 481 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 482 | case enums.SCREEN.FEATURE_GROUPS: |
| 483 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 484 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
| 485 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 486 | case enums.SCREEN.ACTIVITY_LOG: |
| 487 | screenToBreadcrumb = { |
| 488 | [enums.SCREEN.LICENSE_AGREEMENTS]: |
| 489 | enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 490 | [enums.SCREEN.FEATURE_GROUPS]: |
| 491 | enums.BREADCRUMS.FEATURE_GROUPS, |
| 492 | [enums.SCREEN.ENTITLEMENT_POOLS]: |
| 493 | enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 494 | [enums.SCREEN.LICENSE_KEY_GROUPS]: |
| 495 | enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 496 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: |
| 497 | enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 498 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
| 499 | }; |
| 500 | return [ |
| 501 | { |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 502 | selectedKey: currentLicenseModel.id, |
| 503 | menuItems: [ |
| 504 | { |
| 505 | key: currentLicenseModel.id, |
| 506 | displayText: currentLicenseModel.vendorName |
| 507 | } |
| 508 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 509 | }, |
| 510 | { |
| 511 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 512 | menuItems: [ |
| 513 | { |
| 514 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 515 | displayText: i18n('License Model') |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 516 | } |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 517 | ] |
| 518 | }, |
| 519 | { |
| 520 | selectedKey: screenToBreadcrumb[screen], |
| 521 | menuItems: [ |
| 522 | { |
| 523 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 524 | displayText: i18n('Overview') |
| 525 | }, |
| 526 | { |
| 527 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 528 | displayText: i18n('License Agreements') |
| 529 | }, |
| 530 | { |
| 531 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 532 | displayText: i18n('Feature Groups') |
| 533 | }, |
| 534 | { |
| 535 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 536 | displayText: i18n('Entitlement Pools') |
| 537 | }, |
| 538 | { |
| 539 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 540 | displayText: i18n('License Key Groups') |
| 541 | }, |
| 542 | { |
| 543 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 544 | displayText: i18n('Activity Log') |
| 545 | } |
| 546 | ] |
| 547 | } |
| 548 | ]; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 549 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 550 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 551 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 552 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 553 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
| 554 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
| 555 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
| 556 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 557 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
| 558 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 559 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 560 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 561 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 562 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 563 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 564 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 565 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
| 566 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
| 567 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 568 | screenToBreadcrumb = { |
| 569 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: |
| 570 | enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 571 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: |
| 572 | enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 573 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: |
| 574 | enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 575 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: |
| 576 | enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 577 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: |
| 578 | enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 579 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: |
| 580 | enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 581 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: |
| 582 | enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 583 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: |
| 584 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 585 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: |
| 586 | enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
| 587 | }; |
| 588 | let componentScreenToBreadcrumb = { |
| 589 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: |
| 590 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 591 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: |
| 592 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 593 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: |
| 594 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 595 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: |
| 596 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 597 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: |
| 598 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 599 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: |
| 600 | enums.BREADCRUMS |
| 601 | .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 602 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: |
| 603 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 604 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: |
| 605 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 606 | }; |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 607 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 608 | let returnedBreadcrumb = [ |
| 609 | { |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 610 | selectedKey: currentSoftwareProduct.vendorId, |
| 611 | menuItems: [ |
| 612 | { |
| 613 | key: currentSoftwareProduct.vendorId, |
| 614 | displayText: currentSoftwareProduct.vendorName |
| 615 | } |
| 616 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 617 | }, |
| 618 | { |
| 619 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 620 | menuItems: [ |
| 621 | { |
| 622 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 623 | displayText: i18n('License Model') |
| 624 | }, |
| 625 | { |
| 626 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 627 | displayText: i18n('Software Products') |
| 628 | } |
| 629 | ] |
| 630 | }, |
| 631 | { |
svishnev | ea5e43c | 2018-04-15 09:06:57 +0300 | [diff] [blame] | 632 | selectedKey: currentSoftwareProduct.id, |
| 633 | menuItems: [ |
| 634 | { |
| 635 | key: currentSoftwareProduct.id, |
| 636 | displayText: currentSoftwareProduct.name |
| 637 | } |
| 638 | ] |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 639 | }, |
| 640 | .../*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [ |
| 641 | { |
| 642 | selectedKey: |
| 643 | screenToBreadcrumb[screen] || |
| 644 | enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 645 | menuItems: [ |
| 646 | { |
| 647 | key: |
| 648 | enums.BREADCRUMS |
| 649 | .SOFTWARE_PRODUCT_LANDING_PAGE, |
| 650 | displayText: i18n('Overview') |
| 651 | }, |
| 652 | { |
| 653 | key: |
| 654 | enums.BREADCRUMS |
| 655 | .SOFTWARE_PRODUCT_DETAILS, |
| 656 | displayText: i18n('General') |
| 657 | }, |
| 658 | { |
| 659 | key: |
| 660 | enums.BREADCRUMS |
| 661 | .SOFTWARE_PRODUCT_DEPLOYMENT, |
| 662 | displayText: i18n('Deployment Flavors') |
| 663 | }, |
| 664 | { |
| 665 | key: |
| 666 | enums.BREADCRUMS |
| 667 | .SOFTWARE_PRODUCT_PROCESSES, |
| 668 | displayText: i18n('Process Details') |
| 669 | }, |
| 670 | { |
| 671 | key: |
| 672 | enums.BREADCRUMS |
| 673 | .SOFTWARE_PRODUCT_NETWORKS, |
| 674 | displayText: i18n('Networks') |
| 675 | }, |
| 676 | { |
| 677 | key: |
| 678 | enums.BREADCRUMS |
| 679 | .SOFTWARE_PRODUCT_DEPENDENCIES, |
| 680 | displayText: i18n('Components Dependencies') |
| 681 | }, |
| 682 | { |
| 683 | key: |
| 684 | enums.BREADCRUMS |
| 685 | .SOFTWARE_PRODUCT_ATTACHMENTS, |
| 686 | displayText: i18n('Attachments') |
| 687 | }, |
| 688 | { |
| 689 | key: |
| 690 | enums.BREADCRUMS |
| 691 | .SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 692 | displayText: i18n('Activity Log') |
| 693 | }, |
| 694 | { |
| 695 | key: |
| 696 | enums.BREADCRUMS |
| 697 | .SOFTWARE_PRODUCT_COMPONENTS, |
| 698 | displayText: i18n('Components') |
| 699 | } |
| 700 | ].filter(item => { |
| 701 | switch (item.key) { |
| 702 | case enums.BREADCRUMS |
| 703 | .SOFTWARE_PRODUCT_ATTACHMENTS: |
| 704 | let isHeatData = |
| 705 | onboardingOrigin !== |
| 706 | onboardingOriginTypes.NONE || |
| 707 | candidateOnboardingOrigin === |
| 708 | onboardingOriginTypes.ZIP; |
| 709 | return isHeatData; |
| 710 | case enums.BREADCRUMS |
| 711 | .SOFTWARE_PRODUCT_COMPONENTS: |
| 712 | return componentsList.length > 0; |
| 713 | case enums.BREADCRUMS |
| 714 | .SOFTWARE_PRODUCT_DEPLOYMENT: |
| 715 | let isManualMode = |
| 716 | onboardingMethod === |
| 717 | onboardingMethodTypes.MANUAL; |
| 718 | return isManualMode; |
| 719 | case enums.BREADCRUMS |
| 720 | .SOFTWARE_PRODUCT_DEPENDENCIES: |
| 721 | return componentsList.length > 1; |
| 722 | default: |
| 723 | return true; |
| 724 | } |
| 725 | }) |
| 726 | } |
| 727 | ] |
| 728 | ]; |
| 729 | if (props.componentId) { |
| 730 | returnedBreadcrumb = [ |
| 731 | ...returnedBreadcrumb, |
| 732 | { |
| 733 | selectedKey: props.componentId, |
| 734 | menuItems: componentsList.map( |
| 735 | ({ id, displayName }) => ({ |
| 736 | key: id, |
| 737 | displayText: displayName |
| 738 | }) |
| 739 | ) |
| 740 | }, |
| 741 | ...[ |
| 742 | { |
| 743 | selectedKey: |
| 744 | componentScreenToBreadcrumb[screen], |
| 745 | menuItems: [ |
| 746 | { |
| 747 | key: |
| 748 | enums.BREADCRUMS |
| 749 | .SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 750 | displayText: i18n('General') |
| 751 | }, |
| 752 | { |
| 753 | key: |
| 754 | enums.BREADCRUMS |
| 755 | .SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 756 | displayText: i18n('Compute') |
| 757 | }, |
| 758 | { |
| 759 | key: |
| 760 | enums.BREADCRUMS |
| 761 | .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 762 | displayText: i18n( |
| 763 | 'High Availability & Load Balancing' |
| 764 | ) |
| 765 | }, |
| 766 | { |
| 767 | key: |
| 768 | enums.BREADCRUMS |
| 769 | .SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 770 | displayText: i18n('Networks') |
| 771 | }, |
| 772 | { |
| 773 | key: |
| 774 | enums.BREADCRUMS |
| 775 | .SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 776 | displayText: i18n('Storage') |
| 777 | }, |
| 778 | { |
| 779 | key: |
| 780 | enums.BREADCRUMS |
| 781 | .SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 782 | displayText: i18n('Images') |
| 783 | }, |
| 784 | { |
| 785 | key: |
| 786 | enums.BREADCRUMS |
| 787 | .SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 788 | displayText: i18n('Process Details') |
| 789 | }, |
| 790 | { |
| 791 | key: |
| 792 | enums.BREADCRUMS |
| 793 | .SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 794 | displayText: i18n('Monitoring') |
| 795 | } |
| 796 | ] |
| 797 | } |
| 798 | ] |
| 799 | ]; |
| 800 | } |
| 801 | return returnedBreadcrumb; |
| 802 | } |
| 803 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 804 | } |