blob: 905712003ac150bbb0f65e803223e01bbad0f7d8 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import React from 'react';
talig8e9c0652017-12-20 14:30:43 +020017import PropTypes from 'prop-types';
Michael Landoefa037d2017-02-19 12:57:33 +020018import ReactDOM from 'react-dom';
19import {connect} from 'react-redux';
20import isEqual from 'lodash/isEqual.js';
21import objectValues from 'lodash/values.js';
22
23import i18n from 'nfvo-utils/i18n/i18n.js';
24import Application from 'sdc-app/Application.jsx';
25import store from 'sdc-app/AppStore.js';
26import Configuration from 'sdc-app/config/Configuration.js';
talig8e9c0652017-12-20 14:30:43 +020027import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020028
AviZi280f8012017-06-09 02:39:56 +030029import Onboard from './onboard/Onboard.js';
talig8e9c0652017-12-20 14:30:43 +020030import VersionsPage from './versionsPage/VersionsPage.js';
Michael Landoefa037d2017-02-19 12:57:33 +020031import LicenseModel from './licenseModel/LicenseModel.js';
AviZi280f8012017-06-09 02:39:56 +030032import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030033import ActivityLog from 'sdc-app/common/activity-log/ActivityLog.js';
AviZi280f8012017-06-09 02:39:56 +030034
Michael Landoefa037d2017-02-19 12:57:33 +020035import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
36import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js';
37import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
38import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
39import SoftwareProduct from './softwareProduct/SoftwareProduct.js';
40import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js';
41import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js';
42import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js';
43import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030044import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js';
Michael Landoefa037d2017-02-19 12:57:33 +020045import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js';
AviZi280f8012017-06-09 02:39:56 +030046import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030047
48import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js';
Michael Landoefa037d2017-02-19 12:57:33 +020049import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
50import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js';
51import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
52import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
53import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js';
54import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030055import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js';
Michael Landoefa037d2017-02-19 12:57:33 +020056import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
talig8e9c0652017-12-20 14:30:43 +020057import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030058
talig8e9c0652017-12-20 14:30:43 +020059import {itemTypes} from './versionsPage/VersionsPageConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020060
AviZi280f8012017-06-09 02:39:56 +030061import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
62
talig8e9c0652017-12-20 14:30:43 +020063import {actionTypes, enums, screenTypes} from './OnboardingConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020064import OnboardingActionHelper from './OnboardingActionHelper.js';
65
Michael Landoefa037d2017-02-19 12:57:33 +020066class OnboardingView extends React.Component {
67 static propTypes = {
talig8e9c0652017-12-20 14:30:43 +020068 currentScreen: PropTypes.shape({
69 screen: PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired,
70 props: PropTypes.object.isRequired,
71 itemPermission: PropTypes.object
Michael Landoefa037d2017-02-19 12:57:33 +020072 }).isRequired
73 };
74
75 componentDidMount() {
76 let element = ReactDOM.findDOMNode(this);
77 element.addEventListener('click', event => {
78 if (event.target.tagName === 'A') {
79 event.preventDefault();
80 }
81 });
82 ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType =>
83 element.addEventListener(eventType, event => event.stopPropagation())
84 );
85 }
86
87 render() {
88 let {currentScreen} = this.props;
89 let {screen, props} = currentScreen;
90
91 return (
92 <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'>
93 {(() => {
94 switch (screen) {
95 case enums.SCREEN.ONBOARDING_CATALOG:
AviZi280f8012017-06-09 02:39:56 +030096 return <Onboard {...props}/>;
talig8e9c0652017-12-20 14:30:43 +020097 case enums.SCREEN.VERSIONS_PAGE:
98 return <VersionsPage {...props} />;
Michael Landoefa037d2017-02-19 12:57:33 +020099
100 case enums.SCREEN.LICENSE_AGREEMENTS:
101 case enums.SCREEN.FEATURE_GROUPS:
102 case enums.SCREEN.ENTITLEMENT_POOLS:
103 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300104 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
105 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200106 return (
107 <LicenseModel currentScreen={currentScreen}>
talig8e9c0652017-12-20 14:30:43 +0200108 {
109 (()=>{
110 switch(screen) {
111 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
112 return <LicenseModelOverview {...props}/>;
113 case enums.SCREEN.LICENSE_AGREEMENTS:
114 return <LicenseAgreementListEditor {...props}/>;
115 case enums.SCREEN.FEATURE_GROUPS:
116 return <FeatureGroupListEditor {...props}/>;
117 case enums.SCREEN.ENTITLEMENT_POOLS:
118 return <EntitlementPoolsListEditor {...props}/>;
119 case enums.SCREEN.LICENSE_KEY_GROUPS:
120 return <LicenseKeyGroupsListEditor {...props}/>;
121 case enums.SCREEN.ACTIVITY_LOG:
122 return <ActivityLog {...props}/>;
123 }
124 })()
125 }
Michael Landoefa037d2017-02-19 12:57:33 +0200126 </LicenseModel>
127 );
128
129 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
130 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
131 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
132 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300133 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200134 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300135 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
Michael Landoefa037d2017-02-19 12:57:33 +0200136 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
137 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
138 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
139 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
140 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
141 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
142 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300143 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200144 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
AviZi280f8012017-06-09 02:39:56 +0300145 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200146 return (
147 <SoftwareProduct currentScreen={currentScreen}>
talig8e9c0652017-12-20 14:30:43 +0200148 {
149 (()=>{
150 switch(screen) {
151 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
152 return <SoftwareProductLandingPage {...props}/>;
153 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
154 return <SoftwareProductDetails {...props}/>;
155 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
156 return <SoftwareProductAttachments className='no-padding-content-area' {...props} />;
157 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
158 return <SoftwareProductProcesses {...props}/>;
159 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
160 return <SoftwareProductDeployment {...props}/>;
161 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
162 return <SoftwareProductNetworks {...props}/>;
163 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
164 return <SoftwareProductDependencies {...props} />;
165 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
166 return <SoftwareProductComponentsList {...props}/>;
167 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
168 return <SoftwareProductComponentProcessesList {...props}/>;
169 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
170 return <SoftwareProductComponentStorage {...props}/>;
171 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
172 return <SoftwareProductComponentsNetworkList {...props}/>;
173 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
174 return <SoftwareProductComponentsGeneral{...props}/>;
175 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
176 return <SoftwareProductComponentsCompute {...props}/>;
177 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
178 return <SoftwareProductComponentLoadBalancing{...props}/>;
179 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
180 return <SoftwareProductComponentsImageList{...props}/>;
181 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
182 return <SoftwareProductComponentsMonitoring {...props}/>;
183 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
184 return <ActivityLog {...props}/>;
185 }
186 })()
187 }
Michael Landoefa037d2017-02-19 12:57:33 +0200188 </SoftwareProduct>
189 );
190 }
191 })()}
192 </div>
193 );
194 }
195}
196const mapStateToProps = ({currentScreen}) => ({currentScreen});
197let Onboarding = connect(mapStateToProps, null)(OnboardingView);
198
199export default class OnboardingPunchOut {
200
201 render({options: {data, apiRoot, apiHeaders}, onEvent}, element) {
202 if (!this.unsubscribeFromStore) {
203 this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange());
204 }
205
206 if (!this.isConfigSet) {
207 Configuration.setATTApiRoot(apiRoot);
208 Configuration.setATTApiHeaders(apiHeaders);
209 this.isConfigSet = true;
210 }
211
212 this.onEvent = (...args) => onEvent(...args);
213 this.handleData(data);
214
215 if (!this.rendered) {
216 ReactDOM.render(
217 <Application>
218 <Onboarding/>
219 </Application>,
220 element
221 );
222 this.rendered = true;
223 }
224 }
225
226 unmount(element) {
227 ReactDOM.unmountComponentAtNode(element);
228 this.rendered = false;
229 this.unsubscribeFromStore();
230 this.unsubscribeFromStore = null;
231 }
232
233 handleData(data) {
234 let {breadcrumbs: {selectedKeys = []} = {}} = data;
235 let dispatch = action => store.dispatch(action);
talig8e9c0652017-12-20 14:30:43 +0200236 let {currentScreen, users: {usersList}, softwareProductList, licenseModelList, softwareProduct: {softwareProductEditor: {data: vspData = {}},
237 softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState();
238
239 let {props: {version, isReadOnlyMode}, screen} = currentScreen;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300240 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200241 if (this.programmaticBreadcrumbsUpdate) {
242 this.prevSelectedKeys = selectedKeys;
243 this.programmaticBreadcrumbsUpdate = false;
244 return;
245 }
Michael Landoefa037d2017-02-19 12:57:33 +0200246 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
247 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200248
AviZi280f8012017-06-09 02:39:56 +0300249 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
250 let preNavigate = Promise.resolve();
talig8e9c0652017-12-20 14:30:43 +0200251 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) {
AviZi280f8012017-06-09 02:39:56 +0300252 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300253 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300254 softwareProductId: prevVspId,
talig8e9c0652017-12-20 14:30:43 +0200255 version,
AviZi280f8012017-06-09 02:39:56 +0300256 vspComponentId: prevComponentId,
257 dataToSave
258 });
Michael Landoefa037d2017-02-19 12:57:33 +0200259 }
AviZi280f8012017-06-09 02:39:56 +0300260
261 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
262 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
talig8e9c0652017-12-20 14:30:43 +0200263 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
264 Promise.resolve();
AviZi280f8012017-06-09 02:39:56 +0300265 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
266 this.prevSelectedKeys = selectedKeys;
267 if (selectedKeys.length === 0) {
talig8e9c0652017-12-20 14:30:43 +0200268 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG});
269
AviZi280f8012017-06-09 02:39:56 +0300270 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
271 let [licenseModelId, , licenseModelScreen] = selectedKeys;
talig8e9c0652017-12-20 14:30:43 +0200272 let licenseModel = licenseModelList.find(vlm => vlm.id === licenseModelId);
273 ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL,
274 props: {licenseModelId, version, licenseModel, usersList}});
275
AviZi280f8012017-06-09 02:39:56 +0300276 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
277 let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys;
278 let softwareProduct = softwareProductId ?
279 softwareProductList.find(({id}) => id === softwareProductId) :
280 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
281 if (!softwareProductId) {
282 softwareProductId = softwareProduct.id;
283 }
talig8e9c0652017-12-20 14:30:43 +0200284 if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) {
285 softwareProduct = vspData;
286 //check current vsp fields to determine which file has uploaded
287 if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) {
288 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
289 }
290 else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) {
291 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
292 }
AviZi280f8012017-06-09 02:39:56 +0300293 }
talig8e9c0652017-12-20 14:30:43 +0200294
295 ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
296 props: {softwareProductId, softwareProduct, version, usersList}});
297
AviZi280f8012017-06-09 02:39:56 +0300298 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
299 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
300 let softwareProduct = softwareProductId ?
301 softwareProductList.find(({id}) => id === softwareProductId) :
302 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
303 if (!softwareProductId) {
304 softwareProductId = softwareProduct.id;
305 }
talig8e9c0652017-12-20 14:30:43 +0200306 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT,
307 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
308
AviZi280f8012017-06-09 02:39:56 +0300309 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
310 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
311 let softwareProduct = softwareProductId ?
312 softwareProductList.find(({id}) => id === softwareProductId) :
313 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
314 if (!softwareProductId) {
315 softwareProductId = softwareProduct.id;
316 }
talig8e9c0652017-12-20 14:30:43 +0200317 ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
318 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
319
AviZi280f8012017-06-09 02:39:56 +0300320 } else {
321 console.error('Unknown breadcrumbs path: ', selectedKeys);
322 }
323 }).catch(() => {
324 store.dispatch({
325 type: actionTypes.SET_CURRENT_SCREEN,
326 currentScreen: {
327 ...currentScreen,
328 forceBreadCrumbsUpdate: true
329 }
330 });
331 });
Michael Landoefa037d2017-02-19 12:57:33 +0200332 }
333 }
334
335 handleStoreChange() {
talig8e9c0652017-12-20 14:30:43 +0200336 let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage:
337 {versionsList: {itemType, itemId}},
338 softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}},
shrek2000c8a540b2017-09-11 15:45:37 +0300339 softwareProductComponents: {componentsList}}} = store.getState();
talig8e9c0652017-12-20 14:30:43 +0200340 const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList];
341 const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList];
342 let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList};
343
AviZi280f8012017-06-09 02:39:56 +0300344 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200345 this.prevBreadcrumbsData = breadcrumbsData;
346 this.breadcrumbsPrefixSelected = false;
347 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200348 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
349 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300350 store.dispatch({
351 type: actionTypes.SET_CURRENT_SCREEN,
352 currentScreen: {
353 ...currentScreen,
354 forceBreadCrumbsUpdate: false
355 }
356 });
Michael Landoefa037d2017-02-19 12:57:33 +0200357 }
358 }
359
talig8e9c0652017-12-20 14:30:43 +0200360 buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct,
361 wholeLicenseModelList, wholeSoftwareProductList, componentsList}) {
362 let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct;
Michael Landoefa037d2017-02-19 12:57:33 +0200363 let screenToBreadcrumb;
364 switch (screen) {
365 case enums.SCREEN.ONBOARDING_CATALOG:
366 return [];
367
talig8e9c0652017-12-20 14:30:43 +0200368 case enums.SCREEN.VERSIONS_PAGE:
369 let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [
370 {
371 selectedKey: itemId,
372 menuItems: wholeLicenseModelList.map(({id, name}) => ({
373 key: id,
374 displayText: name
375 }))
376 }] : [
377 {
378 selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId,
379 menuItems: wholeLicenseModelList.map(({id, name}) => ({
380 key: id,
381 displayText: name
382 }))
383 },
384 {
385 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
386 menuItems: [{
387 key: enums.BREADCRUMS.LICENSE_MODEL,
388 displayText: i18n('License Model')
389 }, {
390 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
391 displayText: i18n('Software Products')
392 }]
393 },
394 {
395 selectedKey: itemId,
396 menuItems: wholeSoftwareProductList
397 .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId)
398 .map(({id, name}) => ({
399 key: id,
400 displayText: name
401 }))
402 },
403 ];
404 return [
405 ...firstMenuItems,
406 {
407 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
408 menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}]
409 }
410 ];
411
Michael Landoefa037d2017-02-19 12:57:33 +0200412 case enums.SCREEN.LICENSE_AGREEMENTS:
413 case enums.SCREEN.FEATURE_GROUPS:
414 case enums.SCREEN.ENTITLEMENT_POOLS:
415 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300416 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
417 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200418 screenToBreadcrumb = {
419 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
420 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
421 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300422 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
423 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
424 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200425 };
426 return [
427 {
428 selectedKey: props.licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200429 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200430 key: id,
talig8e9c0652017-12-20 14:30:43 +0200431 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200432 }))
433 },
434 {
435 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
436 menuItems: [{
437 key: enums.BREADCRUMS.LICENSE_MODEL,
438 displayText: i18n('License Model')
439 },
talig8e9c0652017-12-20 14:30:43 +0200440 ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
441 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
442 displayText: i18n('Software Products')
443 }])]
Michael Landoefa037d2017-02-19 12:57:33 +0200444 }, {
445 selectedKey: screenToBreadcrumb[screen],
446 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300447 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
448 displayText: i18n('Overview')
449 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200450 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
451 displayText: i18n('License Agreements')
452 }, {
453 key: enums.BREADCRUMS.FEATURE_GROUPS,
454 displayText: i18n('Feature Groups')
455 }, {
456 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
457 displayText: i18n('Entitlement Pools')
458 }, {
459 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
460 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300461 }, {
462 key: enums.BREADCRUMS.ACTIVITY_LOG,
463 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200464 }]
465 }
466 ];
467
468 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
469 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
470 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
471 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300472 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200473 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300474 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
475 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200476 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
477
478 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
479 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
480 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
481 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
482 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
483 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300484 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200485 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
486 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300487 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200488 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
489 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
490 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300491 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200492 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300493 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
494 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
495 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200496 };
497 let componentScreenToBreadcrumb = {
498 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
499 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
500 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
501 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
502 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
503 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300504 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200505 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
506 };
talig8e9c0652017-12-20 14:30:43 +0200507 let licenseModelId = currentSoftwareProduct.vendorId;
Michael Landoefa037d2017-02-19 12:57:33 +0200508 let returnedBreadcrumb = [
509 {
510 selectedKey: licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200511 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200512 key: id,
talig8e9c0652017-12-20 14:30:43 +0200513 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200514 }))
515 },
516 {
517 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
518 menuItems: [{
519 key: enums.BREADCRUMS.LICENSE_MODEL,
520 displayText: i18n('License Model')
521 }, {
522 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
523 displayText: i18n('Software Products')
524 }]
525 },
526 {
527 selectedKey: props.softwareProductId,
talig8e9c0652017-12-20 14:30:43 +0200528 menuItems: wholeSoftwareProductList
529 .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId)
Michael Landoefa037d2017-02-19 12:57:33 +0200530 .map(({id, name}) => ({
531 key: id,
532 displayText: name
533 }))
534 },
AviZi280f8012017-06-09 02:39:56 +0300535 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200536 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
537 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300538 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
539 displayText: i18n('Overview')
540 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200541 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
542 displayText: i18n('General')
543 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300544 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
545 displayText: i18n('Deployment Flavors')
546 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200547 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
548 displayText: i18n('Process Details')
549 }, {
550 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
551 displayText: i18n('Networks')
552 }, {
AviZi280f8012017-06-09 02:39:56 +0300553 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
554 displayText: i18n('Components Dependencies')
555 }, {
556 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
557 displayText: i18n('Attachments')
558 }, {
559 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
560 displayText: i18n('Activity Log')
561 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200562 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
563 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300564 }].filter(item => {
AviZi280f8012017-06-09 02:39:56 +0300565 switch (item.key) {
566 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
talig8e9c0652017-12-20 14:30:43 +0200567 let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP;
AviZi280f8012017-06-09 02:39:56 +0300568 return isHeatData;
569 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300570 return (componentsList.length > 0);
571 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
talig8e9c0652017-12-20 14:30:43 +0200572 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300573 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300574 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300575 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300576 default:
577 return true;
578 }
579 })
Michael Landoefa037d2017-02-19 12:57:33 +0200580 }])
581 ];
582 if(props.componentId) {
583 returnedBreadcrumb = [
584 ...returnedBreadcrumb, {
585 selectedKey: props.componentId,
586 menuItems: componentsList
587 .map(({id, displayName}) => ({
588 key: id,
589 displayText: displayName
590 }))
591 },
592 ...[{
593 selectedKey: componentScreenToBreadcrumb[screen],
594 menuItems: [{
595 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
596 displayText: i18n('General')
597 }, {
598 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
599 displayText: i18n('Compute')
600 }, {
601 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
602 displayText: i18n('High Availability & Load Balancing')
603 }, {
604 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
605 displayText: i18n('Networks')
606 }, {
607 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
608 displayText: i18n('Storage')
609 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300610 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
611 displayText: i18n('Images')
612 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200613 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
614 displayText: i18n('Process Details')
615 }, {
616 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
617 displayText: i18n('Monitoring')
Avi Ziv61070c92017-07-26 17:37:57 +0300618 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200619 }]
620 ];
621 }
622 return returnedBreadcrumb;
623 }
624 }
625}