blob: e8a844b03f0672cf74b3d1642c5d9b2a1eb14fba [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';
17import ReactDOM from 'react-dom';
18import {connect} from 'react-redux';
19import isEqual from 'lodash/isEqual.js';
20import objectValues from 'lodash/values.js';
21
22import i18n from 'nfvo-utils/i18n/i18n.js';
23import Application from 'sdc-app/Application.jsx';
24import store from 'sdc-app/AppStore.js';
25import Configuration from 'sdc-app/config/Configuration.js';
26
AviZi280f8012017-06-09 02:39:56 +030027import Onboard from './onboard/Onboard.js';
Michael Landoefa037d2017-02-19 12:57:33 +020028import LicenseModel from './licenseModel/LicenseModel.js';
AviZi280f8012017-06-09 02:39:56 +030029import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js';
30import ActivityLog from 'nfvo-components/activity-log/ActivityLog.js';
31import {doesHeatDataExist} from './softwareProduct/attachments/SoftwareProductAttachmentsUtils.js';
32
Michael Landoefa037d2017-02-19 12:57:33 +020033import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
34import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js';
35import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
36import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
37import SoftwareProduct from './softwareProduct/SoftwareProduct.js';
38import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js';
39import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js';
40import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js';
41import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js';
42import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js';
AviZi280f8012017-06-09 02:39:56 +030043import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js';
Michael Landoefa037d2017-02-19 12:57:33 +020044import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponentsList.js';
45import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
46import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js';
47import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
48import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
49import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js';
50import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
51import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
52import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
AviZi280f8012017-06-09 02:39:56 +030053import {statusEnum as VCItemStatus} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
54import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
Michael Landoefa037d2017-02-19 12:57:33 +020055
AviZi280f8012017-06-09 02:39:56 +030056import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
57
58import {actionTypes, enums} from './OnboardingConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020059import OnboardingActionHelper from './OnboardingActionHelper.js';
60
61
62class OnboardingView extends React.Component {
63 static propTypes = {
64 currentScreen: React.PropTypes.shape({
65 screen: React.PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired,
66 props: React.PropTypes.object.isRequired
67 }).isRequired
68 };
69
70 componentDidMount() {
71 let element = ReactDOM.findDOMNode(this);
72 element.addEventListener('click', event => {
73 if (event.target.tagName === 'A') {
74 event.preventDefault();
75 }
76 });
77 ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType =>
78 element.addEventListener(eventType, event => event.stopPropagation())
79 );
80 }
81
82 render() {
83 let {currentScreen} = this.props;
84 let {screen, props} = currentScreen;
85
86 return (
87 <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'>
88 {(() => {
89 switch (screen) {
90 case enums.SCREEN.ONBOARDING_CATALOG:
AviZi280f8012017-06-09 02:39:56 +030091 return <Onboard {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +020092
93 case enums.SCREEN.LICENSE_AGREEMENTS:
94 case enums.SCREEN.FEATURE_GROUPS:
95 case enums.SCREEN.ENTITLEMENT_POOLS:
96 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +030097 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
98 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +020099 return (
100 <LicenseModel currentScreen={currentScreen}>
101 {
102 (()=>{
103 switch(screen) {
AviZi280f8012017-06-09 02:39:56 +0300104 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
105 return <LicenseModelOverview {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200106 case enums.SCREEN.LICENSE_AGREEMENTS:
107 return <LicenseAgreementListEditor {...props}/>;
108 case enums.SCREEN.FEATURE_GROUPS:
109 return <FeatureGroupListEditor {...props}/>;
110 case enums.SCREEN.ENTITLEMENT_POOLS:
111 return <EntitlementPoolsListEditor {...props}/>;
112 case enums.SCREEN.LICENSE_KEY_GROUPS:
113 return <LicenseKeyGroupsListEditor {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300114 case enums.SCREEN.ACTIVITY_LOG:
115 return <ActivityLog {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200116 }
117 })()
118 }
119 </LicenseModel>
120 );
121
122 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
123 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
124 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
125 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
126 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300127 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
Michael Landoefa037d2017-02-19 12:57:33 +0200128 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
129 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
130 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
131 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
132 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
133 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
134 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
135 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
AviZi280f8012017-06-09 02:39:56 +0300136 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200137 return (
138 <SoftwareProduct currentScreen={currentScreen}>
139 {
140 (()=>{
141 switch(screen) {
142 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
143 return <SoftwareProductLandingPage {...props}/>;
144 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
145 return <SoftwareProductDetails {...props}/>;
146 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
AviZi280f8012017-06-09 02:39:56 +0300147 return <SoftwareProductAttachments className='no-padding-content-area' {...props} />;
Michael Landoefa037d2017-02-19 12:57:33 +0200148 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
149 return <SoftwareProductProcesses {...props}/>;
150 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
151 return <SoftwareProductNetworks {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300152 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
153 return <SoftwareProductDependencies {...props} />;
Michael Landoefa037d2017-02-19 12:57:33 +0200154 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
155 return <SoftwareProductComponentsList {...props}/>;
156 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
157 return <SoftwareProductComponentProcessesList {...props}/>;
158 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
159 return <SoftwareProductComponentStorage {...props}/>;
160 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
161 return <SoftwareProductComponentsNetworkList {...props}/>;
162 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
163 return <SoftwareProductComponentsGeneral{...props}/>;
164 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
165 return <SoftwareProductComponentsCompute {...props}/>;
166 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
167 return <SoftwareProductComponentLoadBalancing{...props}/>;
168 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
169 return <SoftwareProductComponentsMonitoring {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300170 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
171 return <ActivityLog {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200172 }
173 })()
174 }
175 </SoftwareProduct>
176 );
177 }
178 })()}
179 </div>
180 );
181 }
182}
183const mapStateToProps = ({currentScreen}) => ({currentScreen});
184let Onboarding = connect(mapStateToProps, null)(OnboardingView);
185
186export default class OnboardingPunchOut {
187
188 render({options: {data, apiRoot, apiHeaders}, onEvent}, element) {
189 if (!this.unsubscribeFromStore) {
190 this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange());
191 }
192
193 if (!this.isConfigSet) {
194 Configuration.setATTApiRoot(apiRoot);
195 Configuration.setATTApiHeaders(apiHeaders);
196 this.isConfigSet = true;
197 }
198
199 this.onEvent = (...args) => onEvent(...args);
200 this.handleData(data);
201
202 if (!this.rendered) {
203 ReactDOM.render(
204 <Application>
205 <Onboarding/>
206 </Application>,
207 element
208 );
209 this.rendered = true;
210 }
211 }
212
213 unmount(element) {
214 ReactDOM.unmountComponentAtNode(element);
215 this.rendered = false;
216 this.unsubscribeFromStore();
217 this.unsubscribeFromStore = null;
218 }
219
220 handleData(data) {
221 let {breadcrumbs: {selectedKeys = []} = {}} = data;
222 let dispatch = action => store.dispatch(action);
AviZi280f8012017-06-09 02:39:56 +0300223 let {currentScreen, softwareProductList, softwareProduct: {softwareProductEditor: {data: vspData = {}},
224 softwareProductComponents = {}, softwareProductQuestionnaire = {}},
225 licenseModelList, licenseModel: {licenseModelEditor: {data: {id: currentLicenseModelId, version: currentLicenseModelVersion} = {}}}} = store.getState();
226 let {id: currentSoftwareProductId, version: currentSoftwareProductVersion} = vspData;
227 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200228 if (this.programmaticBreadcrumbsUpdate) {
229 this.prevSelectedKeys = selectedKeys;
230 this.programmaticBreadcrumbsUpdate = false;
231 return;
232 }
Michael Landoefa037d2017-02-19 12:57:33 +0200233 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
234 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200235
AviZi280f8012017-06-09 02:39:56 +0300236 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
237 let preNavigate = Promise.resolve();
238 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && vspData.status === VCItemStatus.CHECK_OUT_STATUS && VersionControllerUtils.isCheckedOutByCurrentUser(vspData)) {
239 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
240 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
241 softwareProductId: prevVspId,
242 version: currentSoftwareProductVersion,
243 vspComponentId: prevComponentId,
244 dataToSave
245 });
Michael Landoefa037d2017-02-19 12:57:33 +0200246 }
AviZi280f8012017-06-09 02:39:56 +0300247
248 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
249 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
250 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
251 Promise.resolve();
252 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
253 this.prevSelectedKeys = selectedKeys;
254 if (selectedKeys.length === 0) {
255 OnboardingActionHelper.navigateToOnboardingCatalog(dispatch);
256 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
257 let [licenseModelId, , licenseModelScreen] = selectedKeys;
258 if (!licenseModelScreen) {
259 licenseModelScreen = enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW;
260 }
261 if (currentLicenseModelId !== licenseModelId) {
262 currentLicenseModelVersion = licenseModelList.find(lm => lm.id === licenseModelId).version;
263 }
264 switch (licenseModelScreen) {
265 case enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW:
266 OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version: currentLicenseModelVersion});
267 break;
268 case enums.BREADCRUMS.LICENSE_AGREEMENTS:
269 OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version: currentLicenseModelVersion});
270 break;
271 case enums.BREADCRUMS.FEATURE_GROUPS:
272 OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion});
273 break;
274 case enums.BREADCRUMS.ENTITLEMENT_POOLS:
275 OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version: currentLicenseModelVersion});
276 break;
277 case enums.BREADCRUMS.LICENSE_KEY_GROUPS:
278 OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion});
279 break;
280 case enums.BREADCRUMS.ACTIVITY_LOG:
281 OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version: currentLicenseModelVersion});
282 break;
283 }
284 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
285 let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys;
286 let softwareProduct = softwareProductId ?
287 softwareProductList.find(({id}) => id === softwareProductId) :
288 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
289 if (!softwareProductId) {
290 softwareProductId = softwareProduct.id;
291 }
292 if (currentSoftwareProductId !== softwareProductId) {
293 currentSoftwareProductVersion = softwareProduct.version;
294 }
295 switch (softwareProductScreen) {
296 case enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE:
297 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
298 break;
299 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS:
300 OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
301 break;
302 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
303 OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
304 break;
305 case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES:
306 OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
307 break;
308 case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS:
309 OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
310 break;
311 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
312 OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
313 break;
314 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG:
315 OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
316 break;
317 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
318 OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
319 dispatch({
320 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
321 mapOfExpandedIds: {
322 [SoftwareProductNavigationItems.COMPONENTS]: true
323 }
324 });
325 break;
326 default:
327 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
328 break;
329 }
330 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
331 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
332 let softwareProduct = softwareProductId ?
333 softwareProductList.find(({id}) => id === softwareProductId) :
334 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
335 if (!softwareProductId) {
336 softwareProductId = softwareProduct.id;
337 }
338 if (currentSoftwareProductId !== softwareProductId) {
339 currentSoftwareProductVersion = softwareProduct.version;
340 }
341 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
342 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
343 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
344 let softwareProduct = softwareProductId ?
345 softwareProductList.find(({id}) => id === softwareProductId) :
346 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
347 if (!softwareProductId) {
348 softwareProductId = softwareProduct.id;
349 }
350 if (currentSoftwareProductId !== softwareProductId) {
351 currentSoftwareProductVersion = softwareProduct.version;
352 }
353 switch (componentScreen) {
354 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
355 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
356 break;
357 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
358 OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId});
359 break;
360 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
361 OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId});
362 break;
363 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
364 OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId});
365 break;
366 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
367 OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId});
368 break;
369 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
370 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId});
371 break;
372 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
373 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId});
374 break;
375 }
376 } else {
377 console.error('Unknown breadcrumbs path: ', selectedKeys);
378 }
379 }).catch(() => {
380 store.dispatch({
381 type: actionTypes.SET_CURRENT_SCREEN,
382 currentScreen: {
383 ...currentScreen,
384 forceBreadCrumbsUpdate: true
385 }
386 });
387 });
Michael Landoefa037d2017-02-19 12:57:33 +0200388 }
389 }
390
391 handleStoreChange() {
AviZi280f8012017-06-09 02:39:56 +0300392 let {currentScreen, licenseModelList, softwareProductList,
393 softwareProduct: {softwareProductComponents: {componentsList}, softwareProductAttachments: {heatSetup}}} = store.getState();
394 let breadcrumbsData = {currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup};
395 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200396 this.prevBreadcrumbsData = breadcrumbsData;
397 this.breadcrumbsPrefixSelected = false;
398 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200399 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
400 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300401 store.dispatch({
402 type: actionTypes.SET_CURRENT_SCREEN,
403 currentScreen: {
404 ...currentScreen,
405 forceBreadCrumbsUpdate: false
406 }
407 });
Michael Landoefa037d2017-02-19 12:57:33 +0200408 }
409 }
410
AviZi280f8012017-06-09 02:39:56 +0300411 buildBreadcrumbs({currentScreen: {screen, props}, licenseModelList, softwareProductList, componentsList, heatSetup}) {
Michael Landoefa037d2017-02-19 12:57:33 +0200412 let screenToBreadcrumb;
413 switch (screen) {
414 case enums.SCREEN.ONBOARDING_CATALOG:
415 return [];
416
417 case enums.SCREEN.LICENSE_AGREEMENTS:
418 case enums.SCREEN.FEATURE_GROUPS:
419 case enums.SCREEN.ENTITLEMENT_POOLS:
420 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300421 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
422 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200423 screenToBreadcrumb = {
424 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
425 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
426 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300427 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
428 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
429 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200430 };
431 return [
432 {
433 selectedKey: props.licenseModelId,
434 menuItems: licenseModelList.map(({id, vendorName}) => ({
435 key: id,
436 displayText: vendorName
437 }))
438 },
439 {
440 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
441 menuItems: [{
442 key: enums.BREADCRUMS.LICENSE_MODEL,
443 displayText: i18n('License Model')
444 },
445 ...(softwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
446 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
447 displayText: i18n('Software Products')
448 }])]
449 }, {
450 selectedKey: screenToBreadcrumb[screen],
451 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300452 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
453 displayText: i18n('Overview')
454 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200455 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
456 displayText: i18n('License Agreements')
457 }, {
458 key: enums.BREADCRUMS.FEATURE_GROUPS,
459 displayText: i18n('Feature Groups')
460 }, {
461 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
462 displayText: i18n('Entitlement Pools')
463 }, {
464 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
465 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300466 }, {
467 key: enums.BREADCRUMS.ACTIVITY_LOG,
468 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200469 }]
470 }
471 ];
472
473 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
474 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
475 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
476 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
477 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300478 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
479 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200480 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
481
482 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
483 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
484 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
485 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
486 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
487 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
488 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
489 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300490 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200491 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
492 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
493 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
494 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300495 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
496 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
497 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200498 };
499 let componentScreenToBreadcrumb = {
500 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
501 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
502 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
503 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
504 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
505 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
506 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
507 };
508 let licenseModelId = softwareProductList.find(({id}) => id === props.softwareProductId).vendorId;
509 let returnedBreadcrumb = [
510 {
511 selectedKey: licenseModelId,
512 menuItems: licenseModelList.map(({id, vendorName}) => ({
513 key: id,
514 displayText: vendorName
515 }))
516 },
517 {
518 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
519 menuItems: [{
520 key: enums.BREADCRUMS.LICENSE_MODEL,
521 displayText: i18n('License Model')
522 }, {
523 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
524 displayText: i18n('Software Products')
525 }]
526 },
527 {
528 selectedKey: props.softwareProductId,
529 menuItems: softwareProductList
530 .filter(({vendorId}) => vendorId === licenseModelId)
531 .map(({id, name}) => ({
532 key: id,
533 displayText: name
534 }))
535 },
AviZi280f8012017-06-09 02:39:56 +0300536 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200537 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
538 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300539 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
540 displayText: i18n('Overview')
541 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200542 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
543 displayText: i18n('General')
544 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200545 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
546 displayText: i18n('Process Details')
547 }, {
548 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
549 displayText: i18n('Networks')
550 }, {
AviZi280f8012017-06-09 02:39:56 +0300551 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
552 displayText: i18n('Components Dependencies')
553 }, {
554 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
555 displayText: i18n('Attachments')
556 }, {
557 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
558 displayText: i18n('Activity Log')
559 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200560 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
561 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300562 }].filter(item => {
563 let isHeatData = doesHeatDataExist(heatSetup);
564 let isComponentsData = componentsList.length > 0;
565 switch (item.key) {
566 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
567 return isHeatData;
568 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
569 return isComponentsData;
570 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
571 return isComponentsData;
572 default:
573 return true;
574 }
575 })
Michael Landoefa037d2017-02-19 12:57:33 +0200576 }])
577 ];
578 if(props.componentId) {
579 returnedBreadcrumb = [
580 ...returnedBreadcrumb, {
581 selectedKey: props.componentId,
582 menuItems: componentsList
583 .map(({id, displayName}) => ({
584 key: id,
585 displayText: displayName
586 }))
587 },
588 ...[{
589 selectedKey: componentScreenToBreadcrumb[screen],
590 menuItems: [{
591 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
592 displayText: i18n('General')
593 }, {
594 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
595 displayText: i18n('Compute')
596 }, {
597 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
598 displayText: i18n('High Availability & Load Balancing')
599 }, {
600 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
601 displayText: i18n('Networks')
602 }, {
603 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
604 displayText: i18n('Storage')
605 }, {
606 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
607 displayText: i18n('Process Details')
608 }, {
609 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
610 displayText: i18n('Monitoring')
611 }]
612 }]
613 ];
614 }
615 return returnedBreadcrumb;
616 }
617 }
618}