blob: 06c95b0b2f892c8294378cb24ce4f92e00cb03d6 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import React from 'react';
talig8e9c0652017-12-20 14:30:43 +020017import PropTypes from 'prop-types';
Michael Landoefa037d2017-02-19 12:57:33 +020018import ReactDOM from 'react-dom';
19import {connect} from 'react-redux';
20import isEqual from 'lodash/isEqual.js';
21import objectValues from 'lodash/values.js';
miriamed411d152018-01-02 15:35:55 +020022import lodashUnionBy from 'lodash/unionBy.js';
Michael Landoefa037d2017-02-19 12:57:33 +020023
24import i18n from 'nfvo-utils/i18n/i18n.js';
25import Application from 'sdc-app/Application.jsx';
26import store from 'sdc-app/AppStore.js';
27import Configuration from 'sdc-app/config/Configuration.js';
talig8e9c0652017-12-20 14:30:43 +020028import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020029
AviZi280f8012017-06-09 02:39:56 +030030import Onboard from './onboard/Onboard.js';
talig8e9c0652017-12-20 14:30:43 +020031import VersionsPage from './versionsPage/VersionsPage.js';
Michael Landoefa037d2017-02-19 12:57:33 +020032import LicenseModel from './licenseModel/LicenseModel.js';
AviZi280f8012017-06-09 02:39:56 +030033import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030034import ActivityLog from 'sdc-app/common/activity-log/ActivityLog.js';
AviZi280f8012017-06-09 02:39:56 +030035
Michael Landoefa037d2017-02-19 12:57:33 +020036import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
37import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js';
38import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
39import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
40import SoftwareProduct from './softwareProduct/SoftwareProduct.js';
41import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js';
42import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js';
43import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js';
44import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030045import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js';
Michael Landoefa037d2017-02-19 12:57:33 +020046import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js';
AviZi280f8012017-06-09 02:39:56 +030047import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030048
49import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponents.js';
Michael Landoefa037d2017-02-19 12:57:33 +020050import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
51import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js';
52import SoftwareProductComponentsNetworkList from './softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
53import SoftwareProductComponentsGeneral from './softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
54import SoftwareProductComponentsCompute from './softwareProduct/components/compute/SoftwareProductComponentCompute.js';
55import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030056import SoftwareProductComponentsImageList from './softwareProduct/components/images/SoftwareProductComponentsImageList.js';
Michael Landoefa037d2017-02-19 12:57:33 +020057import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
talig8e9c0652017-12-20 14:30:43 +020058import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030059
talig8e9c0652017-12-20 14:30:43 +020060import {itemTypes} from './versionsPage/VersionsPageConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020061
AviZi280f8012017-06-09 02:39:56 +030062import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js';
63
talig8e9c0652017-12-20 14:30:43 +020064import {actionTypes, enums, screenTypes} from './OnboardingConstants.js';
Michael Landoefa037d2017-02-19 12:57:33 +020065import OnboardingActionHelper from './OnboardingActionHelper.js';
66
Michael Landoefa037d2017-02-19 12:57:33 +020067class OnboardingView extends React.Component {
68 static propTypes = {
talig8e9c0652017-12-20 14:30:43 +020069 currentScreen: PropTypes.shape({
70 screen: PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired,
71 props: PropTypes.object.isRequired,
72 itemPermission: PropTypes.object
Michael Landoefa037d2017-02-19 12:57:33 +020073 }).isRequired
74 };
75
76 componentDidMount() {
77 let element = ReactDOM.findDOMNode(this);
78 element.addEventListener('click', event => {
79 if (event.target.tagName === 'A') {
80 event.preventDefault();
81 }
82 });
83 ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType =>
84 element.addEventListener(eventType, event => event.stopPropagation())
85 );
86 }
87
88 render() {
89 let {currentScreen} = this.props;
90 let {screen, props} = currentScreen;
91
92 return (
93 <div className='dox-ui dox-ui-punch-out dox-ui-punch-out-full-page'>
94 {(() => {
95 switch (screen) {
96 case enums.SCREEN.ONBOARDING_CATALOG:
AviZi280f8012017-06-09 02:39:56 +030097 return <Onboard {...props}/>;
talig8e9c0652017-12-20 14:30:43 +020098 case enums.SCREEN.VERSIONS_PAGE:
99 return <VersionsPage {...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}>
talig8e9c0652017-12-20 14:30:43 +0200109 {
110 (()=>{
111 switch(screen) {
112 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
113 return <LicenseModelOverview {...props}/>;
114 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}/>;
122 case enums.SCREEN.ACTIVITY_LOG:
123 return <ActivityLog {...props}/>;
124 }
125 })()
126 }
Michael Landoefa037d2017-02-19 12:57:33 +0200127 </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}>
talig8e9c0652017-12-20 14:30:43 +0200149 {
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:
157 return <SoftwareProductAttachments className='no-padding-content-area' {...props} />;
158 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
159 return <SoftwareProductProcesses {...props}/>;
160 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
161 return <SoftwareProductDeployment {...props}/>;
162 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
163 return <SoftwareProductNetworks {...props}/>;
164 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
165 return <SoftwareProductDependencies {...props} />;
166 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}/>;
180 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
181 return <SoftwareProductComponentsImageList{...props}/>;
182 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
183 return <SoftwareProductComponentsMonitoring {...props}/>;
184 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
185 return <ActivityLog {...props}/>;
186 }
187 })()
188 }
Michael Landoefa037d2017-02-19 12:57:33 +0200189 </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);
miriamed411d152018-01-02 15:35:55 +0200237 let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList,
238 softwareProduct: {softwareProductEditor: {data: vspData = {}},
talig8e9c0652017-12-20 14:30:43 +0200239 softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState();
miriamed411d152018-01-02 15:35:55 +0200240 const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList];
241 const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList];
talig8e9c0652017-12-20 14:30:43 +0200242
243 let {props: {version, isReadOnlyMode}, screen} = currentScreen;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300244 let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents;
Michael Landoefa037d2017-02-19 12:57:33 +0200245 if (this.programmaticBreadcrumbsUpdate) {
246 this.prevSelectedKeys = selectedKeys;
247 this.programmaticBreadcrumbsUpdate = false;
248 return;
249 }
Michael Landoefa037d2017-02-19 12:57:33 +0200250 if (!isEqual(selectedKeys, this.prevSelectedKeys)) {
251 this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length));
Michael Landoefa037d2017-02-19 12:57:33 +0200252
AviZi280f8012017-06-09 02:39:56 +0300253 const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || [];
254 let preNavigate = Promise.resolve();
talig8e9c0652017-12-20 14:30:43 +0200255 if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) {
AviZi280f8012017-06-09 02:39:56 +0300256 let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300257 preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300258 softwareProductId: prevVspId,
talig8e9c0652017-12-20 14:30:43 +0200259 version,
AviZi280f8012017-06-09 02:39:56 +0300260 vspComponentId: prevComponentId,
261 dataToSave
262 });
Michael Landoefa037d2017-02-19 12:57:33 +0200263 }
AviZi280f8012017-06-09 02:39:56 +0300264
265 let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState();
266 let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ?
talig8e9c0652017-12-20 14:30:43 +0200267 HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) :
268 Promise.resolve();
AviZi280f8012017-06-09 02:39:56 +0300269 Promise.all([preNavigate, heatSetupPopupPromise]).then(() => {
270 this.prevSelectedKeys = selectedKeys;
271 if (selectedKeys.length === 0) {
talig8e9c0652017-12-20 14:30:43 +0200272 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG});
273
AviZi280f8012017-06-09 02:39:56 +0300274 } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) {
275 let [licenseModelId, , licenseModelScreen] = selectedKeys;
miriamed411d152018-01-02 15:35:55 +0200276 let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId);
talig8e9c0652017-12-20 14:30:43 +0200277 ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL,
278 props: {licenseModelId, version, licenseModel, usersList}});
279
AviZi280f8012017-06-09 02:39:56 +0300280 } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) {
281 let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys;
282 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200283 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
284 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300285 if (!softwareProductId) {
286 softwareProductId = softwareProduct.id;
287 }
talig8e9c0652017-12-20 14:30:43 +0200288 if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) {
289 softwareProduct = vspData;
290 //check current vsp fields to determine which file has uploaded
291 if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) {
292 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP;
293 }
294 else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) {
295 softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION;
296 }
AviZi280f8012017-06-09 02:39:56 +0300297 }
talig8e9c0652017-12-20 14:30:43 +0200298
299 ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
300 props: {softwareProductId, softwareProduct, version, usersList}});
301
AviZi280f8012017-06-09 02:39:56 +0300302 } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
303 let [licenseModelId, , softwareProductId, , componentId] = selectedKeys;
304 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200305 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
306 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300307 if (!softwareProductId) {
308 softwareProductId = softwareProduct.id;
309 }
talig8e9c0652017-12-20 14:30:43 +0200310 ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT,
311 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
312
AviZi280f8012017-06-09 02:39:56 +0300313 } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) {
314 let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys;
315 let softwareProduct = softwareProductId ?
miriamed411d152018-01-02 15:35:55 +0200316 wholeSoftwareProductList.find(({id}) => id === softwareProductId) :
317 wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId);
AviZi280f8012017-06-09 02:39:56 +0300318 if (!softwareProductId) {
319 softwareProductId = softwareProduct.id;
320 }
talig8e9c0652017-12-20 14:30:43 +0200321 ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT,
322 props: {softwareProductId, softwareProduct, componentId, version, usersList}});
323
AviZi280f8012017-06-09 02:39:56 +0300324 } else {
325 console.error('Unknown breadcrumbs path: ', selectedKeys);
326 }
327 }).catch(() => {
328 store.dispatch({
329 type: actionTypes.SET_CURRENT_SCREEN,
330 currentScreen: {
331 ...currentScreen,
332 forceBreadCrumbsUpdate: true
333 }
334 });
335 });
Michael Landoefa037d2017-02-19 12:57:33 +0200336 }
337 }
338
339 handleStoreChange() {
talig8e9c0652017-12-20 14:30:43 +0200340 let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage:
341 {versionsList: {itemType, itemId}},
342 softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}},
shrek2000c8a540b2017-09-11 15:45:37 +0300343 softwareProductComponents: {componentsList}}} = store.getState();
miriamed411d152018-01-02 15:35:55 +0200344 const wholeSoftwareProductList = lodashUnionBy(softwareProductList, finalizedSoftwareProductList, 'id');
345 const wholeLicenseModelList = lodashUnionBy(licenseModelList, finalizedLicenseModelList, 'id');
talig8e9c0652017-12-20 14:30:43 +0200346 let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList};
347
AviZi280f8012017-06-09 02:39:56 +0300348 if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) {
Michael Landoefa037d2017-02-19 12:57:33 +0200349 this.prevBreadcrumbsData = breadcrumbsData;
350 this.breadcrumbsPrefixSelected = false;
351 this.programmaticBreadcrumbsUpdate = true;
Michael Landoefa037d2017-02-19 12:57:33 +0200352 let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData);
353 this.onEvent('breadcrumbsupdated', breadcrumbs);
AviZi280f8012017-06-09 02:39:56 +0300354 store.dispatch({
355 type: actionTypes.SET_CURRENT_SCREEN,
356 currentScreen: {
357 ...currentScreen,
358 forceBreadCrumbsUpdate: false
359 }
360 });
Michael Landoefa037d2017-02-19 12:57:33 +0200361 }
362 }
363
talig8e9c0652017-12-20 14:30:43 +0200364 buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct,
365 wholeLicenseModelList, wholeSoftwareProductList, componentsList}) {
366 let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct;
Michael Landoefa037d2017-02-19 12:57:33 +0200367 let screenToBreadcrumb;
368 switch (screen) {
369 case enums.SCREEN.ONBOARDING_CATALOG:
370 return [];
371
talig8e9c0652017-12-20 14:30:43 +0200372 case enums.SCREEN.VERSIONS_PAGE:
373 let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [
374 {
375 selectedKey: itemId,
376 menuItems: wholeLicenseModelList.map(({id, name}) => ({
377 key: id,
378 displayText: name
379 }))
380 }] : [
381 {
382 selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId,
383 menuItems: wholeLicenseModelList.map(({id, name}) => ({
384 key: id,
385 displayText: name
386 }))
387 },
388 {
389 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
390 menuItems: [{
391 key: enums.BREADCRUMS.LICENSE_MODEL,
392 displayText: i18n('License Model')
393 }, {
394 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
395 displayText: i18n('Software Products')
396 }]
397 },
398 {
399 selectedKey: itemId,
400 menuItems: wholeSoftwareProductList
401 .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId)
402 .map(({id, name}) => ({
403 key: id,
404 displayText: name
405 }))
406 },
407 ];
408 return [
409 ...firstMenuItems,
410 {
411 selectedKey: enums.BREADCRUMS.VERSIONS_PAGE,
412 menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}]
413 }
414 ];
415
Michael Landoefa037d2017-02-19 12:57:33 +0200416 case enums.SCREEN.LICENSE_AGREEMENTS:
417 case enums.SCREEN.FEATURE_GROUPS:
418 case enums.SCREEN.ENTITLEMENT_POOLS:
419 case enums.SCREEN.LICENSE_KEY_GROUPS:
AviZi280f8012017-06-09 02:39:56 +0300420 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
421 case enums.SCREEN.ACTIVITY_LOG:
Michael Landoefa037d2017-02-19 12:57:33 +0200422 screenToBreadcrumb = {
423 [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS,
424 [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS,
425 [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS,
AviZi280f8012017-06-09 02:39:56 +0300426 [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
427 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
428 [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200429 };
430 return [
431 {
432 selectedKey: props.licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200433 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200434 key: id,
talig8e9c0652017-12-20 14:30:43 +0200435 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200436 }))
437 },
438 {
439 selectedKey: enums.BREADCRUMS.LICENSE_MODEL,
440 menuItems: [{
441 key: enums.BREADCRUMS.LICENSE_MODEL,
442 displayText: i18n('License Model')
443 },
talig8e9c0652017-12-20 14:30:43 +0200444 ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{
445 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
446 displayText: i18n('Software Products')
447 }])]
Michael Landoefa037d2017-02-19 12:57:33 +0200448 }, {
449 selectedKey: screenToBreadcrumb[screen],
450 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300451 key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW,
452 displayText: i18n('Overview')
453 },{
Michael Landoefa037d2017-02-19 12:57:33 +0200454 key: enums.BREADCRUMS.LICENSE_AGREEMENTS,
455 displayText: i18n('License Agreements')
456 }, {
457 key: enums.BREADCRUMS.FEATURE_GROUPS,
458 displayText: i18n('Feature Groups')
459 }, {
460 key: enums.BREADCRUMS.ENTITLEMENT_POOLS,
461 displayText: i18n('Entitlement Pools')
462 }, {
463 key: enums.BREADCRUMS.LICENSE_KEY_GROUPS,
464 displayText: i18n('License Key Groups')
AviZi280f8012017-06-09 02:39:56 +0300465 }, {
466 key: enums.BREADCRUMS.ACTIVITY_LOG,
467 displayText: i18n('Activity Log')
Michael Landoefa037d2017-02-19 12:57:33 +0200468 }]
469 }
470 ];
471
472 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
473 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
474 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
475 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300476 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
Michael Landoefa037d2017-02-19 12:57:33 +0200477 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:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300488 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
Michael Landoefa037d2017-02-19 12:57:33 +0200489 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
490 screenToBreadcrumb = {
AviZi280f8012017-06-09 02:39:56 +0300491 [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
Michael Landoefa037d2017-02-19 12:57:33 +0200492 [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
493 [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
494 [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300495 [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
Michael Landoefa037d2017-02-19 12:57:33 +0200496 [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
AviZi280f8012017-06-09 02:39:56 +0300497 [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
498 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
499 [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG
Michael Landoefa037d2017-02-19 12:57:33 +0200500 };
501 let componentScreenToBreadcrumb = {
502 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
503 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
504 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
505 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
506 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
507 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
Avi Zivb8e2faf2017-07-18 19:45:38 +0300508 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
Michael Landoefa037d2017-02-19 12:57:33 +0200509 [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING
510 };
talig8e9c0652017-12-20 14:30:43 +0200511 let licenseModelId = currentSoftwareProduct.vendorId;
Michael Landoefa037d2017-02-19 12:57:33 +0200512 let returnedBreadcrumb = [
513 {
514 selectedKey: licenseModelId,
talig8e9c0652017-12-20 14:30:43 +0200515 menuItems: wholeLicenseModelList.map(({id, name}) => ({
Michael Landoefa037d2017-02-19 12:57:33 +0200516 key: id,
talig8e9c0652017-12-20 14:30:43 +0200517 displayText: name
Michael Landoefa037d2017-02-19 12:57:33 +0200518 }))
519 },
520 {
521 selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT,
522 menuItems: [{
523 key: enums.BREADCRUMS.LICENSE_MODEL,
524 displayText: i18n('License Model')
525 }, {
526 key: enums.BREADCRUMS.SOFTWARE_PRODUCT,
527 displayText: i18n('Software Products')
528 }]
529 },
530 {
531 selectedKey: props.softwareProductId,
talig8e9c0652017-12-20 14:30:43 +0200532 menuItems: wholeSoftwareProductList
533 .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId)
Michael Landoefa037d2017-02-19 12:57:33 +0200534 .map(({id, name}) => ({
535 key: id,
536 displayText: name
537 }))
538 },
AviZi280f8012017-06-09 02:39:56 +0300539 ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{
Michael Landoefa037d2017-02-19 12:57:33 +0200540 selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
541 menuItems: [{
AviZi280f8012017-06-09 02:39:56 +0300542 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE,
543 displayText: i18n('Overview')
544 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200545 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS,
546 displayText: i18n('General')
547 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300548 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT,
549 displayText: i18n('Deployment Flavors')
550 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200551 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES,
552 displayText: i18n('Process Details')
553 }, {
554 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS,
555 displayText: i18n('Networks')
556 }, {
AviZi280f8012017-06-09 02:39:56 +0300557 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES,
558 displayText: i18n('Components Dependencies')
559 }, {
560 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS,
561 displayText: i18n('Attachments')
562 }, {
563 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG,
564 displayText: i18n('Activity Log')
565 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200566 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS,
567 displayText: i18n('Components')
AviZi280f8012017-06-09 02:39:56 +0300568 }].filter(item => {
AviZi280f8012017-06-09 02:39:56 +0300569 switch (item.key) {
570 case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS:
talig8e9c0652017-12-20 14:30:43 +0200571 let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP;
AviZi280f8012017-06-09 02:39:56 +0300572 return isHeatData;
573 case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300574 return (componentsList.length > 0);
575 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT:
talig8e9c0652017-12-20 14:30:43 +0200576 let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL;
Avi Zivb8e2faf2017-07-18 19:45:38 +0300577 return isManualMode;
AviZi280f8012017-06-09 02:39:56 +0300578 case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES:
Avi Zivb8e2faf2017-07-18 19:45:38 +0300579 return (componentsList.length > 1);
AviZi280f8012017-06-09 02:39:56 +0300580 default:
581 return true;
582 }
583 })
Michael Landoefa037d2017-02-19 12:57:33 +0200584 }])
585 ];
586 if(props.componentId) {
587 returnedBreadcrumb = [
588 ...returnedBreadcrumb, {
589 selectedKey: props.componentId,
590 menuItems: componentsList
591 .map(({id, displayName}) => ({
592 key: id,
593 displayText: displayName
594 }))
595 },
596 ...[{
597 selectedKey: componentScreenToBreadcrumb[screen],
598 menuItems: [{
599 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
600 displayText: i18n('General')
601 }, {
602 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
603 displayText: i18n('Compute')
604 }, {
605 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
606 displayText: i18n('High Availability & Load Balancing')
607 }, {
608 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
609 displayText: i18n('Networks')
610 }, {
611 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
612 displayText: i18n('Storage')
613 }, {
Avi Zivb8e2faf2017-07-18 19:45:38 +0300614 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES,
615 displayText: i18n('Images')
616 }, {
Michael Landoefa037d2017-02-19 12:57:33 +0200617 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
618 displayText: i18n('Process Details')
619 }, {
620 key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
621 displayText: i18n('Monitoring')
Avi Ziv61070c92017-07-26 17:37:57 +0300622 }]
Michael Landoefa037d2017-02-19 12:57:33 +0200623 }]
624 ];
625 }
626 return returnedBreadcrumb;
627 }
628 }
629}