blob: afa5a42f83e3e113dfab09d591689245d929e6bd [file] [log] [blame]
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +02001import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
2import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
talig8e9c0652017-12-20 14:30:43 +02003import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +02004import { actionTypes as SoftwareProductActionTypes } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
talig8e9c0652017-12-20 14:30:43 +02005import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js';
6import versionPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js';
7import i18n from 'nfvo-utils/i18n/i18n.js';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +02008import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
talig8e9c0652017-12-20 14:30:43 +02009
10const ScreensHelper = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020011 async loadScreen(dispatch, { screen, screenType, props }) {
12 if (screen === enums.SCREEN.ONBOARDING_CATALOG) {
13 OnboardingActionHelper.navigateToOnboardingCatalog(dispatch);
14 return;
15 }
talig8e9c0652017-12-20 14:30:43 +020016
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020017 screenType = !screenType ? this.getScreenType(screen) : screenType;
talig8e9c0652017-12-20 14:30:43 +020018
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020019 if (screenType === screenTypes.LICENSE_MODEL) {
20 const { licenseModelId, version, licenseModel, usersList } = props;
21 const item = await ItemsHelper.fetchItem(licenseModelId);
22 let itemStatusPromise =
23 version && screen
24 ? ItemsHelper.checkItemStatus(dispatch, {
25 itemId: licenseModelId,
26 versionId: version.id
27 })
28 : Promise.resolve();
29 itemStatusPromise.then(updatedVersion => {
30 if (
31 updatedVersion &&
32 updatedVersion.status !== version.status
33 ) {
34 dispatch({
35 type: modalActionTypes.GLOBAL_MODAL_WARNING,
36 data: {
37 title: i18n('Commit error'),
38 msg: i18n('Item version was certified by Owner'),
39 cancelButtonText: i18n('Cancel')
40 }
41 });
42 versionPageActionHelper.fetchVersions(dispatch, {
43 itemType: itemTypes.LICENSE_MODEL,
44 itemId: licenseModelId
45 });
46 }
47 let newVersion = updatedVersion ? updatedVersion : version;
48 const screenProps = {
49 licenseModelId,
50 version: newVersion,
51 status: item.status
52 };
53 switch (screen) {
54 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
55 OnboardingActionHelper.navigateToLicenseModelOverview(
56 dispatch,
57 screenProps
58 );
59 break;
60 case enums.SCREEN.LICENSE_AGREEMENTS:
61 OnboardingActionHelper.navigateToLicenseAgreements(
62 dispatch,
63 screenProps
64 );
65 break;
66 case enums.SCREEN.FEATURE_GROUPS:
67 OnboardingActionHelper.navigateToFeatureGroups(
68 dispatch,
69 screenProps
70 );
71 break;
72 case enums.SCREEN.ENTITLEMENT_POOLS:
73 OnboardingActionHelper.navigateToEntitlementPools(
74 dispatch,
75 screenProps
76 );
77 break;
78 case enums.SCREEN.LICENSE_KEY_GROUPS:
79 OnboardingActionHelper.navigateToLicenseKeyGroups(
80 dispatch,
81 screenProps
82 );
83 break;
84 case enums.SCREEN.ACTIVITY_LOG:
85 OnboardingActionHelper.navigateToLicenseModelActivityLog(
86 dispatch,
87 screenProps
88 );
89 break;
90 case enums.SCREEN.VERSIONS_PAGE:
91 default:
92 OnboardingActionHelper.navigateToVersionsPage(
93 dispatch,
94 {
95 itemId: licenseModelId,
96 itemType: itemTypes.LICENSE_MODEL,
97 itemName: licenseModel.name,
98 users: usersList
99 }
100 );
101 break;
102 }
103 });
104 } else if (screenType === screenTypes.SOFTWARE_PRODUCT) {
105 const {
106 softwareProductId,
107 componentId,
108 version,
109 softwareProduct,
110 usersList
111 } = props;
112 const item = await ItemsHelper.fetchItem(softwareProductId);
113 let itemStatusPromise =
114 version && screen
115 ? ItemsHelper.checkItemStatus(dispatch, {
116 itemId: softwareProductId,
117 versionId: version.id
118 })
119 : Promise.resolve();
120 itemStatusPromise.then(updatedVersion => {
121 if (
122 updatedVersion &&
123 updatedVersion.status !== version.status
124 ) {
125 dispatch({
126 type: modalActionTypes.GLOBAL_MODAL_WARNING,
127 data: {
128 title: i18n('Commit error'),
129 msg: i18n('Item version already Certified'),
130 cancelButtonText: i18n('Cancel')
131 }
132 });
133 versionPageActionHelper.fetchVersions(dispatch, {
134 itemType: itemTypes.SOFTWARE_PRODUCT,
135 itemId: softwareProductId
136 });
137 }
talig8e9c0652017-12-20 14:30:43 +0200138
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200139 let newVersion = updatedVersion ? updatedVersion : version;
talig8e9c0652017-12-20 14:30:43 +0200140
svishnev84f69f32018-03-21 14:27:59 +0200141 const vspProps = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200142 softwareProductId,
143 componentId,
144 version: newVersion,
145 status: item.status
146 };
147 if (
148 screen ===
149 screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL
150 ) {
151 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(
152 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200153 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200154 );
155 }
talig8e9c0652017-12-20 14:30:43 +0200156
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200157 switch (screen) {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200158 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
159 OnboardingActionHelper.navigateToSoftwareProductLandingPage(
160 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200161 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200162 );
163 break;
164 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
165 OnboardingActionHelper.navigateToSoftwareProductDetails(
166 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200167 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200168 );
169 break;
170 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP:
171 OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab(
172 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200173 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200174 );
175 break;
176 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION:
177 OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab(
178 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200179 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200180 );
181 break;
andre.schmid6692cde2019-07-16 10:01:17 +0000182 case enums.SCREEN
183 .SOFTWARE_PRODUCT_ATTACHMENTS_VIEW_VALIDATION:
184 OnboardingActionHelper.viewSoftwareProductAttachmentsValidationTab(
185 dispatch,
186 vspProps
187 );
188 break;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200189 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
190 OnboardingActionHelper.navigateToSoftwareProductProcesses(
191 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200192 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200193 );
194 break;
195 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
196 OnboardingActionHelper.navigateToSoftwareProductDeployment(
197 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200198 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200199 );
200 break;
201 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
202 OnboardingActionHelper.navigateToSoftwareProductNetworks(
203 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200204 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200205 );
206 break;
Vodafone804ec682019-03-18 15:46:53 +0530207 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION:
208 OnboardingActionHelper.navigateToSoftwareProductValidation(
209 dispatch,
210 vspProps
211 );
212 break;
213 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS:
214 OnboardingActionHelper.navigateToSoftwareProductValidationResults(
215 dispatch,
216 vspProps
217 );
218 break;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200219 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
220 OnboardingActionHelper.navigateToSoftwareProductDependencies(
221 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200222 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200223 );
224 break;
225 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
226 OnboardingActionHelper.navigateToSoftwareProductActivityLog(
227 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200228 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200229 );
230 break;
231 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
svishnev84f69f32018-03-21 14:27:59 +0200232 if (!componentId) {
233 OnboardingActionHelper.navigateToSoftwareProductComponents(
234 dispatch,
235 vspProps
236 );
237 dispatch({
238 type:
239 SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
240 mapOfExpandedIds: {
241 [enums.SCREEN
242 .SOFTWARE_PRODUCT_COMPONENTS]: true
243 }
244 });
245 } else {
246 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(
247 dispatch,
248 vspProps
249 );
250 }
251 break;
252 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
253 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200254 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200255 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200256 );
svishnev84f69f32018-03-21 14:27:59 +0200257 break;
258 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
259 OnboardingActionHelper.navigateToComponentCompute(
260 dispatch,
261 vspProps
262 );
263 break;
264 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
265 OnboardingActionHelper.navigateToComponentLoadBalancing(
266 dispatch,
267 vspProps
268 );
269 break;
270 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
271 OnboardingActionHelper.navigateToComponentNetwork(
272 dispatch,
273 vspProps
274 );
275 break;
276 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
277 OnboardingActionHelper.navigateToComponentStorage(
278 dispatch,
279 vspProps
280 );
281 break;
282 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
283 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(
284 dispatch,
285 vspProps
286 );
287 break;
288 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
289 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(
290 dispatch,
291 vspProps
292 );
293 break;
294 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
295 OnboardingActionHelper.navigateToComponentImages(
296 dispatch,
297 vspProps
298 );
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200299 break;
300 case enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE:
301 default:
302 OnboardingActionHelper.navigateToVersionsPage(
303 dispatch,
304 {
305 itemId: softwareProductId,
306 itemType: itemTypes.SOFTWARE_PRODUCT,
307 itemName: softwareProduct.name,
308 users: usersList,
309 additionalProps: {
310 licenseModelId: softwareProduct.vendorId,
311 licensingVersion:
312 softwareProduct.licensingVersion
313 }
314 }
315 );
316 break;
317 }
318 });
319 }
320 },
321
322 getScreenType(screen) {
323 switch (screen) {
324 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
325 case enums.SCREEN.LICENSE_AGREEMENTS:
326 case enums.SCREEN.FEATURE_GROUPS:
327 case enums.SCREEN.ENTITLEMENT_POOLS:
328 case enums.SCREEN.LICENSE_KEY_GROUPS:
329 case enums.SCREEN.ACTIVITY_LOG:
330 return screenTypes.LICENSE_MODEL;
331 case screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL:
332 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
333 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
334 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
335 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
336 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
337 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
338 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
339 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
340 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
341 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
342 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
343 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
344 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
345 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
346 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
347 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
348 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
349 return screenTypes.SOFTWARE_PRODUCT;
350 }
351 },
352
353 loadLandingScreen(
354 dispatch,
355 {
356 previousScreenName,
357 screenType,
358 props: { licenseModelId, softwareProductId, version }
359 }
360 ) {
361 let selectedScreenType = screenType
362 ? screenType
363 : this.getScreenType(previousScreenName);
364 let screen =
365 selectedScreenType === screenTypes.SOFTWARE_PRODUCT
366 ? enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE
367 : enums.SCREEN.LICENSE_MODEL_OVERVIEW;
368 let props = { licenseModelId, softwareProductId, version };
369 return this.loadScreen(dispatch, {
370 screen,
371 screenType: selectedScreenType,
372 props
373 });
374 }
talig8e9c0652017-12-20 14:30:43 +0200375};
376
377export default ScreensHelper;