blob: fbb12022c11ea602c80dc173dc8fe799927e9ff5 [file] [log] [blame]
svishnev1eb66b72018-01-11 14:39:45 +02001/*
2 * Copyright © 2016-2017 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
19import {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
miriamed411d152018-01-02 15:35:55 +020024import lodashUnionBy from 'lodash/unionBy.js';
Michael Landoefa037d2017-02-19 12:57:33 +020025
26import i18n from 'nfvo-utils/i18n/i18n.js';
27import Application from 'sdc-app/Application.jsx';
28import store from 'sdc-app/AppStore.js';
29import Configuration from 'sdc-app/config/Configuration.js';
talig8e9c0652017-12-20 14:30:43 +020030import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020031
AviZi280f8012017-06-09 02:39:56 +030032
talig8e9c0652017-12-20 14:30:43 +020033import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030034
talig8e9c0652017-12-20 14:30:43 +020035import {itemTypes} from './versionsPage/VersionsPageConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020036
svishnev1eb66b72018-01-11 14:39:45 +020037import {AppContainer} from 'react-hot-loader';
AviZi280f8012017-06-09 02:39:56 +030038import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
39
talig8e9c0652017-12-20 14:30:43 +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 {
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) {
ilanap785dc1e2018-01-08 15:50:18 +020052 Configuration.setCatalogApiRoot(apiRoot);
53 Configuration.setCatalogApiHeaders(apiHeaders);
Michael Landoefa037d2017-02-19 12:57:33 +020054 this.isConfigSet = true;
55 }
56
57 this.onEvent = (...args) => onEvent(...args);
58 this.handleData(data);
59
60 if (!this.rendered) {
svishnev1eb66b72018-01-11 14:39:45 +020061 render(
62 <AppContainer>
63 <Application>
64 <Onboarding/>
65 </Application>
66 </AppContainer>,
Michael Landoefa037d2017-02-19 12:57:33 +020067 element
68 );
svishnev1eb66b72018-01-11 14:39:45 +020069 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 Landoefa037d2017-02-19 12:57:33 +020082 this.rendered = true;
svishnev1eb66b72018-01-11 14:39:45 +020083
Michael Landoefa037d2017-02-19 12:57:33 +020084 }
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);
miriamed411d152018-01-02 15:35:55 +020097 let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList,
98 softwareProduct: {softwareProductEditor: {data: vspData = {}},
talig8e9c0652017-12-20 14:30:43 +020099 softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState();
miriamed411d152018-01-02 15:35:55 +0200100 const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList];
101 const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList];
talig8e9c0652017-12-20 14:30:43 +0200102
103 let {props: {version, isReadOnlyMode}, screen} = currentScreen;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300104 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200105 if (this.programmaticBreadcrumbsUpdate) {
106 this.prevSelectedKeys = selectedKeys;
107 this.programmaticBreadcrumbsUpdate = false;
108 return;
109 }
Michael Landoefa037d2017-02-19 12:57:33 +0200110 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
111 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200112
AviZi280f8012017-06-09 02:39:56 +0300113 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
114 let preNavigate = Promise.resolve();
talig8e9c0652017-12-20 14:30:43 +0200115 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) {
AviZi280f8012017-06-09 02:39:56 +0300116 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300117 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300118 softwareProductId: prevVspId,
talig8e9c0652017-12-20 14:30:43 +0200119 version,
AviZi280f8012017-06-09 02:39:56 +0300120 vspComponentId: prevComponentId,
121 dataToSave
122 });
Michael Landoefa037d2017-02-19 12:57:33 +0200123 }
AviZi280f8012017-06-09 02:39:56 +0300124
125 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
126 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
talig8e9c0652017-12-20 14:30:43 +0200127 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
128 Promise.resolve();
AviZi280f8012017-06-09 02:39:56 +0300129 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
130 this.prevSelectedKeys = selectedKeys;
131 if (selectedKeys.length === 0) {
talig8e9c0652017-12-20 14:30:43 +0200132 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG});
133
AviZi280f8012017-06-09 02:39:56 +0300134 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
135 let [licenseModelId, , licenseModelScreen] = selectedKeys;
miriamed411d152018-01-02 15:35:55 +0200136 let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId);
talig8e9c0652017-12-20 14:30:43 +0200137 ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL,
138 props: {licenseModelId, version, licenseModel, usersList}});
139
AviZi280f8012017-06-09 02:39:56 +0300140 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
141 let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys;
142 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200143 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
144 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300145 if (!softwareProductId) {
146 softwareProductId = softwareProduct.id;
147 }
talig8e9c0652017-12-20 14:30:43 +0200148 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 }
AviZi280f8012017-06-09 02:39:56 +0300157 }
talig8e9c0652017-12-20 14:30:43 +0200158
159 ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
160 props: {softwareProductId, softwareProduct, version, usersList}});
161
AviZi280f8012017-06-09 02:39:56 +0300162 } 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 ?
miriamed411d152018-01-02 15:35:55 +0200165 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
166 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300167 if (!softwareProductId) {
168 softwareProductId = softwareProduct.id;
169 }
talig8e9c0652017-12-20 14:30:43 +0200170 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT,
171 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
172
AviZi280f8012017-06-09 02:39:56 +0300173 } 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 ?
miriamed411d152018-01-02 15:35:55 +0200176 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
177 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300178 if (!softwareProductId) {
179 softwareProductId = softwareProduct.id;
180 }
talig8e9c0652017-12-20 14:30:43 +0200181 ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
182 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
183
AviZi280f8012017-06-09 02:39:56 +0300184 } 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 Landoefa037d2017-02-19 12:57:33 +0200196 }
197 }
198
199 handleStoreChange() {
talig8e9c0652017-12-20 14:30:43 +0200200 let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage:
201 {versionsList: {itemType, itemId}},
202 softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}},
shrek2000c8a540b2017-09-11 15:45:37 +0300203 softwareProductComponents: {componentsList}}} = store.getState();
miriamed411d152018-01-02 15:35:55 +0200204 const wholeSoftwareProductList = lodashUnionBy(softwareProductList, finalizedSoftwareProductList, 'id');
205 const wholeLicenseModelList = lodashUnionBy(licenseModelList, finalizedLicenseModelList, 'id');
talig8e9c0652017-12-20 14:30:43 +0200206 let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList};
207
AviZi280f8012017-06-09 02:39:56 +0300208 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200209 this.prevBreadcrumbsData = breadcrumbsData;
210 this.breadcrumbsPrefixSelected = false;
211 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200212 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
213 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300214 store.dispatch({
215 type: actionTypes.SET_CURRENT_SCREEN,
216 currentScreen: {
217 ...currentScreen,
218 forceBreadCrumbsUpdate: false
219 }
220 });
Michael Landoefa037d2017-02-19 12:57:33 +0200221 }
222 }
223
talig8e9c0652017-12-20 14:30:43 +0200224 buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct,
225 wholeLicenseModelList, wholeSoftwareProductList, componentsList}) {
226 let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct;
Michael Landoefa037d2017-02-19 12:57:33 +0200227 let screenToBreadcrumb;
228 switch (screen) {
229 case enums.SCREEN.ONBOARDING_CATALOG:
230 return [];
231
talig8e9c0652017-12-20 14:30:43 +0200232 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 Landoefa037d2017-02-19 12:57:33 +0200276 case enums.SCREEN.LICENSE_AGREEMENTS:
277 case enums.SCREEN.FEATURE_GROUPS:
278 case enums.SCREEN.ENTITLEMENT_POOLS:
279 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300280 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
281 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200282 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,
AviZi280f8012017-06-09 02:39:56 +0300286 [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 Landoefa037d2017-02-19 12:57:33 +0200289 };
290 return [
291 {
292 selectedKey: props.licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200293 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200294 key: id,
talig8e9c0652017-12-20 14:30:43 +0200295 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200296 }))
297 },
298 {
299 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
300 menuItems: [{
301 key: enums.BREADCRUMS.LICENSE_MODEL,
302 displayText: i18n('License Model')
303 },
talig8e9c0652017-12-20 14:30:43 +0200304 ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
305 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
306 displayText: i18n('Software Products')
307 }])]
Michael Landoefa037d2017-02-19 12:57:33 +0200308 }, {
309 selectedKey: screenToBreadcrumb[screen],
310 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300311 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
312 displayText: i18n('Overview')
313 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200314 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')
AviZi280f8012017-06-09 02:39:56 +0300325 }, {
326 key: enums.BREADCRUMS.ACTIVITY_LOG,
327 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200328 }]
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 Zivb8e2faf2017-07-18 19:45:38 +0300336 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200337 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300338 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
339 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200340 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 Zivb8e2faf2017-07-18 19:45:38 +0300348 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200349 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
350 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300351 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200352 [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 Zivb8e2faf2017-07-18 19:45:38 +0300355 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200356 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300357 [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 Landoefa037d2017-02-19 12:57:33 +0200360 };
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 Zivb8e2faf2017-07-18 19:45:38 +0300368 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200369 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
370 };
talig8e9c0652017-12-20 14:30:43 +0200371 let licenseModelId = currentSoftwareProduct.vendorId;
Michael Landoefa037d2017-02-19 12:57:33 +0200372 let returnedBreadcrumb = [
373 {
374 selectedKey: licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200375 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200376 key: id,
talig8e9c0652017-12-20 14:30:43 +0200377 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200378 }))
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,
talig8e9c0652017-12-20 14:30:43 +0200392 menuItems: wholeSoftwareProductList
393 .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId)
Michael Landoefa037d2017-02-19 12:57:33 +0200394 .map(({id, name}) => ({
395 key: id,
396 displayText: name
397 }))
398 },
AviZi280f8012017-06-09 02:39:56 +0300399 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200400 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
401 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300402 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
403 displayText: i18n('Overview')
404 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200405 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
406 displayText: i18n('General')
407 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300408 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
409 displayText: i18n('Deployment Flavors')
410 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200411 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
412 displayText: i18n('Process Details')
413 }, {
414 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
415 displayText: i18n('Networks')
416 }, {
AviZi280f8012017-06-09 02:39:56 +0300417 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 Landoefa037d2017-02-19 12:57:33 +0200426 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
427 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300428 }].filter(item => {
AviZi280f8012017-06-09 02:39:56 +0300429 switch (item.key) {
430 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
talig8e9c0652017-12-20 14:30:43 +0200431 let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP;
AviZi280f8012017-06-09 02:39:56 +0300432 return isHeatData;
433 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300434 return (componentsList.length > 0);
435 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
talig8e9c0652017-12-20 14:30:43 +0200436 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300437 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300438 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300439 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300440 default:
441 return true;
442 }
443 })
Michael Landoefa037d2017-02-19 12:57:33 +0200444 }])
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 Zivb8e2faf2017-07-18 19:45:38 +0300474 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
475 displayText: i18n('Images')
476 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200477 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 Ziv61070c92017-07-26 17:37:57 +0300482 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200483 }]
484 ];
485 }
486 return returnedBreadcrumb;
487 }
488 }
489}