blob: 4945d33b237a28c474de1b7ff3f85623af50bdfe [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
158 SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion});
159 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
AviZi280f8012017-06-09 02:39:56 +0300160 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200161 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version});
162 });
163 },
164
AviZi280f8012017-06-09 02:39:56 +0300165 navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) {
166 SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version});
167 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200168 },
169
AviZi280f8012017-06-09 02:39:56 +0300170 navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) {
171 SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version});
172 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200173 },
174
175 navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) {
176 if (softwareProductId) {
177 SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version});
178 }
AviZi280f8012017-06-09 02:39:56 +0300179 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200180 },
181
182 navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) {
183 if (softwareProductId) {
184 SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version});
185 }
AviZi280f8012017-06-09 02:39:56 +0300186 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200187 },
188
AviZi280f8012017-06-09 02:39:56 +0300189 navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) {
190 SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
191 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version});
192 },
193
194 navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) {
195 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
196 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version});
197 },
198
199 navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){
200 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id});
201 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200202 },
203
204 navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) {
205 if (componentId && softwareProductId) {
206 SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version});
207 }
AviZi280f8012017-06-09 02:39:56 +0300208 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200209 },
210
AviZi280f8012017-06-09 02:39:56 +0300211 navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){
212 if (componentId && softwareProductId && version) {
213 SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200214 }
AviZi280f8012017-06-09 02:39:56 +0300215 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200216 },
217
AviZi280f8012017-06-09 02:39:56 +0300218 navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) {
219 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
220 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200221 },
222
AviZi280f8012017-06-09 02:39:56 +0300223 navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) {
224 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
225 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200226 },
227
228 navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) {
229 SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version});
AviZi280f8012017-06-09 02:39:56 +0300230 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200231 },
232
233 navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) {
234 if (componentId && softwareProductId) {
235 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
Michael Landoefa037d2017-02-19 12:57:33 +0200236 }
AviZi280f8012017-06-09 02:39:56 +0300237 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200238 },
239
240 navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) {
241 this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version});
242 dispatch({
243 type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM,
244 mapOfExpandedIds: {
245 [SoftwareProductNavigationItems.COMPONENTS]: true,
246 [SoftwareProductNavigationItems.COMPONENTS + '|' + componentId]: true
247 }
248 });
249 },
250
AviZi280f8012017-06-09 02:39:56 +0300251 navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) {
252 SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version});
253 setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId});
Michael Landoefa037d2017-02-19 12:57:33 +0200254 }
AviZi280f8012017-06-09 02:39:56 +0300255
Michael Landoefa037d2017-02-19 12:57:33 +0200256};