blob: aea5fc6406b4792bcb8adcb48a3192722781cc95 [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';
Avi Zivb8e2faf2017-07-18 19:45:38 +030030import ActivityLog from 'sdc-app/common/activity-log/ActivityLog.js';
AviZi280f8012017-06-09 02:39:56 +030031import {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';
Avi Zivb8e2faf2017-07-18 19:45:38 +030042import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js';
Michael Landoefa037d2017-02-19 12:57:33 +020043import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js';
AviZi280f8012017-06-09 02:39:56 +030044import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030045
46import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js';
Michael Landoefa037d2017-02-19 12:57:33 +020047import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
48import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js';
49import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
50import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
51import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js';
52import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030053import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js';
Michael Landoefa037d2017-02-19 12:57:33 +020054import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030055import {
56 navigationItems as SoftwareProductNavigationItems,
57 onboardingMethod as onboardingMethodTypes,
58 actionTypes as SoftwareProductActionTypes
59} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
60
AviZi280f8012017-06-09 02:39:56 +030061import {statusEnum as VCItemStatus} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
62import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
Michael Landoefa037d2017-02-19 12:57:33 +020063
AviZi280f8012017-06-09 02:39:56 +030064import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
65
66import {actionTypes, enums} from './OnboardingConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020067import OnboardingActionHelper from './OnboardingActionHelper.js';
68
69
70class OnboardingView extends React.Component {
71 static propTypes = {
72 currentScreen: React.PropTypes.shape({
73 screen: React.PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired,
74 props: React.PropTypes.object.isRequired
75 }).isRequired
76 };
77
78 componentDidMount() {
79 let element = ReactDOM.findDOMNode(this);
80 element.addEventListener('click', event => {
81 if (event.target.tagName === 'A') {
82 event.preventDefault();
83 }
84 });
85 ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType =>
86 element.addEventListener(eventType, event => event.stopPropagation())
87 );
88 }
89
90 render() {
91 let {currentScreen} = this.props;
92 let {screen, props} = currentScreen;
93
94 return (
95 <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'>
96 {(() => {
97 switch (screen) {
98 case enums.SCREEN.ONBOARDING_CATALOG:
AviZi280f8012017-06-09 02:39:56 +030099 return <Onboard {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200100
101 case enums.SCREEN.LICENSE_AGREEMENTS:
102 case enums.SCREEN.FEATURE_GROUPS:
103 case enums.SCREEN.ENTITLEMENT_POOLS:
104 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300105 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
106 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200107 return (
108 <LicenseModel currentScreen={currentScreen}>
109 {
110 (()=>{
111 switch(screen) {
AviZi280f8012017-06-09 02:39:56 +0300112 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
113 return <LicenseModelOverview {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200114 case enums.SCREEN.LICENSE_AGREEMENTS:
115 return <LicenseAgreementListEditor {...props}/>;
116 case enums.SCREEN.FEATURE_GROUPS:
117 return <FeatureGroupListEditor {...props}/>;
118 case enums.SCREEN.ENTITLEMENT_POOLS:
119 return <EntitlementPoolsListEditor {...props}/>;
120 case enums.SCREEN.LICENSE_KEY_GROUPS:
121 return <LicenseKeyGroupsListEditor {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300122 case enums.SCREEN.ACTIVITY_LOG:
123 return <ActivityLog {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200124 }
125 })()
126 }
127 </LicenseModel>
128 );
129
130 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
131 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
132 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
133 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300134 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200135 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300136 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
Michael Landoefa037d2017-02-19 12:57:33 +0200137 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
138 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
139 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
140 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
141 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
142 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
143 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300144 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200145 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
AviZi280f8012017-06-09 02:39:56 +0300146 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200147 return (
148 <SoftwareProduct currentScreen={currentScreen}>
149 {
150 (()=>{
151 switch(screen) {
152 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
153 return <SoftwareProductLandingPage {...props}/>;
154 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
155 return <SoftwareProductDetails {...props}/>;
156 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
AviZi280f8012017-06-09 02:39:56 +0300157 return <SoftwareProductAttachments className='no-padding-content-area' {...props} />;
Michael Landoefa037d2017-02-19 12:57:33 +0200158 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
159 return <SoftwareProductProcesses {...props}/>;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300160 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
161 return <SoftwareProductDeployment {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200162 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
163 return <SoftwareProductNetworks {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300164 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
165 return <SoftwareProductDependencies {...props} />;
Michael Landoefa037d2017-02-19 12:57:33 +0200166 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
167 return <SoftwareProductComponentsList {...props}/>;
168 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
169 return <SoftwareProductComponentProcessesList {...props}/>;
170 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
171 return <SoftwareProductComponentStorage {...props}/>;
172 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
173 return <SoftwareProductComponentsNetworkList {...props}/>;
174 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
175 return <SoftwareProductComponentsGeneral{...props}/>;
176 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
177 return <SoftwareProductComponentsCompute {...props}/>;
178 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
179 return <SoftwareProductComponentLoadBalancing{...props}/>;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300180 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
181 return <SoftwareProductComponentsImageList{...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200182 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
183 return <SoftwareProductComponentsMonitoring {...props}/>;
AviZi280f8012017-06-09 02:39:56 +0300184 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
185 return <ActivityLog {...props}/>;
Michael Landoefa037d2017-02-19 12:57:33 +0200186 }
187 })()
188 }
189 </SoftwareProduct>
190 );
191 }
192 })()}
193 </div>
194 );
195 }
196}
197const mapStateToProps = ({currentScreen}) => ({currentScreen});
198let Onboarding = connect(mapStateToProps, null)(OnboardingView);
199
200export default class OnboardingPunchOut {
201
202 render({options: {data, apiRoot, apiHeaders}, onEvent}, element) {
203 if (!this.unsubscribeFromStore) {
204 this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange());
205 }
206
207 if (!this.isConfigSet) {
208 Configuration.setATTApiRoot(apiRoot);
209 Configuration.setATTApiHeaders(apiHeaders);
210 this.isConfigSet = true;
211 }
212
213 this.onEvent = (...args) => onEvent(...args);
214 this.handleData(data);
215
216 if (!this.rendered) {
217 ReactDOM.render(
218 <Application>
219 <Onboarding/>
220 </Application>,
221 element
222 );
223 this.rendered = true;
224 }
225 }
226
227 unmount(element) {
228 ReactDOM.unmountComponentAtNode(element);
229 this.rendered = false;
230 this.unsubscribeFromStore();
231 this.unsubscribeFromStore = null;
232 }
233
234 handleData(data) {
235 let {breadcrumbs: {selectedKeys = []} = {}} = data;
236 let dispatch = action => store.dispatch(action);
Avi Zivb8e2faf2017-07-18 19:45:38 +0300237 let {currentScreen, softwareProductList, softwareProduct: {softwareProductEditor: {data: vspData = {}},
AviZi280f8012017-06-09 02:39:56 +0300238 softwareProductComponents = {}, softwareProductQuestionnaire = {}},
239 licenseModelList, licenseModel: {licenseModelEditor: {data: {id: currentLicenseModelId, version: currentLicenseModelVersion} = {}}}} = store.getState();
240 let {id: currentSoftwareProductId, version: currentSoftwareProductVersion} = vspData;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300241 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200242 if (this.programmaticBreadcrumbsUpdate) {
243 this.prevSelectedKeys = selectedKeys;
244 this.programmaticBreadcrumbsUpdate = false;
245 return;
246 }
Michael Landoefa037d2017-02-19 12:57:33 +0200247 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
248 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200249
AviZi280f8012017-06-09 02:39:56 +0300250 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
251 let preNavigate = Promise.resolve();
252 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && vspData.status === VCItemStatus.CHECK_OUT_STATUS && VersionControllerUtils.isCheckedOutByCurrentUser(vspData)) {
253 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300254 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300255 softwareProductId: prevVspId,
256 version: currentSoftwareProductVersion,
257 vspComponentId: prevComponentId,
258 dataToSave
259 });
Michael Landoefa037d2017-02-19 12:57:33 +0200260 }
AviZi280f8012017-06-09 02:39:56 +0300261
262 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
263 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
264 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
265 Promise.resolve();
266 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
267 this.prevSelectedKeys = selectedKeys;
268 if (selectedKeys.length === 0) {
269 OnboardingActionHelper.navigateToOnboardingCatalog(dispatch);
270 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
271 let [licenseModelId, , licenseModelScreen] = selectedKeys;
272 if (!licenseModelScreen) {
273 licenseModelScreen = enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW;
274 }
275 if (currentLicenseModelId !== licenseModelId) {
276 currentLicenseModelVersion = licenseModelList.find(lm => lm.id === licenseModelId).version;
277 }
278 switch (licenseModelScreen) {
279 case enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW:
280 OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version: currentLicenseModelVersion});
281 break;
282 case enums.BREADCRUMS.LICENSE_AGREEMENTS:
283 OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version: currentLicenseModelVersion});
284 break;
285 case enums.BREADCRUMS.FEATURE_GROUPS:
286 OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion});
287 break;
288 case enums.BREADCRUMS.ENTITLEMENT_POOLS:
289 OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version: currentLicenseModelVersion});
290 break;
291 case enums.BREADCRUMS.LICENSE_KEY_GROUPS:
292 OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion});
293 break;
294 case enums.BREADCRUMS.ACTIVITY_LOG:
295 OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version: currentLicenseModelVersion});
296 break;
297 }
298 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
299 let [licenseModelId, , softwareProductId, softwareProductScreen] = 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 }
306 if (currentSoftwareProductId !== softwareProductId) {
307 currentSoftwareProductVersion = softwareProduct.version;
308 }
309 switch (softwareProductScreen) {
310 case enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE:
311 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
312 break;
313 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS:
314 OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
315 break;
316 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
317 OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
318 break;
319 case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES:
320 OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
321 break;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300322 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
323 OnboardingActionHelper.navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
324 break;
AviZi280f8012017-06-09 02:39:56 +0300325 case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS:
326 OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
327 break;
328 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
329 OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
330 break;
331 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG:
332 OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
333 break;
334 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
335 OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
336 dispatch({
337 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
338 mapOfExpandedIds: {
339 [SoftwareProductNavigationItems.COMPONENTS]: true
340 }
341 });
342 break;
343 default:
344 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
345 break;
346 }
347 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
348 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
349 let softwareProduct = softwareProductId ?
350 softwareProductList.find(({id}) => id === softwareProductId) :
351 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
352 if (!softwareProductId) {
353 softwareProductId = softwareProduct.id;
354 }
355 if (currentSoftwareProductId !== softwareProductId) {
356 currentSoftwareProductVersion = softwareProduct.version;
357 }
358 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
359 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
360 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
361 let softwareProduct = softwareProductId ?
362 softwareProductList.find(({id}) => id === softwareProductId) :
363 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
364 if (!softwareProductId) {
365 softwareProductId = softwareProduct.id;
366 }
367 if (currentSoftwareProductId !== softwareProductId) {
368 currentSoftwareProductVersion = softwareProduct.version;
369 }
370 switch (componentScreen) {
371 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
372 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
373 break;
374 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300375 OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300376 break;
377 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300378 OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300379 break;
380 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300381 OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300382 break;
383 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300384 OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300385 break;
386 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300387 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300388 break;
389 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300390 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
391 break;
392 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
393 OnboardingActionHelper.navigateToComponentImages(dispatch, {
394 softwareProductId,
395 componentId,
396 version: currentSoftwareProductVersion
397 });
AviZi280f8012017-06-09 02:39:56 +0300398 break;
399 }
400 } else {
401 console.error('Unknown breadcrumbs path: ', selectedKeys);
402 }
403 }).catch(() => {
404 store.dispatch({
405 type: actionTypes.SET_CURRENT_SCREEN,
406 currentScreen: {
407 ...currentScreen,
408 forceBreadCrumbsUpdate: true
409 }
410 });
411 });
Michael Landoefa037d2017-02-19 12:57:33 +0200412 }
413 }
414
415 handleStoreChange() {
AviZi280f8012017-06-09 02:39:56 +0300416 let {currentScreen, licenseModelList, softwareProductList,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300417 softwareProduct: {softwareProductEditor: {data = {onboardingMethod: ''}},
Avi Ziv61070c92017-07-26 17:37:57 +0300418 softwareProductComponents: {componentsList}, softwareProductAttachments: {heatSetup}}} = store.getState();
Avi Zivb8e2faf2017-07-18 19:45:38 +0300419 let {onboardingMethod} = data;
Avi Ziv61070c92017-07-26 17:37:57 +0300420 let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup};
AviZi280f8012017-06-09 02:39:56 +0300421 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200422 this.prevBreadcrumbsData = breadcrumbsData;
423 this.breadcrumbsPrefixSelected = false;
424 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200425 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
426 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300427 store.dispatch({
428 type: actionTypes.SET_CURRENT_SCREEN,
429 currentScreen: {
430 ...currentScreen,
431 forceBreadCrumbsUpdate: false
432 }
433 });
Michael Landoefa037d2017-02-19 12:57:33 +0200434 }
435 }
436
Avi Ziv61070c92017-07-26 17:37:57 +0300437 buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, heatSetup}) {
Michael Landoefa037d2017-02-19 12:57:33 +0200438 let screenToBreadcrumb;
439 switch (screen) {
440 case enums.SCREEN.ONBOARDING_CATALOG:
441 return [];
442
443 case enums.SCREEN.LICENSE_AGREEMENTS:
444 case enums.SCREEN.FEATURE_GROUPS:
445 case enums.SCREEN.ENTITLEMENT_POOLS:
446 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300447 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
448 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200449 screenToBreadcrumb = {
450 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
451 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
452 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300453 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
454 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
455 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200456 };
457 return [
458 {
459 selectedKey: props.licenseModelId,
460 menuItems: licenseModelList.map(({id, vendorName}) => ({
461 key: id,
462 displayText: vendorName
463 }))
464 },
465 {
466 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
467 menuItems: [{
468 key: enums.BREADCRUMS.LICENSE_MODEL,
469 displayText: i18n('License Model')
470 },
471 ...(softwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
472 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
473 displayText: i18n('Software Products')
474 }])]
475 }, {
476 selectedKey: screenToBreadcrumb[screen],
477 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300478 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
479 displayText: i18n('Overview')
480 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200481 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
482 displayText: i18n('License Agreements')
483 }, {
484 key: enums.BREADCRUMS.FEATURE_GROUPS,
485 displayText: i18n('Feature Groups')
486 }, {
487 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
488 displayText: i18n('Entitlement Pools')
489 }, {
490 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
491 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300492 }, {
493 key: enums.BREADCRUMS.ACTIVITY_LOG,
494 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200495 }]
496 }
497 ];
498
499 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
500 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
501 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
502 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300503 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200504 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300505 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
506 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200507 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
508
509 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
510 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
511 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
512 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
513 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
514 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300515 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200516 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
517 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300518 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200519 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
520 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
521 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300522 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200523 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300524 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
525 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
526 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200527 };
528 let componentScreenToBreadcrumb = {
529 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
530 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
531 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
532 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
533 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
534 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300535 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200536 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
537 };
538 let licenseModelId = softwareProductList.find(({id}) => id === props.softwareProductId).vendorId;
539 let returnedBreadcrumb = [
540 {
541 selectedKey: licenseModelId,
542 menuItems: licenseModelList.map(({id, vendorName}) => ({
543 key: id,
544 displayText: vendorName
545 }))
546 },
547 {
548 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
549 menuItems: [{
550 key: enums.BREADCRUMS.LICENSE_MODEL,
551 displayText: i18n('License Model')
552 }, {
553 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
554 displayText: i18n('Software Products')
555 }]
556 },
557 {
558 selectedKey: props.softwareProductId,
559 menuItems: softwareProductList
560 .filter(({vendorId}) => vendorId === licenseModelId)
561 .map(({id, name}) => ({
562 key: id,
563 displayText: name
564 }))
565 },
AviZi280f8012017-06-09 02:39:56 +0300566 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200567 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
568 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300569 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
570 displayText: i18n('Overview')
571 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200572 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
573 displayText: i18n('General')
574 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300575 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
576 displayText: i18n('Deployment Flavors')
577 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200578 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
579 displayText: i18n('Process Details')
580 }, {
581 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
582 displayText: i18n('Networks')
583 }, {
AviZi280f8012017-06-09 02:39:56 +0300584 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
585 displayText: i18n('Components Dependencies')
586 }, {
587 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
588 displayText: i18n('Attachments')
589 }, {
590 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
591 displayText: i18n('Activity Log')
592 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200593 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
594 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300595 }].filter(item => {
596 let isHeatData = doesHeatDataExist(heatSetup);
Avi Zivb8e2faf2017-07-18 19:45:38 +0300597 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
AviZi280f8012017-06-09 02:39:56 +0300598 switch (item.key) {
599 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
600 return isHeatData;
601 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300602 return (componentsList.length > 0);
603 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
604 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300605 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300606 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300607 default:
608 return true;
609 }
610 })
Michael Landoefa037d2017-02-19 12:57:33 +0200611 }])
612 ];
613 if(props.componentId) {
614 returnedBreadcrumb = [
615 ...returnedBreadcrumb, {
616 selectedKey: props.componentId,
617 menuItems: componentsList
618 .map(({id, displayName}) => ({
619 key: id,
620 displayText: displayName
621 }))
622 },
623 ...[{
624 selectedKey: componentScreenToBreadcrumb[screen],
625 menuItems: [{
626 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
627 displayText: i18n('General')
628 }, {
629 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
630 displayText: i18n('Compute')
631 }, {
632 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
633 displayText: i18n('High Availability & Load Balancing')
634 }, {
635 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
636 displayText: i18n('Networks')
637 }, {
638 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
639 displayText: i18n('Storage')
640 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300641 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
642 displayText: i18n('Images')
643 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200644 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
645 displayText: i18n('Process Details')
646 }, {
647 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
648 displayText: i18n('Monitoring')
Avi Ziv61070c92017-07-26 17:37:57 +0300649 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200650 }]
651 ];
652 }
653 return returnedBreadcrumb;
654 }
655 }
656}