blob: fc65083bffa81b6e69adb445325a3c5d3d4e95ff [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';
Michael Lando4d97d5f2017-06-17 22:40:44 +030038import {selectedButton as licenseModelOverviewSelectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
shrek2000c8a540b2017-09-11 15:45:37 +030039import {tabsMapping as attachmentsTabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
40import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020041
42function setCurrentScreen(dispatch, screen, props = {}) {
43 dispatch({
44 type: actionTypes.SET_CURRENT_SCREEN,
45 currentScreen: {
46 screen,
AviZi280f8012017-06-09 02:39:56 +030047 props,
48 forceBreadCrumbsUpdate: true
Michael Landoefa037d2017-02-19 12:57:33 +020049 }
50 });
51}
52
53function getCurrentLicenseModelVersion(licenseModelId) {
54 return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version;
55}
56
AviZi280f8012017-06-09 02:39:56 +030057function getCurrentSoftwareProductVersion(softwareProductId) {
58 return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version;
59}
60
Michael Landoefa037d2017-02-19 12:57:33 +020061export default {
62
63 navigateToOnboardingCatalog(dispatch) {
64 LicenseModelActionHelper.fetchLicenseModels(dispatch);
AviZi280f8012017-06-09 02:39:56 +030065 LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020066 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch);
AviZi280f8012017-06-09 02:39:56 +030067 SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch);
68 OnboardActionHelper.resetOnboardStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020069 setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG);
70 },
71
AviZi280f8012017-06-09 02:39:56 +030072 autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) {
73 if(softwareProductId) {
74 if(vspComponentId) {
75 return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {
76 softwareProductId, version, vspComponentId,
77 componentData: dataToSave.componentData,
78 qdata: dataToSave.qdata
79 });
80 }
81 return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {
82 softwareProduct: dataToSave.softwareProduct,
83 qdata: dataToSave.qdata
84 });
85 }
86 return Promise.resolve();
87 },
88
89 navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) {
90 if (!version) {
91 version = getCurrentLicenseModelVersion(licenseModelId);
92 }
93
94 /**
95 * TODO change to specific rest
96 */
97
98 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
99 LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() =>{
100 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version});
101 });
Michael Lando4d97d5f2017-06-17 22:40:44 +0300102 licenseModelOverviewActionHelper.selectVLMListView(dispatch, {buttonTab: licenseModelOverviewSelectedButton.VLM_LIST_VIEW});
AviZi280f8012017-06-09 02:39:56 +0300103 });
104 },
Michael Landoefa037d2017-02-19 12:57:33 +0200105 navigateToLicenseAgreements(dispatch, {licenseModelId, version}) {
106 if(!version) {
107 version = getCurrentLicenseModelVersion(licenseModelId);
108 }
109 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
110 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300111 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200112 });
113 },
114
115 navigateToFeatureGroups(dispatch, {licenseModelId, version}) {
116 if(!version) {
117 version = getCurrentLicenseModelVersion(licenseModelId);
118 }
119 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300120 setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200121 },
122
123 navigateToEntitlementPools(dispatch, {licenseModelId, version}) {
124 if(!version) {
125 version = getCurrentLicenseModelVersion(licenseModelId);
126 }
127 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300128 setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200129 },
130
131 navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) {
132 if(!version) {
133 version = getCurrentLicenseModelVersion(licenseModelId);
134 }
135 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300136 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version});
137 },
138
139 navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){
140 if(!version) {
141 version = getCurrentLicenseModelVersion(licenseModelId);
142 }
143 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id});
144 setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200145 },
146
147 navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) {
AviZi280f8012017-06-09 02:39:56 +0300148
149 if (!version) {
150 version = getCurrentSoftwareProductVersion(softwareProductId);
151 }
152
153 SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +0200154 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => {
155 if(!licensingVersion) {
156 licensingVersion = response[0].licensingVersion;
AviZi280f8012017-06-09 02:39:56 +0300157 if (!licensingVersion) {
158 licensingVersion = {id: '1.0', label: '1.0'};
159 }
Michael Landoefa037d2017-02-19 12:57:33 +0200160 }
161 if (!licenseModelId) {
162 licenseModelId = response[0].vendorId;
163 }
164
Michael Landob3d48982017-06-11 14:22:02 +0300165 const newVersion = response[0].version ? response[0].version : version;
166
Michael Landoefa037d2017-02-19 12:57:33 +0200167 SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion});
Avi Ziv61070c92017-07-26 17:37:57 +0300168
169 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion});
shrek2000c8a540b2017-09-11 15:45:37 +0300170 if(response[0].onboardingOrigin === onboardingOriginTypes.ZIP) {
171 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion});
172 }
Avi Ziv61070c92017-07-26 17:37:57 +0300173 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion});
Michael Landoefa037d2017-02-19 12:57:33 +0200174 });
175 },
176
AviZi280f8012017-06-09 02:39:56 +0300177 navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) {
178 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version});
179 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200180 },
181
shrek2000c8a540b2017-09-11 15:45:37 +0300182 navigateToSoftwareProductAttachmentsSetupTab(dispatch, {softwareProductId, version}) {
AviZi280f8012017-06-09 02:39:56 +0300183 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
shrek2000c8a540b2017-09-11 15:45:37 +0300184 SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.SETUP});
AviZi280f8012017-06-09 02:39:56 +0300185 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200186 },
187
shrek2000c8a540b2017-09-11 15:45:37 +0300188 navigateToSoftwareProductAttachmentsValidationTab(dispatch, {softwareProductId, version}) {
189 SoftwareProductActionHelper.processAndValidateHeatCandidate(dispatch, {softwareProductId, version}).then(() => {
190 SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.VALIDATION});
191 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
192 });
193 },
194
Michael Landoefa037d2017-02-19 12:57:33 +0200195 navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) {
196 if (softwareProductId) {
197 SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version});
198 }
AviZi280f8012017-06-09 02:39:56 +0300199 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200200 },
201
202 navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) {
203 if (softwareProductId) {
204 SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version});
205 }
AviZi280f8012017-06-09 02:39:56 +0300206 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200207 },
208
AviZi280f8012017-06-09 02:39:56 +0300209 navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) {
210 SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
211 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version});
212 },
213
214 navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) {
215 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
216 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version});
217 },
Avi Zivb8e2faf2017-07-18 19:45:38 +0300218 navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version}) {
219 SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version});
220 ComputeFlavorActionHelper.fetchComputesListForVSP(dispatch, {softwareProductId, version});
221 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, {softwareProductId, version});
222 },
AviZi280f8012017-06-09 02:39:56 +0300223 navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){
224 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id});
225 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200226 },
227
228 navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) {
229 if (componentId && softwareProductId) {
230 SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version});
231 }
AviZi280f8012017-06-09 02:39:56 +0300232 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200233 },
234
AviZi280f8012017-06-09 02:39:56 +0300235 navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){
236 if (componentId && softwareProductId && version) {
237 SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200238 }
AviZi280f8012017-06-09 02:39:56 +0300239 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200240 },
241
AviZi280f8012017-06-09 02:39:56 +0300242 navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) {
243 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
244 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200245 },
246
AviZi280f8012017-06-09 02:39:56 +0300247 navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) {
248 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300249 if (componentId && softwareProductId) {
250 ComputeFlavorActionHelper.fetchComputesList(dispatch, {softwareProductId, componentId, version});
251 }
AviZi280f8012017-06-09 02:39:56 +0300252 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200253 },
254
255 navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) {
256 SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version});
AviZi280f8012017-06-09 02:39:56 +0300257 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200258 },
259
260 navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) {
261 if (componentId && softwareProductId) {
262 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200263 }
AviZi280f8012017-06-09 02:39:56 +0300264 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200265 },
266
267 navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) {
268 this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version});
269 dispatch({
270 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
271 mapOfExpandedIds: {
272 [SoftwareProductNavigationItems.COMPONENTS]: true,
273 [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true
274 }
275 });
276 },
277
AviZi280f8012017-06-09 02:39:56 +0300278 navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) {
279 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
280 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300281 },
282
283 navigateToComponentImages(dispatch, {softwareProductId, componentId, version}) {
284 SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, {
285 softwareProductId,
286 componentId,
287 version
288 });
289 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES, {softwareProductId, version, componentId});
az2497644017c2017-08-10 17:49:40 +0300290 },
291
292 updateCurrentScreenVersion(dispatch, version) {
293 dispatch({
294 type: actionTypes.SET_CURRENT_SCREEN_VERSION,
295 version
296 });
Michael Landoefa037d2017-02-19 12:57:33 +0200297 }
AviZi280f8012017-06-09 02:39:56 +0300298
Michael Landoefa037d2017-02-19 12:57:33 +0200299};