blob: 24ba05e303047280091ccb876db901de29afab33 [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';
Avi Ziv61070c92017-07-26 17:37:57 +030034import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} 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';
Michael Landoefa037d2017-02-19 12:57:33 +020039
40function setCurrentScreen(dispatch, screen, props = {}) {
41 dispatch({
42 type: actionTypes.SET_CURRENT_SCREEN,
43 currentScreen: {
44 screen,
AviZi280f8012017-06-09 02:39:56 +030045 props,
46 forceBreadCrumbsUpdate: true
Michael Landoefa037d2017-02-19 12:57:33 +020047 }
48 });
49}
50
51function getCurrentLicenseModelVersion(licenseModelId) {
52 return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version;
53}
54
AviZi280f8012017-06-09 02:39:56 +030055function getCurrentSoftwareProductVersion(softwareProductId) {
56 return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version;
57}
58
Michael Landoefa037d2017-02-19 12:57:33 +020059export default {
60
61 navigateToOnboardingCatalog(dispatch) {
62 LicenseModelActionHelper.fetchLicenseModels(dispatch);
AviZi280f8012017-06-09 02:39:56 +030063 LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020064 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch);
AviZi280f8012017-06-09 02:39:56 +030065 SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch);
66 OnboardActionHelper.resetOnboardStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020067 setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG);
68 },
69
AviZi280f8012017-06-09 02:39:56 +030070 autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) {
71 if(softwareProductId) {
72 if(vspComponentId) {
73 return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {
74 softwareProductId, version, vspComponentId,
75 componentData: dataToSave.componentData,
76 qdata: dataToSave.qdata
77 });
78 }
79 return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {
80 softwareProduct: dataToSave.softwareProduct,
81 qdata: dataToSave.qdata
82 });
83 }
84 return Promise.resolve();
85 },
86
87 navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) {
88 if (!version) {
89 version = getCurrentLicenseModelVersion(licenseModelId);
90 }
91
92 /**
93 * TODO change to specific rest
94 */
95
96 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
97 LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() =>{
98 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version});
99 });
Michael Lando4d97d5f2017-06-17 22:40:44 +0300100 licenseModelOverviewActionHelper.selectVLMListView(dispatch, {buttonTab: licenseModelOverviewSelectedButton.VLM_LIST_VIEW});
AviZi280f8012017-06-09 02:39:56 +0300101 });
102 },
Michael Landoefa037d2017-02-19 12:57:33 +0200103 navigateToLicenseAgreements(dispatch, {licenseModelId, version}) {
104 if(!version) {
105 version = getCurrentLicenseModelVersion(licenseModelId);
106 }
107 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
108 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300109 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200110 });
111 },
112
113 navigateToFeatureGroups(dispatch, {licenseModelId, version}) {
114 if(!version) {
115 version = getCurrentLicenseModelVersion(licenseModelId);
116 }
117 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300118 setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200119 },
120
121 navigateToEntitlementPools(dispatch, {licenseModelId, version}) {
122 if(!version) {
123 version = getCurrentLicenseModelVersion(licenseModelId);
124 }
125 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300126 setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200127 },
128
129 navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) {
130 if(!version) {
131 version = getCurrentLicenseModelVersion(licenseModelId);
132 }
133 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300134 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version});
135 },
136
137 navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){
138 if(!version) {
139 version = getCurrentLicenseModelVersion(licenseModelId);
140 }
141 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id});
142 setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200143 },
144
145 navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) {
AviZi280f8012017-06-09 02:39:56 +0300146
147 if (!version) {
148 version = getCurrentSoftwareProductVersion(softwareProductId);
149 }
150
151 SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +0200152 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => {
153 if(!licensingVersion) {
154 licensingVersion = response[0].licensingVersion;
AviZi280f8012017-06-09 02:39:56 +0300155 if (!licensingVersion) {
156 licensingVersion = {id: '1.0', label: '1.0'};
157 }
Michael Landoefa037d2017-02-19 12:57:33 +0200158 }
159 if (!licenseModelId) {
160 licenseModelId = response[0].vendorId;
161 }
162
Michael Landob3d48982017-06-11 14:22:02 +0300163 const newVersion = response[0].version ? response[0].version : version;
164
Michael Landoefa037d2017-02-19 12:57:33 +0200165 SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion});
Avi Ziv61070c92017-07-26 17:37:57 +0300166
167 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion});
168 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion});
169 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion});
Michael Landoefa037d2017-02-19 12:57:33 +0200170 });
171 },
172
AviZi280f8012017-06-09 02:39:56 +0300173 navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) {
174 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version});
175 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200176 },
177
AviZi280f8012017-06-09 02:39:56 +0300178 navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) {
179 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
180 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200181 },
182
183 navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) {
184 if (softwareProductId) {
185 SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version});
186 }
AviZi280f8012017-06-09 02:39:56 +0300187 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200188 },
189
190 navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) {
191 if (softwareProductId) {
192 SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version});
193 }
AviZi280f8012017-06-09 02:39:56 +0300194 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200195 },
196
AviZi280f8012017-06-09 02:39:56 +0300197 navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) {
198 SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
199 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version});
200 },
201
202 navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) {
203 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
204 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version});
205 },
Avi Zivb8e2faf2017-07-18 19:45:38 +0300206 navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version}) {
207 SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version});
208 ComputeFlavorActionHelper.fetchComputesListForVSP(dispatch, {softwareProductId, version});
209 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, {softwareProductId, version});
210 },
AviZi280f8012017-06-09 02:39:56 +0300211 navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){
212 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id});
213 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200214 },
215
216 navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) {
217 if (componentId && softwareProductId) {
218 SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version});
219 }
AviZi280f8012017-06-09 02:39:56 +0300220 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200221 },
222
AviZi280f8012017-06-09 02:39:56 +0300223 navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){
224 if (componentId && softwareProductId && version) {
225 SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200226 }
AviZi280f8012017-06-09 02:39:56 +0300227 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200228 },
229
AviZi280f8012017-06-09 02:39:56 +0300230 navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) {
231 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
232 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200233 },
234
AviZi280f8012017-06-09 02:39:56 +0300235 navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) {
236 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300237 if (componentId && softwareProductId) {
238 ComputeFlavorActionHelper.fetchComputesList(dispatch, {softwareProductId, componentId, version});
239 }
AviZi280f8012017-06-09 02:39:56 +0300240 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200241 },
242
243 navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) {
244 SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version});
AviZi280f8012017-06-09 02:39:56 +0300245 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200246 },
247
248 navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) {
249 if (componentId && softwareProductId) {
250 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200251 }
AviZi280f8012017-06-09 02:39:56 +0300252 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200253 },
254
255 navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) {
256 this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version});
257 dispatch({
258 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
259 mapOfExpandedIds: {
260 [SoftwareProductNavigationItems.COMPONENTS]: true,
261 [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true
262 }
263 });
264 },
265
AviZi280f8012017-06-09 02:39:56 +0300266 navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) {
267 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
268 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId});
Avi Zivb8e2faf2017-07-18 19:45:38 +0300269 },
270
271 navigateToComponentImages(dispatch, {softwareProductId, componentId, version}) {
272 SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, {
273 softwareProductId,
274 componentId,
275 version
276 });
277 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES, {softwareProductId, version, componentId});
az2497644017c2017-08-10 17:49:40 +0300278 },
279
280 updateCurrentScreenVersion(dispatch, version) {
281 dispatch({
282 type: actionTypes.SET_CURRENT_SCREEN_VERSION,
283 version
284 });
Michael Landoefa037d2017-02-19 12:57:33 +0200285 }
AviZi280f8012017-06-09 02:39:56 +0300286
Michael Landoefa037d2017-02-19 12:57:33 +0200287};