blob: fbf0239ffbbad5c048c0ba03d835d682a20cc360 [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;
200 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
201 OnboardingActionHelper.navigateToSoftwareProductDependencies(
202 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200203 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200204 );
205 break;
206 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
207 OnboardingActionHelper.navigateToSoftwareProductActivityLog(
208 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200209 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200210 );
211 break;
212 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
svishnev84f69f32018-03-21 14:27:59 +0200213 if (!componentId) {
214 OnboardingActionHelper.navigateToSoftwareProductComponents(
215 dispatch,
216 vspProps
217 );
218 dispatch({
219 type:
220 SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
221 mapOfExpandedIds: {
222 [enums.SCREEN
223 .SOFTWARE_PRODUCT_COMPONENTS]: true
224 }
225 });
226 } else {
227 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(
228 dispatch,
229 vspProps
230 );
231 }
232 break;
233 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
234 OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200235 dispatch,
svishnev84f69f32018-03-21 14:27:59 +0200236 vspProps
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200237 );
svishnev84f69f32018-03-21 14:27:59 +0200238 break;
239 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
240 OnboardingActionHelper.navigateToComponentCompute(
241 dispatch,
242 vspProps
243 );
244 break;
245 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
246 OnboardingActionHelper.navigateToComponentLoadBalancing(
247 dispatch,
248 vspProps
249 );
250 break;
251 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
252 OnboardingActionHelper.navigateToComponentNetwork(
253 dispatch,
254 vspProps
255 );
256 break;
257 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
258 OnboardingActionHelper.navigateToComponentStorage(
259 dispatch,
260 vspProps
261 );
262 break;
263 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
264 OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(
265 dispatch,
266 vspProps
267 );
268 break;
269 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
270 OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(
271 dispatch,
272 vspProps
273 );
274 break;
275 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
276 OnboardingActionHelper.navigateToComponentImages(
277 dispatch,
278 vspProps
279 );
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200280 break;
281 case enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE:
282 default:
283 OnboardingActionHelper.navigateToVersionsPage(
284 dispatch,
285 {
286 itemId: softwareProductId,
287 itemType: itemTypes.SOFTWARE_PRODUCT,
288 itemName: softwareProduct.name,
289 users: usersList,
290 additionalProps: {
291 licenseModelId: softwareProduct.vendorId,
292 licensingVersion:
293 softwareProduct.licensingVersion
294 }
295 }
296 );
297 break;
298 }
299 });
300 }
301 },
302
303 getScreenType(screen) {
304 switch (screen) {
305 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
306 case enums.SCREEN.LICENSE_AGREEMENTS:
307 case enums.SCREEN.FEATURE_GROUPS:
308 case enums.SCREEN.ENTITLEMENT_POOLS:
309 case enums.SCREEN.LICENSE_KEY_GROUPS:
310 case enums.SCREEN.ACTIVITY_LOG:
311 return screenTypes.LICENSE_MODEL;
312 case screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL:
313 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL:
314 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
315 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
316 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK:
317 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE:
318 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
319 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING:
320 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES:
321 case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE:
322 case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS:
323 case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS:
324 case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES:
325 case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT:
326 case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS:
327 case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES:
328 case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG:
329 case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS:
330 return screenTypes.SOFTWARE_PRODUCT;
331 }
332 },
333
334 loadLandingScreen(
335 dispatch,
336 {
337 previousScreenName,
338 screenType,
339 props: { licenseModelId, softwareProductId, version }
340 }
341 ) {
342 let selectedScreenType = screenType
343 ? screenType
344 : this.getScreenType(previousScreenName);
345 let screen =
346 selectedScreenType === screenTypes.SOFTWARE_PRODUCT
347 ? enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE
348 : enums.SCREEN.LICENSE_MODEL_OVERVIEW;
349 let props = { licenseModelId, softwareProductId, version };
350 return this.loadScreen(dispatch, {
351 screen,
352 screenType: selectedScreenType,
353 props
354 });
355 }
talig8e9c0652017-12-20 14:30:43 +0200356};
357
358export default ScreensHelper;