blob: 58f47957def83e2c02d46f5ab88d00677e1b9180 [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;
182 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
183 OnboardingActionHelper.navigateToSoftwareProductProcesses(
184 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200185 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200186 );
187 break;
188 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
189 OnboardingActionHelper.navigateToSoftwareProductDeployment(
190 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200191 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200192 );
193 break;
194 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
195 OnboardingActionHelper.navigateToSoftwareProductNetworks(
196 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200197 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200198 );
199 break;
Vodafone804ec682019-03-18 15:46:53 +0530200 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION:
201 OnboardingActionHelper.navigateToSoftwareProductValidation(
202 dispatch,
203 vspProps
204 );
205 break;
206 case enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS:
207 OnboardingActionHelper.navigateToSoftwareProductValidationResults(
208 dispatch,
209 vspProps
210 );
211 break;
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200212 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
213 OnboardingActionHelper.navigateToSoftwareProductDependencies(
214 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200215 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200216 );
217 break;
218 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
219 OnboardingActionHelper.navigateToSoftwareProductActivityLog(
220 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200221 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200222 );
223 break;
224 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
svishnev84f69f32018-03-21 14:27:59 +0200225 if (!componentId) {
226 OnboardingActionHelper.navigateToSoftwareProductComponents(
227 dispatch,
228 vspProps
229 );
230 dispatch({
231 type:
232 SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
233 mapOfExpandedIds: {
234 [enums.SCREEN
235 .SOFTWARE_PRODUCT_COMPONENTS]: true
236 }
237 });
238 } else {
239 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(
240 dispatch,
241 vspProps
242 );
243 }
244 break;
245 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
246 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200247 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200248 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200249 );
svishnev84f69f32018-03-21 14:27:59 +0200250 break;
251 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
252 OnboardingActionHelper.navigateToComponentCompute(
253 dispatch,
254 vspProps
255 );
256 break;
257 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
258 OnboardingActionHelper.navigateToComponentLoadBalancing(
259 dispatch,
260 vspProps
261 );
262 break;
263 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
264 OnboardingActionHelper.navigateToComponentNetwork(
265 dispatch,
266 vspProps
267 );
268 break;
269 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
270 OnboardingActionHelper.navigateToComponentStorage(
271 dispatch,
272 vspProps
273 );
274 break;
275 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
276 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(
277 dispatch,
278 vspProps
279 );
280 break;
281 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
282 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(
283 dispatch,
284 vspProps
285 );
286 break;
287 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
288 OnboardingActionHelper.navigateToComponentImages(
289 dispatch,
290 vspProps
291 );
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200292 break;
293 case enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE:
294 default:
295 OnboardingActionHelper.navigateToVersionsPage(
296 dispatch,
297 {
298 itemId: softwareProductId,
299 itemType: itemTypes.SOFTWARE_PRODUCT,
300 itemName: softwareProduct.name,
301 users: usersList,
302 additionalProps: {
303 licenseModelId: softwareProduct.vendorId,
304 licensingVersion:
305 softwareProduct.licensingVersion
306 }
307 }
308 );
309 break;
310 }
311 });
312 }
313 },
314
315 getScreenType(screen) {
316 switch (screen) {
317 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
318 case enums.SCREEN.LICENSE_AGREEMENTS:
319 case enums.SCREEN.FEATURE_GROUPS:
320 case enums.SCREEN.ENTITLEMENT_POOLS:
321 case enums.SCREEN.LICENSE_KEY_GROUPS:
322 case enums.SCREEN.ACTIVITY_LOG:
323 return screenTypes.LICENSE_MODEL;
324 case screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL:
325 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
326 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
327 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
328 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
329 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
330 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
331 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
332 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
333 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
334 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
335 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
336 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
337 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
338 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
339 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
340 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
341 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
342 return screenTypes.SOFTWARE_PRODUCT;
343 }
344 },
345
346 loadLandingScreen(
347 dispatch,
348 {
349 previousScreenName,
350 screenType,
351 props: { licenseModelId, softwareProductId, version }
352 }
353 ) {
354 let selectedScreenType = screenType
355 ? screenType
356 : this.getScreenType(previousScreenName);
357 let screen =
358 selectedScreenType === screenTypes.SOFTWARE_PRODUCT
359 ? enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE
360 : enums.SCREEN.LICENSE_MODEL_OVERVIEW;
361 let props = { licenseModelId, softwareProductId, version };
362 return this.loadScreen(dispatch, {
363 screen,
364 screenType: selectedScreenType,
365 props
366 });
367 }
talig8e9c0652017-12-20 14:30:43 +0200368};
369
370export default ScreensHelper;