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