blob: 245dd2b55c6a02036fe418f64b53e7955b0853e4 [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';
Michael Landoefa037d2017-02-19 12:57:33 +020029
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';
Michael Landoefa037d2017-02-19 12:57:33 +020041import OnboardingActionHelper from './OnboardingActionHelper.js';
svishnev1eb66b72018-01-11 14:39:45 +020042import Onboarding from './Onboarding.js';
Michael Landoefa037d2017-02-19 12:57:33 +020043
44export default class OnboardingPunchOut {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020045 render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) {
46 if (!this.unsubscribeFromStore) {
47 this.unsubscribeFromStore = store.subscribe(() =>
48 this.handleStoreChange()
49 );
50 }
Michael Landoefa037d2017-02-19 12:57:33 +020051
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020052 if (!this.isConfigSet) {
53 Configuration.setCatalogApiRoot(apiRoot);
54 Configuration.setCatalogApiHeaders(apiHeaders);
55 this.isConfigSet = true;
56 }
Michael Landoefa037d2017-02-19 12:57:33 +020057
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020058 this.onEvent = (...args) => onEvent(...args);
59 this.handleData(data);
Michael Landoefa037d2017-02-19 12:57:33 +020060
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020061 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 Landoefa037d2017-02-19 12:57:33 +020087
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020088 unmount(element) {
89 ReactDOM.unmountComponentAtNode(element);
90 this.rendered = false;
91 this.unsubscribeFromStore();
92 this.unsubscribeFromStore = null;
93 }
Michael Landoefa037d2017-02-19 12:57:33 +020094
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020095 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 Landoefa037d2017-02-19 12:57:33 +0200121
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200122 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 );
talig8e9c0652017-12-20 14:30:43 +0200140
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200141 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 Landoefa037d2017-02-19 12:57:33 +0200167
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200168 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 ) {
235 softwareProduct = vspData;
236 //check current vsp fields to determine which file has uploaded
237 if (
238 vspData.onboardingOrigin ===
239 onboardingOriginTypes.ZIP ||
240 vspData.candidateOnboardingOrigin ===
241 onboardingOriginTypes.ZIP
242 ) {
243 softwareProductScreen =
244 enums.SCREEN
245 .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
246 } else if (
247 vspData.onboardingOrigin ===
248 onboardingOriginTypes.CSAR
249 ) {
250 softwareProductScreen =
251 enums.SCREEN
252 .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
253 }
254 }
AviZi280f8012017-06-09 02:39:56 +0300255
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200256 ScreensHelper.loadScreen(dispatch, {
257 screen: softwareProductScreen,
258 screenType: screenTypes.SOFTWARE_PRODUCT,
259 props: {
260 softwareProductId,
261 softwareProduct,
262 version,
263 usersList
264 }
265 });
266 } else if (
267 selectedKeys.length === 5 &&
268 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
269 selectedKeys[3] ===
270 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
271 ) {
272 let [
273 licenseModelId,
274 ,
275 softwareProductId,
276 ,
277 componentId
278 ] = selectedKeys;
279 let softwareProduct = softwareProductId
280 ? wholeSoftwareProductList.find(
281 ({ id }) => id === softwareProductId
282 )
283 : wholeSoftwareProductList.find(
284 ({ vendorId }) => vendorId === licenseModelId
285 );
286 if (!softwareProductId) {
287 softwareProductId = softwareProduct.id;
288 }
289 ScreensHelper.loadScreen(dispatch, {
290 screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS,
291 screenType: screenTypes.SOFTWARE_PRODUCT,
292 props: {
293 softwareProductId,
294 softwareProduct,
295 componentId,
296 version,
297 usersList
298 }
299 });
300 } else if (
301 selectedKeys.length === 6 &&
302 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
303 selectedKeys[3] ===
304 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
305 ) {
306 let [
307 licenseModelId,
308 ,
309 softwareProductId,
310 ,
311 componentId,
312 componentScreen
313 ] = selectedKeys;
314 let softwareProduct = softwareProductId
315 ? wholeSoftwareProductList.find(
316 ({ id }) => id === softwareProductId
317 )
318 : wholeSoftwareProductList.find(
319 ({ vendorId }) => vendorId === licenseModelId
320 );
321 if (!softwareProductId) {
322 softwareProductId = softwareProduct.id;
323 }
324 ScreensHelper.loadScreen(dispatch, {
325 screen: componentScreen,
326 screenType: screenTypes.SOFTWARE_PRODUCT,
327 props: {
328 softwareProductId,
329 softwareProduct,
330 componentId,
331 version,
332 usersList
333 }
334 });
335 } else {
336 console.error(
337 'Unknown breadcrumbs path: ',
338 selectedKeys
339 );
340 }
341 })
342 .catch(() => {
343 store.dispatch({
344 type: actionTypes.SET_CURRENT_SCREEN,
345 currentScreen: {
346 ...currentScreen,
347 forceBreadCrumbsUpdate: true
348 }
349 });
350 });
351 }
352 }
talig8e9c0652017-12-20 14:30:43 +0200353
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200354 handleStoreChange() {
355 let {
356 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200357 versionsPage: { versionsList: { itemType, itemId } },
358 softwareProduct: {
359 softwareProductEditor: {
360 data: currentSoftwareProduct = { onboardingMethod: '' }
361 },
362 softwareProductComponents: { componentsList }
363 },
svishnevea5e43c2018-04-15 09:06:57 +0300364 licenseModel: {
365 licenseModelEditor: { data: currentLicenseModel = {} }
366 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200367 } = store.getState();
svishnevea5e43c2018-04-15 09:06:57 +0300368
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200369 let breadcrumbsData = {
370 itemType,
371 itemId,
372 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200373 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300374 currentLicenseModel,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200375 componentsList
376 };
talig8e9c0652017-12-20 14:30:43 +0200377
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200378 if (
379 currentScreen.forceBreadCrumbsUpdate ||
380 !isEqual(breadcrumbsData, this.prevBreadcrumbsData) ||
381 this.breadcrumbsPrefixSelected
382 ) {
383 this.prevBreadcrumbsData = breadcrumbsData;
384 this.breadcrumbsPrefixSelected = false;
385 this.programmaticBreadcrumbsUpdate = true;
386 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
387 this.onEvent('breadcrumbsupdated', breadcrumbs);
388 store.dispatch({
389 type: actionTypes.SET_CURRENT_SCREEN,
390 currentScreen: {
391 ...currentScreen,
392 forceBreadCrumbsUpdate: false
393 }
394 });
395 }
396 }
talig8e9c0652017-12-20 14:30:43 +0200397
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200398 buildBreadcrumbs({
399 currentScreen: { screen, props },
400 itemType,
401 itemId,
402 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300403 currentLicenseModel,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200404 componentsList
405 }) {
406 let {
407 onboardingMethod,
408 onboardingOrigin,
409 candidateOnboardingOrigin
410 } = currentSoftwareProduct;
411 let screenToBreadcrumb;
412 switch (screen) {
413 case enums.SCREEN.ONBOARDING_CATALOG:
414 return [];
talig8e9c0652017-12-20 14:30:43 +0200415
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200416 case enums.SCREEN.VERSIONS_PAGE:
417 let firstMenuItems =
418 itemType === itemTypes.LICENSE_MODEL
419 ? [
420 {
421 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300422 menuItems: [
423 {
424 key: itemId,
425 displayText: props.itemName
426 }
427 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200428 }
429 ]
430 : [
431 {
432 selectedKey:
433 props.additionalProps.licenseModelId ||
434 currentSoftwareProduct.vendorId,
svishnevea5e43c2018-04-15 09:06:57 +0300435 menuItems: [
436 {
437 key: props.vendorId,
438 displayText: props.vendorName
439 }
440 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200441 },
442 {
443 selectedKey:
444 enums.BREADCRUMS.SOFTWARE_PRODUCT,
445 menuItems: [
446 {
447 key: enums.BREADCRUMS.LICENSE_MODEL,
448 displayText: i18n('License Model')
449 },
450 {
451 key:
452 enums.BREADCRUMS.SOFTWARE_PRODUCT,
453 displayText: i18n('Software Products')
454 }
455 ]
456 },
457 {
458 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300459 menuItems: [
460 {
461 key: itemId,
462 displayText: props.itemName
463 }
464 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200465 }
466 ];
467 return [
468 ...firstMenuItems,
469 {
470 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
471 menuItems: [
472 {
473 key: enums.BREADCRUMS.VERSIONS_PAGE,
474 displayText: i18n('Versions Page')
475 }
476 ]
477 }
478 ];
talig8e9c0652017-12-20 14:30:43 +0200479
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200480 case enums.SCREEN.LICENSE_AGREEMENTS:
481 case enums.SCREEN.FEATURE_GROUPS:
482 case enums.SCREEN.ENTITLEMENT_POOLS:
483 case enums.SCREEN.LICENSE_KEY_GROUPS:
484 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
485 case enums.SCREEN.ACTIVITY_LOG:
486 screenToBreadcrumb = {
487 [enums.SCREEN.LICENSE_AGREEMENTS]:
488 enums.BREADCRUMS.LICENSE_AGREEMENTS,
489 [enums.SCREEN.FEATURE_GROUPS]:
490 enums.BREADCRUMS.FEATURE_GROUPS,
491 [enums.SCREEN.ENTITLEMENT_POOLS]:
492 enums.BREADCRUMS.ENTITLEMENT_POOLS,
493 [enums.SCREEN.LICENSE_KEY_GROUPS]:
494 enums.BREADCRUMS.LICENSE_KEY_GROUPS,
495 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]:
496 enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
497 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
498 };
499 return [
500 {
svishnevea5e43c2018-04-15 09:06:57 +0300501 selectedKey: currentLicenseModel.id,
502 menuItems: [
503 {
504 key: currentLicenseModel.id,
505 displayText: currentLicenseModel.vendorName
506 }
507 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200508 },
509 {
510 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
511 menuItems: [
512 {
513 key: enums.BREADCRUMS.LICENSE_MODEL,
514 displayText: i18n('License Model')
svishnevea5e43c2018-04-15 09:06:57 +0300515 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200516 ]
517 },
518 {
519 selectedKey: screenToBreadcrumb[screen],
520 menuItems: [
521 {
522 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
523 displayText: i18n('Overview')
524 },
525 {
526 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
527 displayText: i18n('License Agreements')
528 },
529 {
530 key: enums.BREADCRUMS.FEATURE_GROUPS,
531 displayText: i18n('Feature Groups')
532 },
533 {
534 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
535 displayText: i18n('Entitlement Pools')
536 },
537 {
538 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
539 displayText: i18n('License Key Groups')
540 },
541 {
542 key: enums.BREADCRUMS.ACTIVITY_LOG,
543 displayText: i18n('Activity Log')
544 }
545 ]
546 }
547 ];
talig8e9c0652017-12-20 14:30:43 +0200548
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200549 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
550 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
551 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
552 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
553 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
554 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
555 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
556 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
557 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
Michael Landoefa037d2017-02-19 12:57:33 +0200558
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200559 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
560 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
561 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
562 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
563 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
564 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
565 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
566 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
567 screenToBreadcrumb = {
568 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]:
569 enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
570 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]:
571 enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
572 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]:
573 enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
574 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]:
575 enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
576 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]:
577 enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
578 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]:
579 enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
580 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]:
581 enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
582 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]:
583 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
584 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]:
585 enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
586 };
587 let componentScreenToBreadcrumb = {
588 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]:
589 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
590 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]:
591 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
592 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]:
593 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
594 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]:
595 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
596 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]:
597 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
598 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]:
599 enums.BREADCRUMS
600 .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
601 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]:
602 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
603 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]:
604 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
605 };
svishnevea5e43c2018-04-15 09:06:57 +0300606
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200607 let returnedBreadcrumb = [
608 {
svishnevea5e43c2018-04-15 09:06:57 +0300609 selectedKey: currentSoftwareProduct.vendorId,
610 menuItems: [
611 {
612 key: currentSoftwareProduct.vendorId,
613 displayText: currentSoftwareProduct.vendorName
614 }
615 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200616 },
617 {
618 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
619 menuItems: [
620 {
621 key: enums.BREADCRUMS.LICENSE_MODEL,
622 displayText: i18n('License Model')
623 },
624 {
625 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
626 displayText: i18n('Software Products')
627 }
628 ]
629 },
630 {
svishnevea5e43c2018-04-15 09:06:57 +0300631 selectedKey: currentSoftwareProduct.id,
632 menuItems: [
633 {
634 key: currentSoftwareProduct.id,
635 displayText: currentSoftwareProduct.name
636 }
637 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200638 },
639 .../*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [
640 {
641 selectedKey:
642 screenToBreadcrumb[screen] ||
643 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
644 menuItems: [
645 {
646 key:
647 enums.BREADCRUMS
648 .SOFTWARE_PRODUCT_LANDING_PAGE,
649 displayText: i18n('Overview')
650 },
651 {
652 key:
653 enums.BREADCRUMS
654 .SOFTWARE_PRODUCT_DETAILS,
655 displayText: i18n('General')
656 },
657 {
658 key:
659 enums.BREADCRUMS
660 .SOFTWARE_PRODUCT_DEPLOYMENT,
661 displayText: i18n('Deployment Flavors')
662 },
663 {
664 key:
665 enums.BREADCRUMS
666 .SOFTWARE_PRODUCT_PROCESSES,
667 displayText: i18n('Process Details')
668 },
669 {
670 key:
671 enums.BREADCRUMS
672 .SOFTWARE_PRODUCT_NETWORKS,
673 displayText: i18n('Networks')
674 },
675 {
676 key:
677 enums.BREADCRUMS
678 .SOFTWARE_PRODUCT_DEPENDENCIES,
679 displayText: i18n('Components Dependencies')
680 },
681 {
682 key:
683 enums.BREADCRUMS
684 .SOFTWARE_PRODUCT_ATTACHMENTS,
685 displayText: i18n('Attachments')
686 },
687 {
688 key:
689 enums.BREADCRUMS
690 .SOFTWARE_PRODUCT_ACTIVITY_LOG,
691 displayText: i18n('Activity Log')
692 },
693 {
694 key:
695 enums.BREADCRUMS
696 .SOFTWARE_PRODUCT_COMPONENTS,
697 displayText: i18n('Components')
698 }
699 ].filter(item => {
700 switch (item.key) {
701 case enums.BREADCRUMS
702 .SOFTWARE_PRODUCT_ATTACHMENTS:
703 let isHeatData =
704 onboardingOrigin !==
705 onboardingOriginTypes.NONE ||
706 candidateOnboardingOrigin ===
707 onboardingOriginTypes.ZIP;
708 return isHeatData;
709 case enums.BREADCRUMS
710 .SOFTWARE_PRODUCT_COMPONENTS:
711 return componentsList.length > 0;
712 case enums.BREADCRUMS
713 .SOFTWARE_PRODUCT_DEPLOYMENT:
714 let isManualMode =
715 onboardingMethod ===
716 onboardingMethodTypes.MANUAL;
717 return isManualMode;
718 case enums.BREADCRUMS
719 .SOFTWARE_PRODUCT_DEPENDENCIES:
720 return componentsList.length > 1;
721 default:
722 return true;
723 }
724 })
725 }
726 ]
727 ];
728 if (props.componentId) {
729 returnedBreadcrumb = [
730 ...returnedBreadcrumb,
731 {
732 selectedKey: props.componentId,
733 menuItems: componentsList.map(
734 ({ id, displayName }) => ({
735 key: id,
736 displayText: displayName
737 })
738 )
739 },
740 ...[
741 {
742 selectedKey:
743 componentScreenToBreadcrumb[screen],
744 menuItems: [
745 {
746 key:
747 enums.BREADCRUMS
748 .SOFTWARE_PRODUCT_COMPONENT_GENERAL,
749 displayText: i18n('General')
750 },
751 {
752 key:
753 enums.BREADCRUMS
754 .SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
755 displayText: i18n('Compute')
756 },
757 {
758 key:
759 enums.BREADCRUMS
760 .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
761 displayText: i18n(
762 'High Availability & Load Balancing'
763 )
764 },
765 {
766 key:
767 enums.BREADCRUMS
768 .SOFTWARE_PRODUCT_COMPONENT_NETWORK,
769 displayText: i18n('Networks')
770 },
771 {
772 key:
773 enums.BREADCRUMS
774 .SOFTWARE_PRODUCT_COMPONENT_STORAGE,
775 displayText: i18n('Storage')
776 },
777 {
778 key:
779 enums.BREADCRUMS
780 .SOFTWARE_PRODUCT_COMPONENT_IMAGES,
781 displayText: i18n('Images')
782 },
783 {
784 key:
785 enums.BREADCRUMS
786 .SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
787 displayText: i18n('Process Details')
788 },
789 {
790 key:
791 enums.BREADCRUMS
792 .SOFTWARE_PRODUCT_COMPONENT_MONITORING,
793 displayText: i18n('Monitoring')
794 }
795 ]
796 }
797 ]
798 ];
799 }
800 return returnedBreadcrumb;
801 }
802 }
Michael Landoefa037d2017-02-19 12:57:33 +0200803}