blob: e04f9b7309bc7f11105793c4d8ef80a57da08b5f [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
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;
83 }
84 }
85
86 unmount(element) {
87 ReactDOM.unmountComponentAtNode(element);
88 this.rendered = false;
89 this.unsubscribeFromStore();
90 this.unsubscribeFromStore = null;
91 }
92
93 handleData(data) {
94 let {breadcrumbs: {selectedKeys = []} = {}} = data;
95 let dispatch = action => store.dispatch(action);
miriamed411d152018-01-02 15:35:55 +020096 let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList,
97 softwareProduct: {softwareProductEditor: {data: vspData = {}},
svishnev091edfd2018-03-19 12:15:19 +020098 softwareProductComponents = {}, softwareProductQuestionnaire = {}}, archivedLicenseModelList} = store.getState();
miriamed411d152018-01-02 15:35:55 +020099 const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList];
svishnev091edfd2018-03-19 12:15:19 +0200100 const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList, ...archivedLicenseModelList];
talig8e9c0652017-12-20 14:30:43 +0200101
102 let {props: {version, isReadOnlyMode}, screen} = currentScreen;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300103 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200104 if (this.programmaticBreadcrumbsUpdate) {
105 this.prevSelectedKeys = selectedKeys;
106 this.programmaticBreadcrumbsUpdate = false;
107 return;
108 }
Michael Landoefa037d2017-02-19 12:57:33 +0200109 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
110 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200111
AviZi280f8012017-06-09 02:39:56 +0300112 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
113 let preNavigate = Promise.resolve();
talig8e9c0652017-12-20 14:30:43 +0200114 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) {
AviZi280f8012017-06-09 02:39:56 +0300115 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300116 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300117 softwareProductId: prevVspId,
talig8e9c0652017-12-20 14:30:43 +0200118 version,
AviZi280f8012017-06-09 02:39:56 +0300119 vspComponentId: prevComponentId,
120 dataToSave
121 });
Michael Landoefa037d2017-02-19 12:57:33 +0200122 }
AviZi280f8012017-06-09 02:39:56 +0300123
124 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
125 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
talig8e9c0652017-12-20 14:30:43 +0200126 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
127 Promise.resolve();
AviZi280f8012017-06-09 02:39:56 +0300128 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
129 this.prevSelectedKeys = selectedKeys;
130 if (selectedKeys.length === 0) {
talig8e9c0652017-12-20 14:30:43 +0200131 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG});
132
AviZi280f8012017-06-09 02:39:56 +0300133 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
134 let [licenseModelId, , licenseModelScreen] = selectedKeys;
miriamed411d152018-01-02 15:35:55 +0200135 let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId);
talig8e9c0652017-12-20 14:30:43 +0200136 ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL,
137 props: {licenseModelId, version, licenseModel, usersList}});
138
AviZi280f8012017-06-09 02:39:56 +0300139 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
140 let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys;
141 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200142 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
143 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300144 if (!softwareProductId) {
145 softwareProductId = softwareProduct.id;
146 }
talig8e9c0652017-12-20 14:30:43 +0200147 if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) {
148 softwareProduct = vspData;
149 //check current vsp fields to determine which file has uploaded
150 if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) {
151 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
152 }
153 else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) {
154 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
155 }
AviZi280f8012017-06-09 02:39:56 +0300156 }
talig8e9c0652017-12-20 14:30:43 +0200157
158 ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
159 props: {softwareProductId, softwareProduct, version, usersList}});
160
AviZi280f8012017-06-09 02:39:56 +0300161 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
162 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
163 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200164 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
165 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300166 if (!softwareProductId) {
167 softwareProductId = softwareProduct.id;
168 }
talig8e9c0652017-12-20 14:30:43 +0200169 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT,
170 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
171
AviZi280f8012017-06-09 02:39:56 +0300172 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
173 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
174 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200175 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
176 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300177 if (!softwareProductId) {
178 softwareProductId = softwareProduct.id;
179 }
talig8e9c0652017-12-20 14:30:43 +0200180 ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
181 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
182
AviZi280f8012017-06-09 02:39:56 +0300183 } else {
184 console.error('Unknown breadcrumbs path: ', selectedKeys);
185 }
186 }).catch(() => {
187 store.dispatch({
188 type: actionTypes.SET_CURRENT_SCREEN,
189 currentScreen: {
190 ...currentScreen,
191 forceBreadCrumbsUpdate: true
192 }
193 });
194 });
Michael Landoefa037d2017-02-19 12:57:33 +0200195 }
196 }
197
198 handleStoreChange() {
talig8e9c0652017-12-20 14:30:43 +0200199 let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage:
200 {versionsList: {itemType, itemId}},
201 softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}},
svishnev091edfd2018-03-19 12:15:19 +0200202 softwareProductComponents: {componentsList}}, archivedLicenseModelList, archivedSoftwareProductList} = store.getState();
203 const wholeSoftwareProductList = lodashUnionBy(softwareProductList, [...finalizedSoftwareProductList, ...archivedSoftwareProductList], 'id');
204 const wholeLicenseModelList = lodashUnionBy(licenseModelList, [...finalizedLicenseModelList, ...archivedLicenseModelList], 'id');
talig8e9c0652017-12-20 14:30:43 +0200205 let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList};
206
AviZi280f8012017-06-09 02:39:56 +0300207 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200208 this.prevBreadcrumbsData = breadcrumbsData;
209 this.breadcrumbsPrefixSelected = false;
210 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200211 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
212 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300213 store.dispatch({
214 type: actionTypes.SET_CURRENT_SCREEN,
215 currentScreen: {
216 ...currentScreen,
217 forceBreadCrumbsUpdate: false
218 }
219 });
Michael Landoefa037d2017-02-19 12:57:33 +0200220 }
221 }
222
talig8e9c0652017-12-20 14:30:43 +0200223 buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct,
224 wholeLicenseModelList, wholeSoftwareProductList, componentsList}) {
225 let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct;
Michael Landoefa037d2017-02-19 12:57:33 +0200226 let screenToBreadcrumb;
227 switch (screen) {
228 case enums.SCREEN.ONBOARDING_CATALOG:
229 return [];
230
talig8e9c0652017-12-20 14:30:43 +0200231 case enums.SCREEN.VERSIONS_PAGE:
232 let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [
233 {
234 selectedKey: itemId,
235 menuItems: wholeLicenseModelList.map(({id, name}) => ({
236 key: id,
237 displayText: name
238 }))
239 }] : [
240 {
241 selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId,
242 menuItems: wholeLicenseModelList.map(({id, name}) => ({
243 key: id,
244 displayText: name
245 }))
246 },
247 {
248 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
249 menuItems: [{
250 key: enums.BREADCRUMS.LICENSE_MODEL,
251 displayText: i18n('License Model')
252 }, {
253 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
254 displayText: i18n('Software Products')
255 }]
256 },
257 {
258 selectedKey: itemId,
259 menuItems: wholeSoftwareProductList
260 .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId)
261 .map(({id, name}) => ({
262 key: id,
263 displayText: name
264 }))
265 },
266 ];
267 return [
268 ...firstMenuItems,
269 {
270 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
271 menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}]
272 }
273 ];
274
Michael Landoefa037d2017-02-19 12:57:33 +0200275 case enums.SCREEN.LICENSE_AGREEMENTS:
276 case enums.SCREEN.FEATURE_GROUPS:
277 case enums.SCREEN.ENTITLEMENT_POOLS:
278 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300279 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
280 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200281 screenToBreadcrumb = {
282 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
283 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
284 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300285 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
286 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
287 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200288 };
289 return [
290 {
291 selectedKey: props.licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200292 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200293 key: id,
talig8e9c0652017-12-20 14:30:43 +0200294 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200295 }))
296 },
297 {
298 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
299 menuItems: [{
300 key: enums.BREADCRUMS.LICENSE_MODEL,
301 displayText: i18n('License Model')
302 },
talig8e9c0652017-12-20 14:30:43 +0200303 ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
304 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
305 displayText: i18n('Software Products')
306 }])]
Michael Landoefa037d2017-02-19 12:57:33 +0200307 }, {
308 selectedKey: screenToBreadcrumb[screen],
309 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300310 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
311 displayText: i18n('Overview')
312 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200313 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
314 displayText: i18n('License Agreements')
315 }, {
316 key: enums.BREADCRUMS.FEATURE_GROUPS,
317 displayText: i18n('Feature Groups')
318 }, {
319 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
320 displayText: i18n('Entitlement Pools')
321 }, {
322 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
323 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300324 }, {
325 key: enums.BREADCRUMS.ACTIVITY_LOG,
326 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200327 }]
328 }
329 ];
330
331 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
332 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
333 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
334 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300335 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200336 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300337 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
338 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200339 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
340
341 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
342 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
343 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
344 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
345 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
346 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300347 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200348 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
349 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300350 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200351 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
352 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
353 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300354 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200355 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300356 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
357 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
358 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200359 };
360 let componentScreenToBreadcrumb = {
361 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
362 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
363 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
364 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
365 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
366 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300367 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200368 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
369 };
talig8e9c0652017-12-20 14:30:43 +0200370 let licenseModelId = currentSoftwareProduct.vendorId;
Michael Landoefa037d2017-02-19 12:57:33 +0200371 let returnedBreadcrumb = [
372 {
373 selectedKey: licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200374 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200375 key: id,
talig8e9c0652017-12-20 14:30:43 +0200376 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200377 }))
378 },
379 {
380 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
381 menuItems: [{
382 key: enums.BREADCRUMS.LICENSE_MODEL,
383 displayText: i18n('License Model')
384 }, {
385 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
386 displayText: i18n('Software Products')
387 }]
388 },
389 {
390 selectedKey: props.softwareProductId,
talig8e9c0652017-12-20 14:30:43 +0200391 menuItems: wholeSoftwareProductList
392 .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId)
Michael Landoefa037d2017-02-19 12:57:33 +0200393 .map(({id, name}) => ({
394 key: id,
395 displayText: name
396 }))
397 },
AviZi280f8012017-06-09 02:39:56 +0300398 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200399 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
400 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300401 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
402 displayText: i18n('Overview')
403 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200404 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
405 displayText: i18n('General')
406 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300407 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
408 displayText: i18n('Deployment Flavors')
409 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200410 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
411 displayText: i18n('Process Details')
412 }, {
413 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
414 displayText: i18n('Networks')
415 }, {
AviZi280f8012017-06-09 02:39:56 +0300416 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
417 displayText: i18n('Components Dependencies')
418 }, {
419 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
420 displayText: i18n('Attachments')
421 }, {
422 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
423 displayText: i18n('Activity Log')
424 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200425 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
426 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300427 }].filter(item => {
AviZi280f8012017-06-09 02:39:56 +0300428 switch (item.key) {
429 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
talig8e9c0652017-12-20 14:30:43 +0200430 let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP;
AviZi280f8012017-06-09 02:39:56 +0300431 return isHeatData;
432 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300433 return (componentsList.length > 0);
434 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
talig8e9c0652017-12-20 14:30:43 +0200435 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300436 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300437 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300438 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300439 default:
440 return true;
441 }
442 })
Michael Landoefa037d2017-02-19 12:57:33 +0200443 }])
444 ];
445 if(props.componentId) {
446 returnedBreadcrumb = [
447 ...returnedBreadcrumb, {
448 selectedKey: props.componentId,
449 menuItems: componentsList
450 .map(({id, displayName}) => ({
451 key: id,
452 displayText: displayName
453 }))
454 },
455 ...[{
456 selectedKey: componentScreenToBreadcrumb[screen],
457 menuItems: [{
458 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
459 displayText: i18n('General')
460 }, {
461 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
462 displayText: i18n('Compute')
463 }, {
464 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
465 displayText: i18n('High Availability & Load Balancing')
466 }, {
467 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
468 displayText: i18n('Networks')
469 }, {
470 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
471 displayText: i18n('Storage')
472 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300473 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
474 displayText: i18n('Images')
475 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200476 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
477 displayText: i18n('Process Details')
478 }, {
479 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
480 displayText: i18n('Monitoring')
Avi Ziv61070c92017-07-26 17:37:57 +0300481 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200482 }]
483 ];
484 }
485 return returnedBreadcrumb;
486 }
487 }
488}