blob: 2788d4db92d1cc46c525a20006b8cdd20c6d5013 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
Michael Landoefa037d2017-02-19 12:57:33 +02002 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * 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
AviZi280f8012017-06-09 02:39:56 +03007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
AviZi280f8012017-06-09 02:39:56 +030012 * 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.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import LicenseModelActionHelper from './licenseModel/LicenseModelActionHelper.js';
17import LicenseAgreementActionHelper from './licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
18import FeatureGroupsActionHelper from './licenseModel/featureGroups/FeatureGroupsActionHelper.js';
19import LicenseKeyGroupsActionHelper from './licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
20import EntitlementPoolsActionHelper from './licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
21import SoftwareProductActionHelper from './softwareProduct/SoftwareProductActionHelper.js';
22import SoftwareProductProcessesActionHelper from './softwareProduct/processes/SoftwareProductProcessesActionHelper.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030023import SoftwareProductDeploymentActionHelper from './softwareProduct/deployment/SoftwareProductDeploymentActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020024import SoftwareProductNetworksActionHelper from './softwareProduct/networks/SoftwareProductNetworksActionHelper.js';
25import SoftwareProductComponentsActionHelper from './softwareProduct/components/SoftwareProductComponentsActionHelper.js';
26import SoftwareProductComponentProcessesActionHelper from './softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js';
27import SoftwareProductComponentsNetworkActionHelper from './softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js';
AviZi280f8012017-06-09 02:39:56 +030028import SoftwareProductDependenciesActionHelper from './softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030029import ComputeFlavorActionHelper from './softwareProduct/components/compute/ComputeFlavorActionHelper.js';
AviZi280f8012017-06-09 02:39:56 +030030import OnboardActionHelper from './onboard/OnboardActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020031import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js';
32import {actionTypes, enums} from './OnboardingConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030033import SoftwareProductComponentsImageActionHelper from './softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js';
shrek2000c8a540b2017-09-11 15:45:37 +030034import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
Avi Zivb8e2faf2017-07-18 19:45:38 +030035import ActivityLogActionHelper from 'sdc-app/common/activity-log/ActivityLogActionHelper.js';
Michael Lando4d97d5f2017-06-17 22:40:44 +030036import licenseModelOverviewActionHelper from 'sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020037import store from 'sdc-app/AppStore.js';
shrek2000c8a540b2017-09-11 15:45:37 +030038import {tabsMapping as attachmentsTabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
39import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020040
41function setCurrentScreen(dispatch, screen, props = {}) {
42 dispatch({
43 type: actionTypes.SET_CURRENT_SCREEN,
44 currentScreen: {
45 screen,
AviZi280f8012017-06-09 02:39:56 +030046 props,
47 forceBreadCrumbsUpdate: true
Michael Landoefa037d2017-02-19 12:57:33 +020048 }
49 });
50}
51
52function getCurrentLicenseModelVersion(licenseModelId) {
53 return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version;
54}
55
AviZi280f8012017-06-09 02:39:56 +030056function getCurrentSoftwareProductVersion(softwareProductId) {
57 return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version;
58}
59
Michael Landoefa037d2017-02-19 12:57:33 +020060export default {
61
62 navigateToOnboardingCatalog(dispatch) {
63 LicenseModelActionHelper.fetchLicenseModels(dispatch);
AviZi280f8012017-06-09 02:39:56 +030064 LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020065 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch);
AviZi280f8012017-06-09 02:39:56 +030066 SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch);
67 OnboardActionHelper.resetOnboardStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020068 setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG);
69 },
70
AviZi280f8012017-06-09 02:39:56 +030071 autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) {
72 if(softwareProductId) {
73 if(vspComponentId) {
74 return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {
75 softwareProductId, version, vspComponentId,
76 componentData: dataToSave.componentData,
77 qdata: dataToSave.qdata
78 });
79 }
80 return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {
81 softwareProduct: dataToSave.softwareProduct,
82 qdata: dataToSave.qdata
83 });
84 }
85 return Promise.resolve();
86 },
87
88 navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) {
89 if (!version) {
90 version = getCurrentLicenseModelVersion(licenseModelId);
91 }
92
93 /**
94 * TODO change to specific rest
95 */
96
97 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
98 LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() =>{
99 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version});
100 });
ilanapc6a41de2017-11-07 11:54:10 +0200101 licenseModelOverviewActionHelper.selectVLMListView(dispatch, {buttonTab: null});
AviZi280f8012017-06-09 02:39:56 +0300102 });
103 },
Michael Landoefa037d2017-02-19 12:57:33 +0200104 navigateToLicenseAgreements(dispatch, {licenseModelId, version}) {
105 if(!version) {
106 version = getCurrentLicenseModelVersion(licenseModelId);
107 }
108 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
109 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300110 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200111 });
112 },
113
114 navigateToFeatureGroups(dispatch, {licenseModelId, version}) {
115 if(!version) {
116 version = getCurrentLicenseModelVersion(licenseModelId);
117 }
118 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300119 setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200120 },
121
122 navigateToEntitlementPools(dispatch, {licenseModelId, version}) {
123 if(!version) {
124 version = getCurrentLicenseModelVersion(licenseModelId);
125 }
126 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300127 setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200128 },
129
130 navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) {
131 if(!version) {
132 version = getCurrentLicenseModelVersion(licenseModelId);
133 }
134 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300135 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version});
136 },
137
138 navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){
139 if(!version) {
140 version = getCurrentLicenseModelVersion(licenseModelId);
141 }
142 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id});
143 setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200144 },
145
146 navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) {
AviZi280f8012017-06-09 02:39:56 +0300147
148 if (!version) {
149 version = getCurrentSoftwareProductVersion(softwareProductId);
150 }
151
152 SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +0200153 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => {
154 if(!licensingVersion) {
155 licensingVersion = response[0].licensingVersion;
AviZi280f8012017-06-09 02:39:56 +0300156 if (!licensingVersion) {
157 licensingVersion = {id: '1.0', label: '1.0'};
158 }
Michael Landoefa037d2017-02-19 12:57:33 +0200159 }
160 if (!licenseModelId) {
161 licenseModelId = response[0].vendorId;
162 }
163
Michael Landob3d48982017-06-11 14:22:02 +0300164 const newVersion = response[0].version ? response[0].version : version;
165
Michael Landoefa037d2017-02-19 12:57:33 +0200166 SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion});
Avi Ziv61070c92017-07-26 17:37:57 +0300167
168 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion});
shrek2000c8a540b2017-09-11 15:45:37 +0300169 if(response[0].onboardingOrigin === onboardingOriginTypes.ZIP) {
170 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion});
171 }
Avi Ziv61070c92017-07-26 17:37:57 +0300172 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion});
Michael Landoefa037d2017-02-19 12:57:33 +0200173 });
174 },
175
AviZi280f8012017-06-09 02:39:56 +0300176 navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) {
177 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version});
178 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200179 },
180
shrek2000c8a540b2017-09-11 15:45:37 +0300181 navigateToSoftwareProductAttachmentsSetupTab(dispatch, {softwareProductId, version}) {
AviZi280f8012017-06-09 02:39:56 +0300182 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
shrek2000c8a540b2017-09-11 15:45:37 +0300183 SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.SETUP});
AviZi280f8012017-06-09 02:39:56 +0300184 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200185 },
186
shrek2000c8a540b2017-09-11 15:45:37 +0300187 navigateToSoftwareProductAttachmentsValidationTab(dispatch, {softwareProductId, version}) {
188 SoftwareProductActionHelper.processAndValidateHeatCandidate(dispatch, {softwareProductId, version}).then(() => {
189 SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.VALIDATION});
190 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
191 });
192 },
193
Michael Landoefa037d2017-02-19 12:57:33 +0200194 navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) {
195 if (softwareProductId) {
196 SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version});
197 }
AviZi280f8012017-06-09 02:39:56 +0300198 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200199 },
200
201 navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) {
202 if (softwareProductId) {
203 SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version});
204 }
AviZi280f8012017-06-09 02:39:56 +0300205 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200206 },
207
AviZi280f8012017-06-09 02:39:56 +0300208 navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) {
209 SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
210 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version});
211 },
212
213 navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) {
214 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
215 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version});
216 },
Avi Zivb8e2faf2017-07-18 19:45:38 +0300217 navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version}) {
218 SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version});
219 ComputeFlavorActionHelper.fetchComputesListForVSP(dispatch, {softwareProductId, version});
220 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, {softwareProductId, version});
221 },
AviZi280f8012017-06-09 02:39:56 +0300222 navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){
223 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id});
224 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200225 },
226
227 navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) {
228 if (componentId && softwareProductId) {
229 SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version});
230 }
AviZi280f8012017-06-09 02:39:56 +0300231 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200232 },
233
AviZi280f8012017-06-09 02:39:56 +0300234 navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){
235 if (componentId && softwareProductId && version) {
236 SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200237 }
AviZi280f8012017-06-09 02:39:56 +0300238 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200239 },
240
AviZi280f8012017-06-09 02:39:56 +0300241 navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) {
242 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
243 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200244 },
245
AviZi280f8012017-06-09 02:39:56 +0300246 navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) {
247 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300248 if (componentId && softwareProductId) {
249 ComputeFlavorActionHelper.fetchComputesList(dispatch, {softwareProductId, componentId, version});
250 }
AviZi280f8012017-06-09 02:39:56 +0300251 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200252 },
253
254 navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) {
255 SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version});
AviZi280f8012017-06-09 02:39:56 +0300256 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200257 },
258
259 navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) {
260 if (componentId && softwareProductId) {
261 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200262 }
AviZi280f8012017-06-09 02:39:56 +0300263 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200264 },
265
266 navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) {
267 this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version});
268 dispatch({
269 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
270 mapOfExpandedIds: {
271 [SoftwareProductNavigationItems.COMPONENTS]: true,
272 [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true
273 }
274 });
275 },
276
AviZi280f8012017-06-09 02:39:56 +0300277 navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) {
278 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
279 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300280 },
281
282 navigateToComponentImages(dispatch, {softwareProductId, componentId, version}) {
283 SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, {
284 softwareProductId,
285 componentId,
286 version
287 });
288 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES, {softwareProductId, version, componentId});
az2497644017c2017-08-10 17:49:40 +0300289 },
290
291 updateCurrentScreenVersion(dispatch, version) {
292 dispatch({
293 type: actionTypes.SET_CURRENT_SCREEN_VERSION,
294 version
295 });
Michael Landoefa037d2017-02-19 12:57:33 +0200296 }
AviZi280f8012017-06-09 02:39:56 +0300297
Michael Landoefa037d2017-02-19 12:57:33 +0200298};