blob: c1f3251281cc3e8c9de5cf89cc8e84699175a8eb [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 +030031
Michael Landoefa037d2017-02-19 12:57:33 +020032import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
33import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js';
34import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
35import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
36import SoftwareProduct from './softwareProduct/SoftwareProduct.js';
37import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js';
38import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js';
39import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js';
40import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030041import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js';
Michael Landoefa037d2017-02-19 12:57:33 +020042import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js';
AviZi280f8012017-06-09 02:39:56 +030043import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030044
45import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js';
Michael Landoefa037d2017-02-19 12:57:33 +020046import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
47import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js';
48import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
49import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
50import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js';
51import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030052import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js';
Michael Landoefa037d2017-02-19 12:57:33 +020053import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030054import {
55 navigationItems as SoftwareProductNavigationItems,
56 onboardingMethod as onboardingMethodTypes,
shrek2000c8a540b2017-09-11 15:45:37 +030057 actionTypes as SoftwareProductActionTypes,
58 onboardingOriginTypes
Avi Zivb8e2faf2017-07-18 19:45:38 +030059} 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:
shrek2000c8a540b2017-09-11 15:45:37 +0300317 if(softwareProduct.onboardingOrigin === onboardingOriginTypes.ZIP) {
318 OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
319 }
320 else if(softwareProduct.onboardingOrigin === onboardingOriginTypes.CSAR) {
321 OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
322 }
AviZi280f8012017-06-09 02:39:56 +0300323 break;
324 case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES:
325 OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
326 break;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300327 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
328 OnboardingActionHelper.navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
329 break;
AviZi280f8012017-06-09 02:39:56 +0300330 case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS:
331 OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
332 break;
333 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
334 OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
335 break;
336 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG:
337 OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
338 break;
339 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
340 OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
341 dispatch({
342 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
343 mapOfExpandedIds: {
344 [SoftwareProductNavigationItems.COMPONENTS]: true
345 }
346 });
347 break;
348 default:
349 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion});
350 break;
351 }
352 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
353 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
354 let softwareProduct = softwareProductId ?
355 softwareProductList.find(({id}) => id === softwareProductId) :
356 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
357 if (!softwareProductId) {
358 softwareProductId = softwareProduct.id;
359 }
360 if (currentSoftwareProductId !== softwareProductId) {
361 currentSoftwareProductVersion = softwareProduct.version;
362 }
363 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
364 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
365 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
366 let softwareProduct = softwareProductId ?
367 softwareProductList.find(({id}) => id === softwareProductId) :
368 softwareProductList.find(({vendorId}) => vendorId === licenseModelId);
369 if (!softwareProductId) {
370 softwareProductId = softwareProduct.id;
371 }
372 if (currentSoftwareProductId !== softwareProductId) {
373 currentSoftwareProductVersion = softwareProduct.version;
374 }
375 switch (componentScreen) {
376 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
377 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
378 break;
379 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300380 OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300381 break;
382 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300383 OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300384 break;
385 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300386 OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300387 break;
388 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300389 OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300390 break;
391 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300392 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
AviZi280f8012017-06-09 02:39:56 +0300393 break;
394 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300395 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion});
396 break;
397 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
398 OnboardingActionHelper.navigateToComponentImages(dispatch, {
399 softwareProductId,
400 componentId,
401 version: currentSoftwareProductVersion
402 });
AviZi280f8012017-06-09 02:39:56 +0300403 break;
404 }
405 } else {
406 console.error('Unknown breadcrumbs path: ', selectedKeys);
407 }
408 }).catch(() => {
409 store.dispatch({
410 type: actionTypes.SET_CURRENT_SCREEN,
411 currentScreen: {
412 ...currentScreen,
413 forceBreadCrumbsUpdate: true
414 }
415 });
416 });
Michael Landoefa037d2017-02-19 12:57:33 +0200417 }
418 }
419
420 handleStoreChange() {
AviZi280f8012017-06-09 02:39:56 +0300421 let {currentScreen, licenseModelList, softwareProductList,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300422 softwareProduct: {softwareProductEditor: {data = {onboardingMethod: ''}},
shrek2000c8a540b2017-09-11 15:45:37 +0300423 softwareProductComponents: {componentsList}}} = store.getState();
424 let {onboardingMethod, onboardingOrigin} = data;
425 let breadcrumbsData = {onboardingMethod, currentScreen, licenseModelList, softwareProductList, componentsList, onboardingOrigin};
AviZi280f8012017-06-09 02:39:56 +0300426 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200427 this.prevBreadcrumbsData = breadcrumbsData;
428 this.breadcrumbsPrefixSelected = false;
429 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200430 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
431 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300432 store.dispatch({
433 type: actionTypes.SET_CURRENT_SCREEN,
434 currentScreen: {
435 ...currentScreen,
436 forceBreadCrumbsUpdate: false
437 }
438 });
Michael Landoefa037d2017-02-19 12:57:33 +0200439 }
440 }
441
shrek2000c8a540b2017-09-11 15:45:37 +0300442 buildBreadcrumbs({currentScreen: {screen, props}, onboardingMethod, licenseModelList, softwareProductList, componentsList, onboardingOrigin}) {
Michael Landoefa037d2017-02-19 12:57:33 +0200443 let screenToBreadcrumb;
444 switch (screen) {
445 case enums.SCREEN.ONBOARDING_CATALOG:
446 return [];
447
448 case enums.SCREEN.LICENSE_AGREEMENTS:
449 case enums.SCREEN.FEATURE_GROUPS:
450 case enums.SCREEN.ENTITLEMENT_POOLS:
451 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300452 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
453 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200454 screenToBreadcrumb = {
455 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
456 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
457 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300458 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
459 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
460 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200461 };
462 return [
463 {
464 selectedKey: props.licenseModelId,
465 menuItems: licenseModelList.map(({id, vendorName}) => ({
466 key: id,
467 displayText: vendorName
468 }))
469 },
470 {
471 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
472 menuItems: [{
473 key: enums.BREADCRUMS.LICENSE_MODEL,
474 displayText: i18n('License Model')
475 },
476 ...(softwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
477 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
478 displayText: i18n('Software Products')
479 }])]
480 }, {
481 selectedKey: screenToBreadcrumb[screen],
482 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300483 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
484 displayText: i18n('Overview')
485 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200486 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
487 displayText: i18n('License Agreements')
488 }, {
489 key: enums.BREADCRUMS.FEATURE_GROUPS,
490 displayText: i18n('Feature Groups')
491 }, {
492 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
493 displayText: i18n('Entitlement Pools')
494 }, {
495 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
496 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300497 }, {
498 key: enums.BREADCRUMS.ACTIVITY_LOG,
499 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200500 }]
501 }
502 ];
503
504 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
505 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
506 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
507 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300508 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200509 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
AviZi280f8012017-06-09 02:39:56 +0300510 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
511 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200512 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
513
514 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
515 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
516 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
517 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
518 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
519 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300520 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200521 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
522 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300523 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200524 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
525 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
526 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300527 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200528 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300529 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
530 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
531 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200532 };
533 let componentScreenToBreadcrumb = {
534 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
535 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
536 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
537 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
538 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
539 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300540 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200541 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
542 };
543 let licenseModelId = softwareProductList.find(({id}) => id === props.softwareProductId).vendorId;
544 let returnedBreadcrumb = [
545 {
546 selectedKey: licenseModelId,
547 menuItems: licenseModelList.map(({id, vendorName}) => ({
548 key: id,
549 displayText: vendorName
550 }))
551 },
552 {
553 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
554 menuItems: [{
555 key: enums.BREADCRUMS.LICENSE_MODEL,
556 displayText: i18n('License Model')
557 }, {
558 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
559 displayText: i18n('Software Products')
560 }]
561 },
562 {
563 selectedKey: props.softwareProductId,
564 menuItems: softwareProductList
565 .filter(({vendorId}) => vendorId === licenseModelId)
566 .map(({id, name}) => ({
567 key: id,
568 displayText: name
569 }))
570 },
AviZi280f8012017-06-09 02:39:56 +0300571 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200572 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
573 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300574 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
575 displayText: i18n('Overview')
576 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200577 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
578 displayText: i18n('General')
579 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300580 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
581 displayText: i18n('Deployment Flavors')
582 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200583 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
584 displayText: i18n('Process Details')
585 }, {
586 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
587 displayText: i18n('Networks')
588 }, {
AviZi280f8012017-06-09 02:39:56 +0300589 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
590 displayText: i18n('Components Dependencies')
591 }, {
592 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
593 displayText: i18n('Attachments')
594 }, {
595 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
596 displayText: i18n('Activity Log')
597 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200598 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
599 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300600 }].filter(item => {
shrek2000c8a540b2017-09-11 15:45:37 +0300601 let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300602 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
AviZi280f8012017-06-09 02:39:56 +0300603 switch (item.key) {
604 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
605 return isHeatData;
606 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300607 return (componentsList.length > 0);
608 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
609 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300610 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300611 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300612 default:
613 return true;
614 }
615 })
Michael Landoefa037d2017-02-19 12:57:33 +0200616 }])
617 ];
618 if(props.componentId) {
619 returnedBreadcrumb = [
620 ...returnedBreadcrumb, {
621 selectedKey: props.componentId,
622 menuItems: componentsList
623 .map(({id, displayName}) => ({
624 key: id,
625 displayText: displayName
626 }))
627 },
628 ...[{
629 selectedKey: componentScreenToBreadcrumb[screen],
630 menuItems: [{
631 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
632 displayText: i18n('General')
633 }, {
634 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
635 displayText: i18n('Compute')
636 }, {
637 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
638 displayText: i18n('High Availability & Load Balancing')
639 }, {
640 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
641 displayText: i18n('Networks')
642 }, {
643 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
644 displayText: i18n('Storage')
645 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300646 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
647 displayText: i18n('Images')
648 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200649 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
650 displayText: i18n('Process Details')
651 }, {
652 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
653 displayText: i18n('Monitoring')
Avi Ziv61070c92017-07-26 17:37:57 +0300654 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200655 }]
656 ];
657 }
658 return returnedBreadcrumb;
659 }
660 }
661}