blob: 74bde4058be30b1977eb06d6d786ec049d2ff7b3 [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';
23import SoftwareProductNetworksActionHelper from './softwareProduct/networks/SoftwareProductNetworksActionHelper.js';
24import SoftwareProductComponentsActionHelper from './softwareProduct/components/SoftwareProductComponentsActionHelper.js';
25import SoftwareProductComponentProcessesActionHelper from './softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js';
26import SoftwareProductComponentsNetworkActionHelper from './softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js';
AviZi280f8012017-06-09 02:39:56 +030027import SoftwareProductDependenciesActionHelper from './softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js';
28import OnboardActionHelper from './onboard/OnboardActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020029import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js';
30import {actionTypes, enums} from './OnboardingConstants.js';
31import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
AviZi280f8012017-06-09 02:39:56 +030032import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js';
Michael Landoefa037d2017-02-19 12:57:33 +020033import store from 'sdc-app/AppStore.js';
34
35function setCurrentScreen(dispatch, screen, props = {}) {
36 dispatch({
37 type: actionTypes.SET_CURRENT_SCREEN,
38 currentScreen: {
39 screen,
AviZi280f8012017-06-09 02:39:56 +030040 props,
41 forceBreadCrumbsUpdate: true
Michael Landoefa037d2017-02-19 12:57:33 +020042 }
43 });
44}
45
46function getCurrentLicenseModelVersion(licenseModelId) {
47 return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version;
48}
49
AviZi280f8012017-06-09 02:39:56 +030050function getCurrentSoftwareProductVersion(softwareProductId) {
51 return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version;
52}
53
Michael Landoefa037d2017-02-19 12:57:33 +020054export default {
55
56 navigateToOnboardingCatalog(dispatch) {
57 LicenseModelActionHelper.fetchLicenseModels(dispatch);
AviZi280f8012017-06-09 02:39:56 +030058 LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020059 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch);
AviZi280f8012017-06-09 02:39:56 +030060 SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch);
61 OnboardActionHelper.resetOnboardStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +020062 setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG);
63 },
64
AviZi280f8012017-06-09 02:39:56 +030065 autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) {
66 if(softwareProductId) {
67 if(vspComponentId) {
68 return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {
69 softwareProductId, version, vspComponentId,
70 componentData: dataToSave.componentData,
71 qdata: dataToSave.qdata
72 });
73 }
74 return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {
75 softwareProduct: dataToSave.softwareProduct,
76 qdata: dataToSave.qdata
77 });
78 }
79 return Promise.resolve();
80 },
81
82 navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) {
83 if (!version) {
84 version = getCurrentLicenseModelVersion(licenseModelId);
85 }
86
87 /**
88 * TODO change to specific rest
89 */
90
91 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
92 LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() =>{
93 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version});
94 });
95
96 });
97 },
Michael Landoefa037d2017-02-19 12:57:33 +020098 navigateToLicenseAgreements(dispatch, {licenseModelId, version}) {
99 if(!version) {
100 version = getCurrentLicenseModelVersion(licenseModelId);
101 }
102 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
103 LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300104 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200105 });
106 },
107
108 navigateToFeatureGroups(dispatch, {licenseModelId, version}) {
109 if(!version) {
110 version = getCurrentLicenseModelVersion(licenseModelId);
111 }
112 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300113 setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200114 },
115
116 navigateToEntitlementPools(dispatch, {licenseModelId, version}) {
117 if(!version) {
118 version = getCurrentLicenseModelVersion(licenseModelId);
119 }
120 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300121 setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200122 },
123
124 navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) {
125 if(!version) {
126 version = getCurrentLicenseModelVersion(licenseModelId);
127 }
128 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
AviZi280f8012017-06-09 02:39:56 +0300129 setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version});
130 },
131
132 navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){
133 if(!version) {
134 version = getCurrentLicenseModelVersion(licenseModelId);
135 }
136 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id});
137 setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200138 },
139
140 navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) {
AviZi280f8012017-06-09 02:39:56 +0300141
142 if (!version) {
143 version = getCurrentSoftwareProductVersion(softwareProductId);
144 }
145
146 SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch);
Michael Landoefa037d2017-02-19 12:57:33 +0200147 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => {
148 if(!licensingVersion) {
149 licensingVersion = response[0].licensingVersion;
AviZi280f8012017-06-09 02:39:56 +0300150 if (!licensingVersion) {
151 licensingVersion = {id: '1.0', label: '1.0'};
152 }
Michael Landoefa037d2017-02-19 12:57:33 +0200153 }
154 if (!licenseModelId) {
155 licenseModelId = response[0].vendorId;
156 }
157
Michael Landob3d48982017-06-11 14:22:02 +0300158 const newVersion = response[0].version ? response[0].version : version;
159
Michael Landoefa037d2017-02-19 12:57:33 +0200160 SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion});
Michael Landob3d48982017-06-11 14:22:02 +0300161 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: newVersion});
162 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: newVersion});
163 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version: newVersion});
Michael Landoefa037d2017-02-19 12:57:33 +0200164 });
165 },
166
AviZi280f8012017-06-09 02:39:56 +0300167 navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) {
168 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version});
169 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200170 },
171
AviZi280f8012017-06-09 02:39:56 +0300172 navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) {
173 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
174 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200175 },
176
177 navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) {
178 if (softwareProductId) {
179 SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version});
180 }
AviZi280f8012017-06-09 02:39:56 +0300181 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200182 },
183
184 navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) {
185 if (softwareProductId) {
186 SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version});
187 }
AviZi280f8012017-06-09 02:39:56 +0300188 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200189 },
190
AviZi280f8012017-06-09 02:39:56 +0300191 navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) {
192 SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
193 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version});
194 },
195
196 navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) {
197 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
198 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version});
199 },
200
201 navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){
202 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id});
203 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200204 },
205
206 navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) {
207 if (componentId && softwareProductId) {
208 SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version});
209 }
AviZi280f8012017-06-09 02:39:56 +0300210 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200211 },
212
AviZi280f8012017-06-09 02:39:56 +0300213 navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){
214 if (componentId && softwareProductId && version) {
215 SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200216 }
AviZi280f8012017-06-09 02:39:56 +0300217 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200218 },
219
AviZi280f8012017-06-09 02:39:56 +0300220 navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) {
221 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
222 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200223 },
224
AviZi280f8012017-06-09 02:39:56 +0300225 navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) {
226 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
227 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200228 },
229
230 navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) {
231 SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version});
AviZi280f8012017-06-09 02:39:56 +0300232 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200233 },
234
235 navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) {
236 if (componentId && softwareProductId) {
237 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200238 }
AviZi280f8012017-06-09 02:39:56 +0300239 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200240 },
241
242 navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) {
243 this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version});
244 dispatch({
245 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
246 mapOfExpandedIds: {
247 [SoftwareProductNavigationItems.COMPONENTS]: true,
248 [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true
249 }
250 });
251 },
252
AviZi280f8012017-06-09 02:39:56 +0300253 navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) {
254 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
255 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200256 }
AviZi280f8012017-06-09 02:39:56 +0300257
Michael Landoefa037d2017-02-19 12:57:33 +0200258};