blob: a73501468c4a40ff625f185669924e1cc44063c7 [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 ) {
svishnev57c5c4a2018-04-22 14:14:31 +0300235 softwareProduct = { ...vspData };
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200236 //check current vsp fields to determine which file has uploaded
svishnev57c5c4a2018-04-22 14:14:31 +0300237
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200238 if (
svishnev57c5c4a2018-04-22 14:14:31 +0300239 vspData.onboardingOrigin.toLowerCase() ===
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200240 onboardingOriginTypes.ZIP ||
svishnev57c5c4a2018-04-22 14:14:31 +0300241 vspData.candidateOnboardingOrigin.toLowerCase() ===
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200242 onboardingOriginTypes.ZIP
243 ) {
244 softwareProductScreen =
245 enums.SCREEN
246 .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
247 } else if (
248 vspData.onboardingOrigin ===
249 onboardingOriginTypes.CSAR
250 ) {
251 softwareProductScreen =
252 enums.SCREEN
253 .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
254 }
255 }
AviZi280f8012017-06-09 02:39:56 +0300256
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200257 ScreensHelper.loadScreen(dispatch, {
258 screen: softwareProductScreen,
259 screenType: screenTypes.SOFTWARE_PRODUCT,
260 props: {
261 softwareProductId,
262 softwareProduct,
263 version,
264 usersList
265 }
266 });
267 } else if (
268 selectedKeys.length === 5 &&
269 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
270 selectedKeys[3] ===
271 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
272 ) {
273 let [
274 licenseModelId,
275 ,
276 softwareProductId,
277 ,
278 componentId
279 ] = selectedKeys;
280 let softwareProduct = softwareProductId
281 ? wholeSoftwareProductList.find(
282 ({ id }) => id === softwareProductId
283 )
284 : wholeSoftwareProductList.find(
285 ({ vendorId }) => vendorId === licenseModelId
286 );
287 if (!softwareProductId) {
288 softwareProductId = softwareProduct.id;
289 }
290 ScreensHelper.loadScreen(dispatch, {
291 screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS,
292 screenType: screenTypes.SOFTWARE_PRODUCT,
293 props: {
294 softwareProductId,
295 softwareProduct,
296 componentId,
297 version,
298 usersList
299 }
300 });
301 } else if (
302 selectedKeys.length === 6 &&
303 selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT &&
304 selectedKeys[3] ===
305 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS
306 ) {
307 let [
308 licenseModelId,
309 ,
310 softwareProductId,
311 ,
312 componentId,
313 componentScreen
314 ] = selectedKeys;
315 let softwareProduct = softwareProductId
316 ? wholeSoftwareProductList.find(
317 ({ id }) => id === softwareProductId
318 )
319 : wholeSoftwareProductList.find(
320 ({ vendorId }) => vendorId === licenseModelId
321 );
322 if (!softwareProductId) {
323 softwareProductId = softwareProduct.id;
324 }
325 ScreensHelper.loadScreen(dispatch, {
326 screen: componentScreen,
327 screenType: screenTypes.SOFTWARE_PRODUCT,
328 props: {
329 softwareProductId,
330 softwareProduct,
331 componentId,
332 version,
333 usersList
334 }
335 });
336 } else {
337 console.error(
338 'Unknown breadcrumbs path: ',
339 selectedKeys
340 );
341 }
342 })
343 .catch(() => {
344 store.dispatch({
345 type: actionTypes.SET_CURRENT_SCREEN,
346 currentScreen: {
347 ...currentScreen,
348 forceBreadCrumbsUpdate: true
349 }
350 });
351 });
352 }
353 }
talig8e9c0652017-12-20 14:30:43 +0200354
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200355 handleStoreChange() {
356 let {
357 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200358 versionsPage: { versionsList: { itemType, itemId } },
359 softwareProduct: {
360 softwareProductEditor: {
361 data: currentSoftwareProduct = { onboardingMethod: '' }
362 },
363 softwareProductComponents: { componentsList }
364 },
svishnevea5e43c2018-04-15 09:06:57 +0300365 licenseModel: {
366 licenseModelEditor: { data: currentLicenseModel = {} }
367 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200368 } = store.getState();
svishnevea5e43c2018-04-15 09:06:57 +0300369
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200370 let breadcrumbsData = {
371 itemType,
372 itemId,
373 currentScreen,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200374 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300375 currentLicenseModel,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200376 componentsList
377 };
talig8e9c0652017-12-20 14:30:43 +0200378
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200379 if (
380 currentScreen.forceBreadCrumbsUpdate ||
381 !isEqual(breadcrumbsData, this.prevBreadcrumbsData) ||
382 this.breadcrumbsPrefixSelected
383 ) {
384 this.prevBreadcrumbsData = breadcrumbsData;
385 this.breadcrumbsPrefixSelected = false;
386 this.programmaticBreadcrumbsUpdate = true;
387 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
388 this.onEvent('breadcrumbsupdated', breadcrumbs);
389 store.dispatch({
390 type: actionTypes.SET_CURRENT_SCREEN,
391 currentScreen: {
392 ...currentScreen,
393 forceBreadCrumbsUpdate: false
394 }
395 });
396 }
397 }
talig8e9c0652017-12-20 14:30:43 +0200398
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200399 buildBreadcrumbs({
400 currentScreen: { screen, props },
401 itemType,
402 itemId,
403 currentSoftwareProduct,
svishnevea5e43c2018-04-15 09:06:57 +0300404 currentLicenseModel,
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200405 componentsList
406 }) {
407 let {
408 onboardingMethod,
409 onboardingOrigin,
410 candidateOnboardingOrigin
411 } = currentSoftwareProduct;
412 let screenToBreadcrumb;
413 switch (screen) {
414 case enums.SCREEN.ONBOARDING_CATALOG:
415 return [];
talig8e9c0652017-12-20 14:30:43 +0200416
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200417 case enums.SCREEN.VERSIONS_PAGE:
418 let firstMenuItems =
419 itemType === itemTypes.LICENSE_MODEL
420 ? [
421 {
422 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300423 menuItems: [
424 {
425 key: itemId,
426 displayText: props.itemName
427 }
428 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200429 }
430 ]
431 : [
432 {
433 selectedKey:
434 props.additionalProps.licenseModelId ||
435 currentSoftwareProduct.vendorId,
svishnevea5e43c2018-04-15 09:06:57 +0300436 menuItems: [
437 {
438 key: props.vendorId,
439 displayText: props.vendorName
440 }
441 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200442 },
443 {
444 selectedKey:
445 enums.BREADCRUMS.SOFTWARE_PRODUCT,
446 menuItems: [
447 {
448 key: enums.BREADCRUMS.LICENSE_MODEL,
449 displayText: i18n('License Model')
450 },
451 {
452 key:
453 enums.BREADCRUMS.SOFTWARE_PRODUCT,
454 displayText: i18n('Software Products')
455 }
456 ]
457 },
458 {
459 selectedKey: itemId,
svishnevea5e43c2018-04-15 09:06:57 +0300460 menuItems: [
461 {
462 key: itemId,
463 displayText: props.itemName
464 }
465 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200466 }
467 ];
468 return [
469 ...firstMenuItems,
470 {
471 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
472 menuItems: [
473 {
474 key: enums.BREADCRUMS.VERSIONS_PAGE,
475 displayText: i18n('Versions Page')
476 }
477 ]
478 }
479 ];
talig8e9c0652017-12-20 14:30:43 +0200480
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200481 case enums.SCREEN.LICENSE_AGREEMENTS:
482 case enums.SCREEN.FEATURE_GROUPS:
483 case enums.SCREEN.ENTITLEMENT_POOLS:
484 case enums.SCREEN.LICENSE_KEY_GROUPS:
485 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
486 case enums.SCREEN.ACTIVITY_LOG:
487 screenToBreadcrumb = {
488 [enums.SCREEN.LICENSE_AGREEMENTS]:
489 enums.BREADCRUMS.LICENSE_AGREEMENTS,
490 [enums.SCREEN.FEATURE_GROUPS]:
491 enums.BREADCRUMS.FEATURE_GROUPS,
492 [enums.SCREEN.ENTITLEMENT_POOLS]:
493 enums.BREADCRUMS.ENTITLEMENT_POOLS,
494 [enums.SCREEN.LICENSE_KEY_GROUPS]:
495 enums.BREADCRUMS.LICENSE_KEY_GROUPS,
496 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]:
497 enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
498 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
499 };
500 return [
501 {
svishnevea5e43c2018-04-15 09:06:57 +0300502 selectedKey: currentLicenseModel.id,
503 menuItems: [
504 {
505 key: currentLicenseModel.id,
506 displayText: currentLicenseModel.vendorName
507 }
508 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200509 },
510 {
511 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
512 menuItems: [
513 {
514 key: enums.BREADCRUMS.LICENSE_MODEL,
515 displayText: i18n('License Model')
svishnevea5e43c2018-04-15 09:06:57 +0300516 }
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200517 ]
518 },
519 {
520 selectedKey: screenToBreadcrumb[screen],
521 menuItems: [
522 {
523 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
524 displayText: i18n('Overview')
525 },
526 {
527 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
528 displayText: i18n('License Agreements')
529 },
530 {
531 key: enums.BREADCRUMS.FEATURE_GROUPS,
532 displayText: i18n('Feature Groups')
533 },
534 {
535 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
536 displayText: i18n('Entitlement Pools')
537 },
538 {
539 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
540 displayText: i18n('License Key Groups')
541 },
542 {
543 key: enums.BREADCRUMS.ACTIVITY_LOG,
544 displayText: i18n('Activity Log')
545 }
546 ]
547 }
548 ];
talig8e9c0652017-12-20 14:30:43 +0200549
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200550 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
551 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
552 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
553 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
554 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
555 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
556 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
557 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
558 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
Michael Landoefa037d2017-02-19 12:57:33 +0200559
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200560 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
561 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
562 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
563 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
564 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
565 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
566 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
567 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
568 screenToBreadcrumb = {
569 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]:
570 enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
571 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]:
572 enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
573 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]:
574 enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
575 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]:
576 enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
577 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]:
578 enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
579 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]:
580 enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
581 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]:
582 enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
583 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]:
584 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
585 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]:
586 enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
587 };
588 let componentScreenToBreadcrumb = {
589 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]:
590 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
591 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]:
592 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
593 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]:
594 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
595 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]:
596 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
597 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]:
598 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
599 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]:
600 enums.BREADCRUMS
601 .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
602 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]:
603 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
604 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]:
605 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
606 };
svishnevea5e43c2018-04-15 09:06:57 +0300607
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200608 let returnedBreadcrumb = [
609 {
svishnevea5e43c2018-04-15 09:06:57 +0300610 selectedKey: currentSoftwareProduct.vendorId,
611 menuItems: [
612 {
613 key: currentSoftwareProduct.vendorId,
614 displayText: currentSoftwareProduct.vendorName
615 }
616 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200617 },
618 {
619 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
620 menuItems: [
621 {
622 key: enums.BREADCRUMS.LICENSE_MODEL,
623 displayText: i18n('License Model')
624 },
625 {
626 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
627 displayText: i18n('Software Products')
628 }
629 ]
630 },
631 {
svishnevea5e43c2018-04-15 09:06:57 +0300632 selectedKey: currentSoftwareProduct.id,
633 menuItems: [
634 {
635 key: currentSoftwareProduct.id,
636 displayText: currentSoftwareProduct.name
637 }
638 ]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200639 },
640 .../*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [
641 {
642 selectedKey:
643 screenToBreadcrumb[screen] ||
644 enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
645 menuItems: [
646 {
647 key:
648 enums.BREADCRUMS
649 .SOFTWARE_PRODUCT_LANDING_PAGE,
650 displayText: i18n('Overview')
651 },
652 {
653 key:
654 enums.BREADCRUMS
655 .SOFTWARE_PRODUCT_DETAILS,
656 displayText: i18n('General')
657 },
658 {
659 key:
660 enums.BREADCRUMS
661 .SOFTWARE_PRODUCT_DEPLOYMENT,
662 displayText: i18n('Deployment Flavors')
663 },
664 {
665 key:
666 enums.BREADCRUMS
667 .SOFTWARE_PRODUCT_PROCESSES,
668 displayText: i18n('Process Details')
669 },
670 {
671 key:
672 enums.BREADCRUMS
673 .SOFTWARE_PRODUCT_NETWORKS,
674 displayText: i18n('Networks')
675 },
676 {
677 key:
678 enums.BREADCRUMS
679 .SOFTWARE_PRODUCT_DEPENDENCIES,
680 displayText: i18n('Components Dependencies')
681 },
682 {
683 key:
684 enums.BREADCRUMS
685 .SOFTWARE_PRODUCT_ATTACHMENTS,
686 displayText: i18n('Attachments')
687 },
688 {
689 key:
690 enums.BREADCRUMS
691 .SOFTWARE_PRODUCT_ACTIVITY_LOG,
692 displayText: i18n('Activity Log')
693 },
694 {
695 key:
696 enums.BREADCRUMS
697 .SOFTWARE_PRODUCT_COMPONENTS,
698 displayText: i18n('Components')
699 }
700 ].filter(item => {
701 switch (item.key) {
702 case enums.BREADCRUMS
703 .SOFTWARE_PRODUCT_ATTACHMENTS:
704 let isHeatData =
705 onboardingOrigin !==
706 onboardingOriginTypes.NONE ||
707 candidateOnboardingOrigin ===
708 onboardingOriginTypes.ZIP;
709 return isHeatData;
710 case enums.BREADCRUMS
711 .SOFTWARE_PRODUCT_COMPONENTS:
712 return componentsList.length > 0;
713 case enums.BREADCRUMS
714 .SOFTWARE_PRODUCT_DEPLOYMENT:
715 let isManualMode =
716 onboardingMethod ===
717 onboardingMethodTypes.MANUAL;
718 return isManualMode;
719 case enums.BREADCRUMS
720 .SOFTWARE_PRODUCT_DEPENDENCIES:
721 return componentsList.length > 1;
722 default:
723 return true;
724 }
725 })
726 }
727 ]
728 ];
729 if (props.componentId) {
730 returnedBreadcrumb = [
731 ...returnedBreadcrumb,
732 {
733 selectedKey: props.componentId,
734 menuItems: componentsList.map(
735 ({ id, displayName }) => ({
736 key: id,
737 displayText: displayName
738 })
739 )
740 },
741 ...[
742 {
743 selectedKey:
744 componentScreenToBreadcrumb[screen],
745 menuItems: [
746 {
747 key:
748 enums.BREADCRUMS
749 .SOFTWARE_PRODUCT_COMPONENT_GENERAL,
750 displayText: i18n('General')
751 },
752 {
753 key:
754 enums.BREADCRUMS
755 .SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
756 displayText: i18n('Compute')
757 },
758 {
759 key:
760 enums.BREADCRUMS
761 .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
762 displayText: i18n(
763 'High Availability & Load Balancing'
764 )
765 },
766 {
767 key:
768 enums.BREADCRUMS
769 .SOFTWARE_PRODUCT_COMPONENT_NETWORK,
770 displayText: i18n('Networks')
771 },
772 {
773 key:
774 enums.BREADCRUMS
775 .SOFTWARE_PRODUCT_COMPONENT_STORAGE,
776 displayText: i18n('Storage')
777 },
778 {
779 key:
780 enums.BREADCRUMS
781 .SOFTWARE_PRODUCT_COMPONENT_IMAGES,
782 displayText: i18n('Images')
783 },
784 {
785 key:
786 enums.BREADCRUMS
787 .SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
788 displayText: i18n('Process Details')
789 },
790 {
791 key:
792 enums.BREADCRUMS
793 .SOFTWARE_PRODUCT_COMPONENT_MONITORING,
794 displayText: i18n('Monitoring')
795 }
796 ]
797 }
798 ]
799 ];
800 }
801 return returnedBreadcrumb;
802 }
803 }
Michael Landoefa037d2017-02-19 12:57:33 +0200804}