svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2017 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; |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 83 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | |
| 87 | unmount(element) { |
| 88 | ReactDOM.unmountComponentAtNode(element); |
| 89 | this.rendered = false; |
| 90 | this.unsubscribeFromStore(); |
| 91 | this.unsubscribeFromStore = null; |
| 92 | } |
| 93 | |
| 94 | handleData(data) { |
| 95 | let {breadcrumbs: {selectedKeys = []} = {}} = data; |
| 96 | let dispatch = action => store.dispatch(action); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 97 | let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList, |
| 98 | softwareProduct: {softwareProductEditor: {data: vspData = {}}, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 99 | softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState(); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 100 | const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; |
| 101 | const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList]; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 102 | |
| 103 | let {props: {version, isReadOnlyMode}, screen} = currentScreen; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 104 | let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 105 | if (this.programmaticBreadcrumbsUpdate) { |
| 106 | this.prevSelectedKeys = selectedKeys; |
| 107 | this.programmaticBreadcrumbsUpdate = false; |
| 108 | return; |
| 109 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 110 | if (!isEqual(selectedKeys, this.prevSelectedKeys)) { |
| 111 | this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length)); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 112 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 113 | const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; |
| 114 | let preNavigate = Promise.resolve(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 115 | if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 116 | let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 117 | preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 118 | softwareProductId: prevVspId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 119 | version, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 120 | vspComponentId: prevComponentId, |
| 121 | dataToSave |
| 122 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 123 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 124 | |
| 125 | let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState(); |
| 126 | let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 127 | HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : |
| 128 | Promise.resolve(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 129 | Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { |
| 130 | this.prevSelectedKeys = selectedKeys; |
| 131 | if (selectedKeys.length === 0) { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 132 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG}); |
| 133 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 134 | } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { |
| 135 | let [licenseModelId, , licenseModelScreen] = selectedKeys; |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 136 | let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 137 | ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL, |
| 138 | props: {licenseModelId, version, licenseModel, usersList}}); |
| 139 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 140 | } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { |
| 141 | let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; |
| 142 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 143 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 144 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 145 | if (!softwareProductId) { |
| 146 | softwareProductId = softwareProduct.id; |
| 147 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 148 | if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) { |
| 149 | softwareProduct = vspData; |
| 150 | //check current vsp fields to determine which file has uploaded |
| 151 | if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) { |
| 152 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; |
| 153 | } |
| 154 | else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) { |
| 155 | softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; |
| 156 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 157 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 158 | |
| 159 | ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 160 | props: {softwareProductId, softwareProduct, version, usersList}}); |
| 161 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 162 | } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 163 | let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; |
| 164 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 165 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 166 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 167 | if (!softwareProductId) { |
| 168 | softwareProductId = softwareProduct.id; |
| 169 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 170 | ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 171 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 172 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 173 | } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { |
| 174 | let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; |
| 175 | let softwareProduct = softwareProductId ? |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 176 | wholeSoftwareProductList.find(({id}) => id === softwareProductId) : |
| 177 | wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 178 | if (!softwareProductId) { |
| 179 | softwareProductId = softwareProduct.id; |
| 180 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 181 | ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT, |
| 182 | props: {softwareProductId, softwareProduct, componentId, version, usersList}}); |
| 183 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 184 | } else { |
| 185 | console.error('Unknown breadcrumbs path: ', selectedKeys); |
| 186 | } |
| 187 | }).catch(() => { |
| 188 | store.dispatch({ |
| 189 | type: actionTypes.SET_CURRENT_SCREEN, |
| 190 | currentScreen: { |
| 191 | ...currentScreen, |
| 192 | forceBreadCrumbsUpdate: true |
| 193 | } |
| 194 | }); |
| 195 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
| 199 | handleStoreChange() { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 200 | let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage: |
| 201 | {versionsList: {itemType, itemId}}, |
| 202 | softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}}, |
shrek2000 | c8a540b | 2017-09-11 15:45:37 +0300 | [diff] [blame] | 203 | softwareProductComponents: {componentsList}}} = store.getState(); |
miriame | d411d15 | 2018-01-02 15:35:55 +0200 | [diff] [blame] | 204 | const wholeSoftwareProductList = lodashUnionBy(softwareProductList, finalizedSoftwareProductList, 'id'); |
| 205 | const wholeLicenseModelList = lodashUnionBy(licenseModelList, finalizedLicenseModelList, 'id'); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 206 | let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList}; |
| 207 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 208 | if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 209 | this.prevBreadcrumbsData = breadcrumbsData; |
| 210 | this.breadcrumbsPrefixSelected = false; |
| 211 | this.programmaticBreadcrumbsUpdate = true; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 212 | let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); |
| 213 | this.onEvent('breadcrumbsupdated', breadcrumbs); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 214 | store.dispatch({ |
| 215 | type: actionTypes.SET_CURRENT_SCREEN, |
| 216 | currentScreen: { |
| 217 | ...currentScreen, |
| 218 | forceBreadCrumbsUpdate: false |
| 219 | } |
| 220 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 224 | buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct, |
| 225 | wholeLicenseModelList, wholeSoftwareProductList, componentsList}) { |
| 226 | let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 227 | let screenToBreadcrumb; |
| 228 | switch (screen) { |
| 229 | case enums.SCREEN.ONBOARDING_CATALOG: |
| 230 | return []; |
| 231 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 232 | case enums.SCREEN.VERSIONS_PAGE: |
| 233 | let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [ |
| 234 | { |
| 235 | selectedKey: itemId, |
| 236 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 237 | key: id, |
| 238 | displayText: name |
| 239 | })) |
| 240 | }] : [ |
| 241 | { |
| 242 | selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId, |
| 243 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
| 244 | key: id, |
| 245 | displayText: name |
| 246 | })) |
| 247 | }, |
| 248 | { |
| 249 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 250 | menuItems: [{ |
| 251 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 252 | displayText: i18n('License Model') |
| 253 | }, { |
| 254 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 255 | displayText: i18n('Software Products') |
| 256 | }] |
| 257 | }, |
| 258 | { |
| 259 | selectedKey: itemId, |
| 260 | menuItems: wholeSoftwareProductList |
| 261 | .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId) |
| 262 | .map(({id, name}) => ({ |
| 263 | key: id, |
| 264 | displayText: name |
| 265 | })) |
| 266 | }, |
| 267 | ]; |
| 268 | return [ |
| 269 | ...firstMenuItems, |
| 270 | { |
| 271 | selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, |
| 272 | menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}] |
| 273 | } |
| 274 | ]; |
| 275 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 276 | case enums.SCREEN.LICENSE_AGREEMENTS: |
| 277 | case enums.SCREEN.FEATURE_GROUPS: |
| 278 | case enums.SCREEN.ENTITLEMENT_POOLS: |
| 279 | case enums.SCREEN.LICENSE_KEY_GROUPS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 280 | case enums.SCREEN.LICENSE_MODEL_OVERVIEW: |
| 281 | case enums.SCREEN.ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 282 | screenToBreadcrumb = { |
| 283 | [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 284 | [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, |
| 285 | [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 286 | [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 287 | [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 288 | [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 289 | }; |
| 290 | return [ |
| 291 | { |
| 292 | selectedKey: props.licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 293 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 294 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 295 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 296 | })) |
| 297 | }, |
| 298 | { |
| 299 | selectedKey: enums.BREADCRUMS.LICENSE_MODEL, |
| 300 | menuItems: [{ |
| 301 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 302 | displayText: i18n('License Model') |
| 303 | }, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 304 | ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ |
| 305 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 306 | displayText: i18n('Software Products') |
| 307 | }])] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 308 | }, { |
| 309 | selectedKey: screenToBreadcrumb[screen], |
| 310 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 311 | key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, |
| 312 | displayText: i18n('Overview') |
| 313 | },{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 314 | key: enums.BREADCRUMS.LICENSE_AGREEMENTS, |
| 315 | displayText: i18n('License Agreements') |
| 316 | }, { |
| 317 | key: enums.BREADCRUMS.FEATURE_GROUPS, |
| 318 | displayText: i18n('Feature Groups') |
| 319 | }, { |
| 320 | key: enums.BREADCRUMS.ENTITLEMENT_POOLS, |
| 321 | displayText: i18n('Entitlement Pools') |
| 322 | }, { |
| 323 | key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, |
| 324 | displayText: i18n('License Key Groups') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 325 | }, { |
| 326 | key: enums.BREADCRUMS.ACTIVITY_LOG, |
| 327 | displayText: i18n('Activity Log') |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 328 | }] |
| 329 | } |
| 330 | ]; |
| 331 | |
| 332 | case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: |
| 333 | case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: |
| 334 | case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: |
| 335 | case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 336 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 337 | case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 338 | case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: |
| 339 | case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 340 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: |
| 341 | |
| 342 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: |
| 343 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: |
| 344 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: |
| 345 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: |
| 346 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: |
| 347 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 348 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 349 | case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: |
| 350 | screenToBreadcrumb = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 351 | [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 352 | [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 353 | [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 354 | [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 355 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 356 | [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 357 | [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 358 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 359 | [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 360 | }; |
| 361 | let componentScreenToBreadcrumb = { |
| 362 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 363 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 364 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 365 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 366 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 367 | [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] | 368 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 369 | [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING |
| 370 | }; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 371 | let licenseModelId = currentSoftwareProduct.vendorId; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 372 | let returnedBreadcrumb = [ |
| 373 | { |
| 374 | selectedKey: licenseModelId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 375 | menuItems: wholeLicenseModelList.map(({id, name}) => ({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 376 | key: id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 377 | displayText: name |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 378 | })) |
| 379 | }, |
| 380 | { |
| 381 | selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 382 | menuItems: [{ |
| 383 | key: enums.BREADCRUMS.LICENSE_MODEL, |
| 384 | displayText: i18n('License Model') |
| 385 | }, { |
| 386 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT, |
| 387 | displayText: i18n('Software Products') |
| 388 | }] |
| 389 | }, |
| 390 | { |
| 391 | selectedKey: props.softwareProductId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 392 | menuItems: wholeSoftwareProductList |
| 393 | .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 394 | .map(({id, name}) => ({ |
| 395 | key: id, |
| 396 | displayText: name |
| 397 | })) |
| 398 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 399 | ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 400 | selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 401 | menuItems: [{ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 402 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, |
| 403 | displayText: i18n('Overview') |
| 404 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 405 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, |
| 406 | displayText: i18n('General') |
| 407 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 408 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, |
| 409 | displayText: i18n('Deployment Flavors') |
| 410 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 411 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, |
| 412 | displayText: i18n('Process Details') |
| 413 | }, { |
| 414 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, |
| 415 | displayText: i18n('Networks') |
| 416 | }, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 417 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, |
| 418 | displayText: i18n('Components Dependencies') |
| 419 | }, { |
| 420 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, |
| 421 | displayText: i18n('Attachments') |
| 422 | }, { |
| 423 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, |
| 424 | displayText: i18n('Activity Log') |
| 425 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 426 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, |
| 427 | displayText: i18n('Components') |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 428 | }].filter(item => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 429 | switch (item.key) { |
| 430 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 431 | let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 432 | return isHeatData; |
| 433 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 434 | return (componentsList.length > 0); |
| 435 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 436 | let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 437 | return isManualMode; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 438 | case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 439 | return (componentsList.length > 1); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 440 | default: |
| 441 | return true; |
| 442 | } |
| 443 | }) |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 444 | }]) |
| 445 | ]; |
| 446 | if(props.componentId) { |
| 447 | returnedBreadcrumb = [ |
| 448 | ...returnedBreadcrumb, { |
| 449 | selectedKey: props.componentId, |
| 450 | menuItems: componentsList |
| 451 | .map(({id, displayName}) => ({ |
| 452 | key: id, |
| 453 | displayText: displayName |
| 454 | })) |
| 455 | }, |
| 456 | ...[{ |
| 457 | selectedKey: componentScreenToBreadcrumb[screen], |
| 458 | menuItems: [{ |
| 459 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, |
| 460 | displayText: i18n('General') |
| 461 | }, { |
| 462 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, |
| 463 | displayText: i18n('Compute') |
| 464 | }, { |
| 465 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, |
| 466 | displayText: i18n('High Availability & Load Balancing') |
| 467 | }, { |
| 468 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, |
| 469 | displayText: i18n('Networks') |
| 470 | }, { |
| 471 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, |
| 472 | displayText: i18n('Storage') |
| 473 | }, { |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 474 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, |
| 475 | displayText: i18n('Images') |
| 476 | }, { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 477 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, |
| 478 | displayText: i18n('Process Details') |
| 479 | }, { |
| 480 | key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, |
| 481 | displayText: i18n('Monitoring') |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 482 | }] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 483 | }] |
| 484 | ]; |
| 485 | } |
| 486 | return returnedBreadcrumb; |
| 487 | } |
| 488 | } |
| 489 | } |