2 * Copyright (c) 2019 Vodafone Group
4 * 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
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
17 import Configuration from 'sdc-app/config/Configuration.js';
18 import getValue from 'nfvo-utils/getValue.js';
19 import { actionTypes } from './SoftwareProductValidationConstants.js';
20 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
21 import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
22 import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
23 import i18n from 'nfvo-utils/i18n/i18n.js';
25 function postVSPCertificationChecks(tests) {
26 const restPrefix = Configuration.get('restPrefix');
27 return RestAPIUtil.post(
28 `${restPrefix}/v1.0/externaltesting/executions`,
33 function fetchVspChecks() {
34 const restPrefix = Configuration.get('restPrefix');
35 return RestAPIUtil.get(`${restPrefix}/v1.0/externaltesting/testcasetree`);
38 const SoftwareProductValidationActionHelper = {
39 navigateToSoftwareProductValidationResults(
41 { softwareProductId, version, status, tests }
43 postVSPCertificationChecks(tests)
46 type: actionTypes.POST_VSP_TESTS,
47 vspTestResults: response
49 ScreensHelper.loadScreen(dispatch, {
50 screen: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS,
51 screenType: screenTypes.SOFTWARE_PRODUCT,
60 let errMessage = error.message || error.responseJSON.message;
61 let title = error.responseJSON
62 ? error.responseJSON.status
65 type: modalActionTypes.GLOBAL_MODAL_ERROR,
69 cancelButtonText: i18n('OK')
75 fetchVspChecks(dispatch) {
76 return new Promise((resolve, reject) => {
80 type: actionTypes.FETCH_VSP_CHECKS,
91 setActiveTab(dispatch, { activeTab }) {
93 type: actionTypes.SET_ACTIVE_TAB,
98 onErrorThrown(dispatch, msg) {
100 type: modalActionTypes.GLOBAL_MODAL_ERROR,
102 title: i18n('Error'),
103 modalComponentName: i18n('Error'),
104 modalComponentProps: {
107 type: modalActionTypes.GLOBAL_MODAL_CLOSE
111 cancelButtonText: i18n('OK')
116 setVspTestsMap(dispatch, map) {
118 type: actionTypes.SET_VSP_TESTS_MAP,
123 setComplianceChecked(dispatch, checked) {
125 type: actionTypes.SET_COMPLIANCE_CHECKED,
126 complianceChecked: checked
130 setCertificationChecked(dispatch, checked) {
132 type: actionTypes.SET_CERTIFICATION_CHECKED,
133 certificationChecked: checked
137 setTestsRequest(dispatch, request, info) {
139 type: actionTypes.SET_TESTS_REQUEST,
140 testsRequest: request,
145 setGeneralInfo(dispatch, info) {
147 type: actionTypes.SET_GENERAL_INFO,
152 setIsVspValidationDisabled(dispatch, { isValidationDisabled }) {
154 type: actionTypes.SET_VSP_VALIDATION_DISABLED,
155 isValidationDisabled: isValidationDisabled
160 export default SoftwareProductValidationActionHelper;