blob: d50fcccf09b4b37e2c652483358e9e062c58ef0b [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
svishnev091edfd2018-03-19 12:15:19 +02002 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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
svishnev1eb66b72018-01-11 14:39:45 +02007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
AviZi280f8012017-06-09 02:39:56 +030010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
svishnev1eb66b72018-01-11 14:39:45 +020012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
svishnev1eb66b72018-01-11 14:39:45 +020016
Michael Landoefa037d2017-02-19 12:57:33 +020017import React from 'react';
svishnev1eb66b72018-01-11 14:39:45 +020018
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020019import { render } from 'react-dom';
Michael Landoefa037d2017-02-19 12:57:33 +020020import ReactDOM from 'react-dom';
svishnev1eb66b72018-01-11 14:39:45 +020021
Michael Landoefa037d2017-02-19 12:57:33 +020022import isEqual from 'lodash/isEqual.js';
svishnev1eb66b72018-01-11 14:39:45 +020023
Michael Landoefa037d2017-02-19 12:57:33 +020024import i18n from 'nfvo-utils/i18n/i18n.js';
25import Application from 'sdc-app/Application.jsx';
26import store from 'sdc-app/AppStore.js';
27import Configuration from 'sdc-app/config/Configuration.js';
talig8e9c0652017-12-20 14:30:43 +020028import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
Vodafone804ec682019-03-18 15:46:53 +053029import ConfigHelper from 'sdc-app/common/helpers/ConfigHelper.js';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020030import {
31 onboardingMethod as onboardingMethodTypes,
32 onboardingOriginTypes
33} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
AviZi280f8012017-06-09 02:39:56 +030034
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020035import { itemTypes } from './versionsPage/VersionsPageConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030036
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020037import { AppContainer } from 'react-hot-loader';
AviZi280f8012017-06-09 02:39:56 +030038import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
39
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020040import { actionTypes, enums, screenTypes } from './OnboardingConstants.js';
Vodafone804ec682019-03-18 15:46:53 +053041import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020042import OnboardingActionHelper from './OnboardingActionHelper.js';
svishnev1eb66b72018-01-11 14:39:45 +020043import Onboarding from './Onboarding.js';
Michael Landoefa037d2017-02-19 12:57:33 +020044
Vodafone804ec682019-03-18 15:46:53 +053045ConfigHelper.fetchVspConfig()
46 .then(response => {
47 let dispatch = action => store.dispatch(action);
48 OnboardingActionHelper.saveIsValidationDisabled(dispatch, {
49 isValidationDisabled:
50 response.enabled === undefined || response.enabled === ''
51 ? true
52 : !response.enabled
53 });
54 })
55 .catch(error => {
56 let dispatch = action => store.dispatch(action);
57 dispatch({
58 type: modalActionTypes.GLOBAL_MODAL_ERROR,
59 data: {
60 title: i18n('ERROR'),
61 msg: error.message || error.responseJSON.message,
62 cancelButtonText: i18n('OK')
63 }
64 });
65 });
66
Michael Landoefa037d2017-02-19 12:57:33 +020067export default class OnboardingPunchOut {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020068 render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) {
69 if (!this.unsubscribeFromStore) {
70 this.unsubscribeFromStore = store.subscribe(() =>
71 this.handleStoreChange()
72 );
73 }
Michael Landoefa037d2017-02-19 12:57:33 +020074
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020075 if (!this.isConfigSet) {
76 Configuration.setCatalogApiRoot(apiRoot);
77 Configuration.setCatalogApiHeaders(apiHeaders);
78 this.isConfigSet = true;
79 }
Michael Landoefa037d2017-02-19 12:57:33 +020080
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020081 this.onEvent = (...args) => onEvent(...args);
82 this.handleData(data);
Michael Landoefa037d2017-02-19 12:57:33 +020083
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020084 if (!this.rendered) {
85 render(
86 <AppContainer>
87 <Application>
88 <Onboarding />
89 </Application>
90 </AppContainer>,
91 element
92 );
93 if (module.hot) {
94 module.hot.accept('sdc-app/onboarding/Onboarding.js', () => {
95 const NextOnboarding = require('sdc-app/onboarding/Onboarding.js')
96 .default;
97 render(
98 <AppContainer>
99 <Application>
100 <NextOnboarding />
101 </Application>
102 </AppContainer>,
103 element
104 );
105 });
106 }
107 this.rendered = true;
108 }
109 }
Michael Landoefa037d2017-02-19 12:57:33 +0200110
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200111 unmount(element) {
112 ReactDOM.unmountComponentAtNode(element);
113 this.rendered = false;
114 this.unsubscribeFromStore();
115 this.unsubscribeFromStore = null;
116 }
Michael Landoefa037d2017-02-19 12:57:33 +0200117
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200118 handleData(data) {
119 let { breadcrumbs: { selectedKeys = [] } = {} } = data;
120 let dispatch = action => store.dispatch(action);
121 let {
122 currentScreen,
123 users: { usersList },
124 softwareProductList,
125 finalizedSoftwareProductList,
126 licenseModelList,
127 finalizedLicenseModelList,
128 softwareProduct: {
129 softwareProductEditor: { data: vspData = {} },
130 softwareProductComponents = {},
131 softwareProductQuestionnaire = {}
132 },
133 archivedLicenseModelList
134 } = store.getState();
135 const wholeSoftwareProductList = [
136 ...softwareProductList,
137 ...finalizedSoftwareProductList
138 ];
139 const wholeLicenseModelList = [
140 ...licenseModelList,
141 ...finalizedLicenseModelList,
142 ...archivedLicenseModelList
143 ];
Michael Landoefa037d2017-02-19 12:57:33 +0200144
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200145 let { props: { version, isReadOnlyMode }, screen } = currentScreen;
146 let {
147 componentEditor: {
148 data: componentData = {},
149 qdata: componentQData = {}
150 }
151 } = softwareProductComponents;
152 if (this.programmaticBreadcrumbsUpdate) {
153 this.prevSelectedKeys = selectedKeys;
154 this.programmaticBreadcrumbsUpdate = false;
155 return;
156 }
157 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
158 this.breadcrumbsPrefixSelected = isEqual(
159 selectedKeys,
160 this.prevSelectedKeys &&
161 this.prevSelectedKeys.slice(0, selectedKeys.length)
162 );
talig8e9c0652017-12-20 14:30:43 +0200163
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200164 const [, screenType, prevVspId, , prevComponentId] =
165 this.prevSelectedKeys || [];
166 let preNavigate = Promise.resolve();
167 if (
168 screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
169 screen !== 'VERSIONS_PAGE' &&
170 !isReadOnlyMode
171 ) {
172 let dataToSave = prevVspId
173 ? prevComponentId
174 ? { componentData, qdata: componentQData }
175 : {
176 softwareProduct: vspData,
177 qdata: softwareProductQuestionnaire.qdata
178 }
179 : {};
180 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(
181 dispatch,
182 {
183 softwareProductId: prevVspId,
184 version,
185 vspComponentId: prevComponentId,
186 dataToSave
187 }
188 );
189 }
Michael Landoefa037d2017-02-19 12:57:33 +0200190
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200191 let {
192 currentScreen: { props: { softwareProductId } },
193 softwareProduct: {
194 softwareProductAttachments: { heatSetup, heatSetupCache }
195 }
196 } = store.getState();
197 let heatSetupPopupPromise =
198 currentScreen.screen ===
199 enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS
200 ? HeatSetupActionHelper.heatSetupLeaveConfirmation(
201 dispatch,
202 { softwareProductId, heatSetup, heatSetupCache }
203 )
204 : Promise.resolve();
205 Promise.all([preNavigate, heatSetupPopupPromise])
206 .then(() => {
207 this.prevSelectedKeys = selectedKeys;
208 if (selectedKeys.length === 0) {
209 ScreensHelper.loadScreen(dispatch, {
210 screen: enums.SCREEN.ONBOARDING_CATALOG
211 });
212 } else if (
213 selectedKeys.length === 1 ||
214 selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL
215 ) {
216 let [
217 licenseModelId,
218 ,
219 licenseModelScreen
220 ] = selectedKeys;
221 let licenseModel = wholeLicenseModelList.find(
222 vlm => vlm.id === licenseModelId
223 );
224 ScreensHelper.loadScreen(dispatch, {
225 screen: licenseModelScreen,
226 screenType: screenTypes.LICENSE_MODEL,
227 props: {
228 licenseModelId,
229 version,
230 licenseModel,
231 usersList
232 }
233 });
234 } else if (
235 selectedKeys.length <= 4 &&
236 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT
237 ) {
238 let [
239 licenseModelId,
240 ,
241 softwareProductId,
242 softwareProductScreen
243 ] = selectedKeys;
244 let softwareProduct = softwareProductId
245 ? wholeSoftwareProductList.find(
246 ({ id }) => id === softwareProductId
247 )
248 : wholeSoftwareProductList.find(
249 ({ vendorId }) => vendorId === licenseModelId
250 );
251 if (!softwareProductId) {
252 softwareProductId = softwareProduct.id;
253 }
254 if (
255 softwareProductScreen ===
256 enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS
257 ) {
svishnev57c5c4a2018-04-22 14:14:31 +0300258 softwareProduct = { ...vspData };
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200259 //check current vsp fields to determine which file has uploaded
svishnev57c5c4a2018-04-22 14:14:31 +0300260
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200261 if (
svishnev57c5c4a2018-04-22 14:14:31 +0300262 vspData.onboardingOrigin.toLowerCase() ===
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200263 onboardingOriginTypes.ZIP ||
svishnev57c5c4a2018-04-22 14:14:31 +0300264 vspData.candidateOnboardingOrigin.toLowerCase() ===
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200265 onboardingOriginTypes.ZIP
266 ) {
267 softwareProductScreen =
268 enums.SCREEN
269 .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
270 } else if (
271 vspData.onboardingOrigin ===
272 onboardingOriginTypes.CSAR
273 ) {
274 softwareProductScreen =
275 enums.SCREEN
276 .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
277 }
278 }
AviZi280f8012017-06-09 02:39:56 +0300279
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200280 ScreensHelper.loadScreen(dispatch, {
281 screen: softwareProductScreen,
282 screenType: screenTypes.SOFTWARE_PRODUCT,
283 props: {
284 softwareProductId,
285 softwareProduct,
286 version,
287 usersList
288 }
289 });
290 } else if (
291 selectedKeys.length === 5 &&
292 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
293 selectedKeys[3] ===
294 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
295 ) {
296 let [
297 licenseModelId,
298 ,
299 softwareProductId,
300 ,
301 componentId
302 ] = selectedKeys;
303 let softwareProduct = softwareProductId
304 ? wholeSoftwareProductList.find(
305 ({ id }) => id === softwareProductId
306 )
307 : wholeSoftwareProductList.find(
308 ({ vendorId }) => vendorId === licenseModelId
309 );
310 if (!softwareProductId) {
311 softwareProductId = softwareProduct.id;
312 }
313 ScreensHelper.loadScreen(dispatch, {
314 screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS,
315 screenType: screenTypes.SOFTWARE_PRODUCT,
316 props: {
317 softwareProductId,
318 softwareProduct,
319 componentId,
320 version,
321 usersList
322 }
323 });
324 } else if (
325 selectedKeys.length === 6 &&
326 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
327 selectedKeys[3] ===
328 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
329 ) {
330 let [
331 licenseModelId,
332 ,
333 softwareProductId,
334 ,
335 componentId,
336 componentScreen
337 ] = selectedKeys;
338 let softwareProduct = softwareProductId
339 ? wholeSoftwareProductList.find(
340 ({ id }) => id === softwareProductId
341 )
342 : wholeSoftwareProductList.find(
343 ({ vendorId }) => vendorId === licenseModelId
344 );
345 if (!softwareProductId) {
346 softwareProductId = softwareProduct.id;
347 }
348 ScreensHelper.loadScreen(dispatch, {
349 screen: componentScreen,
350 screenType: screenTypes.SOFTWARE_PRODUCT,
351 props: {
352 softwareProductId,
353 softwareProduct,
354 componentId,
355 version,
356 usersList
357 }
358 });
359 } else {
360 console.error(
361 'Unknown breadcrumbs path: ',
362 selectedKeys
363 );
364 }
365 })
366 .catch(() => {
367 store.dispatch({
368 type: actionTypes.SET_CURRENT_SCREEN,
369 currentScreen: {
370 ...currentScreen,
371 forceBreadCrumbsUpdate: true
372 }
373 });
374 });
375 }
376 }
talig8e9c0652017-12-20 14:30:43 +0200377
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200378 handleStoreChange() {
379 let {
380 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200381 versionsPage: { versionsList: { itemType, itemId } },
382 softwareProduct: {
383 softwareProductEditor: {
384 data: currentSoftwareProduct = { onboardingMethod: '' }
385 },
Vodafone804ec682019-03-18 15:46:53 +0530386 softwareProductComponents: { componentsList },
387 softwareProductValidation: { isValidationDisabled }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200388 },
svishnevea5e43c2018-04-15 09:06:57 +0300389 licenseModel: {
390 licenseModelEditor: { data: currentLicenseModel = {} }
391 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200392 } = store.getState();
svishnevea5e43c2018-04-15 09:06:57 +0300393
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200394 let breadcrumbsData = {
395 itemType,
396 itemId,
397 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200398 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300399 currentLicenseModel,
Vodafone804ec682019-03-18 15:46:53 +0530400 componentsList,
401 isValidationDisabled
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200402 };
talig8e9c0652017-12-20 14:30:43 +0200403
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200404 if (
405 currentScreen.forceBreadCrumbsUpdate ||
406 !isEqual(breadcrumbsData, this.prevBreadcrumbsData) ||
407 this.breadcrumbsPrefixSelected
408 ) {
409 this.prevBreadcrumbsData = breadcrumbsData;
410 this.breadcrumbsPrefixSelected = false;
411 this.programmaticBreadcrumbsUpdate = true;
412 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
413 this.onEvent('breadcrumbsupdated', breadcrumbs);
414 store.dispatch({
415 type: actionTypes.SET_CURRENT_SCREEN,
416 currentScreen: {
417 ...currentScreen,
418 forceBreadCrumbsUpdate: false
419 }
420 });
421 }
422 }
talig8e9c0652017-12-20 14:30:43 +0200423
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200424 buildBreadcrumbs({
425 currentScreen: { screen, props },
426 itemType,
427 itemId,
428 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300429 currentLicenseModel,
Vodafone804ec682019-03-18 15:46:53 +0530430 componentsList,
431 isValidationDisabled
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200432 }) {
433 let {
434 onboardingMethod,
435 onboardingOrigin,
436 candidateOnboardingOrigin
437 } = currentSoftwareProduct;
438 let screenToBreadcrumb;
439 switch (screen) {
440 case enums.SCREEN.ONBOARDING_CATALOG:
441 return [];
talig8e9c0652017-12-20 14:30:43 +0200442
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200443 case enums.SCREEN.VERSIONS_PAGE:
444 let firstMenuItems =
445 itemType === itemTypes.LICENSE_MODEL
446 ? [
447 {
448 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300449 menuItems: [
450 {
451 key: itemId,
452 displayText: props.itemName
453 }
454 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200455 }
456 ]
457 : [
458 {
459 selectedKey:
460 props.additionalProps.licenseModelId ||
461 currentSoftwareProduct.vendorId,
svishnevea5e43c2018-04-15 09:06:57 +0300462 menuItems: [
463 {
464 key: props.vendorId,
465 displayText: props.vendorName
466 }
467 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200468 },
469 {
470 selectedKey:
471 enums.BREADCRUMS.SOFTWARE_PRODUCT,
472 menuItems: [
473 {
474 key: enums.BREADCRUMS.LICENSE_MODEL,
475 displayText: i18n('License Model')
476 },
477 {
478 key:
479 enums.BREADCRUMS.SOFTWARE_PRODUCT,
480 displayText: i18n('Software Products')
481 }
482 ]
483 },
484 {
485 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300486 menuItems: [
487 {
488 key: itemId,
489 displayText: props.itemName
490 }
491 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200492 }
493 ];
494 return [
495 ...firstMenuItems,
496 {
497 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
498 menuItems: [
499 {
500 key: enums.BREADCRUMS.VERSIONS_PAGE,
501 displayText: i18n('Versions Page')
502 }
503 ]
504 }
505 ];
talig8e9c0652017-12-20 14:30:43 +0200506
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200507 case enums.SCREEN.LICENSE_AGREEMENTS:
508 case enums.SCREEN.FEATURE_GROUPS:
509 case enums.SCREEN.ENTITLEMENT_POOLS:
510 case enums.SCREEN.LICENSE_KEY_GROUPS:
511 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
512 case enums.SCREEN.ACTIVITY_LOG:
513 screenToBreadcrumb = {
514 [enums.SCREEN.LICENSE_AGREEMENTS]:
515 enums.BREADCRUMS.LICENSE_AGREEMENTS,
516 [enums.SCREEN.FEATURE_GROUPS]:
517 enums.BREADCRUMS.FEATURE_GROUPS,
518 [enums.SCREEN.ENTITLEMENT_POOLS]:
519 enums.BREADCRUMS.ENTITLEMENT_POOLS,
520 [enums.SCREEN.LICENSE_KEY_GROUPS]:
521 enums.BREADCRUMS.LICENSE_KEY_GROUPS,
522 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]:
523 enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
524 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
525 };
526 return [
527 {
svishnevea5e43c2018-04-15 09:06:57 +0300528 selectedKey: currentLicenseModel.id,
529 menuItems: [
530 {
531 key: currentLicenseModel.id,
532 displayText: currentLicenseModel.vendorName
533 }
534 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200535 },
536 {
537 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
538 menuItems: [
539 {
540 key: enums.BREADCRUMS.LICENSE_MODEL,
541 displayText: i18n('License Model')
svishnevea5e43c2018-04-15 09:06:57 +0300542 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200543 ]
544 },
545 {
546 selectedKey: screenToBreadcrumb[screen],
547 menuItems: [
548 {
549 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
550 displayText: i18n('Overview')
551 },
552 {
553 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
554 displayText: i18n('License Agreements')
555 },
556 {
557 key: enums.BREADCRUMS.FEATURE_GROUPS,
558 displayText: i18n('Feature Groups')
559 },
560 {
561 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
562 displayText: i18n('Entitlement Pools')
563 },
564 {
565 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
566 displayText: i18n('License Key Groups')
567 },
568 {
569 key: enums.BREADCRUMS.ACTIVITY_LOG,
570 displayText: i18n('Activity Log')
571 }
572 ]
573 }
574 ];
talig8e9c0652017-12-20 14:30:43 +0200575
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200576 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
577 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
578 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
579 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
580 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
581 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
Vodafone804ec682019-03-18 15:46:53 +0530582 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION:
583 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS:
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200584 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
585 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
586 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
Michael Landoefa037d2017-02-19 12:57:33 +0200587
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200588 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
589 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
590 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
591 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
592 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
593 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
594 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
595 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
596 screenToBreadcrumb = {
597 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]:
598 enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
599 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]:
600 enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
601 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]:
602 enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
603 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]:
604 enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
605 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]:
606 enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
607 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]:
608 enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
Vodafone804ec682019-03-18 15:46:53 +0530609 [enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION]:
610 enums.BREADCRUMS.SOFTWARE_PRODUCT_VALIDATION,
611 [enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS]:
612 enums.BREADCRUMS.SOFTWARE_PRODUCT_VALIDATION_RESULTS,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200613 [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 };
svishnevea5e43c2018-04-15 09:06:57 +0300639
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200640 let returnedBreadcrumb = [
641 {
svishnevea5e43c2018-04-15 09:06:57 +0300642 selectedKey: currentSoftwareProduct.vendorId,
643 menuItems: [
644 {
645 key: currentSoftwareProduct.vendorId,
646 displayText: currentSoftwareProduct.vendorName
647 }
648 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200649 },
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 {
svishnevea5e43c2018-04-15 09:06:57 +0300664 selectedKey: currentSoftwareProduct.id,
665 menuItems: [
666 {
667 key: currentSoftwareProduct.id,
668 displayText: currentSoftwareProduct.name
669 }
670 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200671 },
672 .../*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [
673 {
674 selectedKey:
675 screenToBreadcrumb[screen] ||
676 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
677 menuItems: [
678 {
679 key:
680 enums.BREADCRUMS
681 .SOFTWARE_PRODUCT_LANDING_PAGE,
682 displayText: i18n('Overview')
683 },
684 {
685 key:
686 enums.BREADCRUMS
687 .SOFTWARE_PRODUCT_DETAILS,
688 displayText: i18n('General')
689 },
690 {
691 key:
692 enums.BREADCRUMS
693 .SOFTWARE_PRODUCT_DEPLOYMENT,
694 displayText: i18n('Deployment Flavors')
695 },
696 {
697 key:
698 enums.BREADCRUMS
699 .SOFTWARE_PRODUCT_PROCESSES,
700 displayText: i18n('Process Details')
701 },
702 {
703 key:
704 enums.BREADCRUMS
705 .SOFTWARE_PRODUCT_NETWORKS,
706 displayText: i18n('Networks')
707 },
708 {
709 key:
710 enums.BREADCRUMS
Vodafone804ec682019-03-18 15:46:53 +0530711 .SOFTWARE_PRODUCT_VALIDATION,
712 displayText: i18n('Validation')
713 },
714 {
715 key:
716 enums.BREADCRUMS
717 .SOFTWARE_PRODUCT_VALIDATION_RESULTS,
718 displayText: i18n('Validation Results')
719 },
720 {
721 key:
722 enums.BREADCRUMS
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200723 .SOFTWARE_PRODUCT_DEPENDENCIES,
724 displayText: i18n('Components Dependencies')
725 },
726 {
727 key:
728 enums.BREADCRUMS
729 .SOFTWARE_PRODUCT_ATTACHMENTS,
730 displayText: i18n('Attachments')
731 },
732 {
733 key:
734 enums.BREADCRUMS
735 .SOFTWARE_PRODUCT_ACTIVITY_LOG,
736 displayText: i18n('Activity Log')
737 },
738 {
739 key:
740 enums.BREADCRUMS
741 .SOFTWARE_PRODUCT_COMPONENTS,
742 displayText: i18n('Components')
743 }
744 ].filter(item => {
745 switch (item.key) {
746 case enums.BREADCRUMS
747 .SOFTWARE_PRODUCT_ATTACHMENTS:
748 let isHeatData =
749 onboardingOrigin !==
750 onboardingOriginTypes.NONE ||
751 candidateOnboardingOrigin ===
752 onboardingOriginTypes.ZIP;
753 return isHeatData;
754 case enums.BREADCRUMS
755 .SOFTWARE_PRODUCT_COMPONENTS:
756 return componentsList.length > 0;
757 case enums.BREADCRUMS
758 .SOFTWARE_PRODUCT_DEPLOYMENT:
759 let isManualMode =
760 onboardingMethod ===
761 onboardingMethodTypes.MANUAL;
762 return isManualMode;
763 case enums.BREADCRUMS
764 .SOFTWARE_PRODUCT_DEPENDENCIES:
765 return componentsList.length > 1;
Vodafone804ec682019-03-18 15:46:53 +0530766 case enums.BREADCRUMS
767 .SOFTWARE_PRODUCT_VALIDATION:
768 case enums.BREADCRUMS
769 .SOFTWARE_PRODUCT_VALIDATION_RESULTS:
770 return !isValidationDisabled;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200771 default:
772 return true;
773 }
774 })
775 }
776 ]
777 ];
778 if (props.componentId) {
779 returnedBreadcrumb = [
780 ...returnedBreadcrumb,
781 {
782 selectedKey: props.componentId,
783 menuItems: componentsList.map(
784 ({ id, displayName }) => ({
785 key: id,
786 displayText: displayName
787 })
788 )
789 },
790 ...[
791 {
792 selectedKey:
793 componentScreenToBreadcrumb[screen],
794 menuItems: [
795 {
796 key:
797 enums.BREADCRUMS
798 .SOFTWARE_PRODUCT_COMPONENT_GENERAL,
799 displayText: i18n('General')
800 },
801 {
802 key:
803 enums.BREADCRUMS
804 .SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
805 displayText: i18n('Compute')
806 },
807 {
808 key:
809 enums.BREADCRUMS
810 .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
811 displayText: i18n(
812 'High Availability & Load Balancing'
813 )
814 },
815 {
816 key:
817 enums.BREADCRUMS
818 .SOFTWARE_PRODUCT_COMPONENT_NETWORK,
819 displayText: i18n('Networks')
820 },
821 {
822 key:
823 enums.BREADCRUMS
824 .SOFTWARE_PRODUCT_COMPONENT_STORAGE,
825 displayText: i18n('Storage')
826 },
827 {
828 key:
829 enums.BREADCRUMS
830 .SOFTWARE_PRODUCT_COMPONENT_IMAGES,
831 displayText: i18n('Images')
832 },
833 {
834 key:
835 enums.BREADCRUMS
836 .SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
837 displayText: i18n('Process Details')
838 },
839 {
840 key:
841 enums.BREADCRUMS
842 .SOFTWARE_PRODUCT_COMPONENT_MONITORING,
843 displayText: i18n('Monitoring')
844 }
845 ]
846 }
847 ]
848 ];
849 }
850 return returnedBreadcrumb;
851 }
852 }
Michael Landoefa037d2017-02-19 12:57:33 +0200853}