From: atulpurohit Date: Tue, 5 Nov 2019 09:01:56 +0000 (+0530) Subject: Refresh option in validation result page X-Git-Tag: 1.6.1~26 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=8b346842194edb8a9e8c4cd2764ae8ebbce988f0;p=sdc.git Refresh option in validation result page Issue-ID: SDC-2585 Co-authored-by: nikhil.soni@vodafone.com Signed-off-by: atulpurohit Change-Id: I78f1385d219837c300cb33aff82b7459f137babb Signed-off-by: atulpurohit --- diff --git a/openecomp-ui/resources/scss/modules/_softwareProductValidationPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductValidationPage.scss index 3f944057cd..2be9c8a022 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductValidationPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductValidationPage.scss @@ -77,4 +77,13 @@ .validation-setup-checkbox-tree-section label { margin-bottom: 0px; } + .validation-form-content .grid-col-1 { + flex-basis: 30%; + } + .form-group input[type=file] { + border: 1px solid $light-gray; + height: 30px; + padding-top: 3px; + width: 100% + } } diff --git a/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss index 303f1f041d..d8d55ab7d3 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss @@ -18,3 +18,21 @@ width: 900px; max-width: 900px; } +.vcp-validation-refresh-btn { + float: right; + border: 1px solid $dark-gray; + width: 98px; + height: 32px; + border-radius: 2px; + padding-top: 6px; + padding-left: 10px; + margin-left: 9px; + margin-right: 10px; + .__versionControllerSync { + height: 12px; + } + &:hover:not(.disabled) { + cursor: pointer; + background-color: $tlv-light-gray; +} +} diff --git a/openecomp-ui/src/nfvo-components/input/validation/Input.jsx b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx index 16a0abc5fd..3feb06da0e 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/Input.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx @@ -105,7 +105,16 @@ class Input extends React.Component { data-test-id={this.props['data-test-id']} /> )} - + {type === 'file' && ( + this.onChangeFile(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + type={type} + data-test-id={this.props['data-test-id']} + inputRef={input => (this.input = input)} + /> + )} {type === 'textarea' && ( { + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, + { softwareProductId, version, status } + ); + }) + .catch(error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: 'ERROR', + msg: error.responseJSON.message, + cancelButtonText: i18n('OK') + } + }); + }); }, navigateToSoftwareProductDependencies( diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index 7b8c426964..dcec5c683f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -46,6 +46,7 @@ import SoftwareProductComponentsComputeFlavorListReducer from './components/comp import SoftwareProductComponentsComputeFlavorReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js'; import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js'; import SoftwareProductDependenciesReducer from './dependencies/SoftwareProductDependenciesReducer.js'; +import SoftwareProductValidationResultsViewReducer from './validationResults/SoftwareProductValidationResultsViewReducer.js'; import { createJSONSchemaReducer, createComposedJSONSchemaReducer @@ -78,6 +79,9 @@ export default combineReducers({ softwareProductValidation: createPlainDataReducer( SoftwareProductValidationReducer ), + softwareProductValidationResult: createPlainDataReducer( + SoftwareProductValidationResultsViewReducer + ), softwareProductProcesses: combineReducers({ processesList: SoftwareProductProcessesListReducer, processesEditor: createPlainDataReducer( diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js index a6237e878a..27d9b5ebf8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js @@ -30,14 +30,21 @@ export const mapActionsToProps = dispatch => { SoftwareProductValidationActionHelper.onErrorThrown(dispatch, msg); }, - onTestSubmit: (softwareProductId, version, status, tests) => { + onTestSubmit: ( + softwareProductId, + version, + status, + tests, + requestId + ) => { SoftwareProductValidationActionHelper.navigateToSoftwareProductValidationResults( dispatch, { softwareProductId, version, status, - tests + tests, + requestId } ); }, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js index 1ebb94b77c..fc6de3e2eb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js @@ -15,18 +15,40 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import getValue from 'nfvo-utils/getValue.js'; import { actionTypes } from './SoftwareProductValidationConstants.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -function postVSPCertificationChecks(tests) { +function createCertificationFormData(tests) { + var formData = new FormData(); + var testData = []; + for (var test of tests) { + if (test.files) { + for (var file of test.files) { + formData.append('files', file.file, file.name); + } + } + delete test.files; + testData.push(test); + } + formData.append('testdata', JSON.stringify(testData)); + + return formData; +} +function postVSPCertificationChecks( + tests, + version, + softwareProductId, + requestId +) { const restPrefix = Configuration.get('restPrefix'); + var id = version.id; + var formData = createCertificationFormData(tests); return RestAPIUtil.post( - `${restPrefix}/v1.0/externaltesting/executions`, - getValue(tests) + `${restPrefix}/v1.0/externaltesting/executions?vspId=${softwareProductId}&vspVersionId=${id}&requestId=${requestId}`, + formData ); } @@ -35,41 +57,59 @@ function fetchVspChecks() { return RestAPIUtil.fetch(`${restPrefix}/v1.0/externaltesting/testcasetree`); } +function extractEndPoint(tests) { + return [...new Set(tests.map(test => test.endpoint))]; +} const SoftwareProductValidationActionHelper = { navigateToSoftwareProductValidationResults( dispatch, - { softwareProductId, version, status, tests } + { softwareProductId, version, status, tests, requestId } ) { - postVSPCertificationChecks(tests) - .then(response => { - dispatch({ - type: actionTypes.POST_VSP_TESTS, - vspTestResults: response - }); - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, - screenType: screenTypes.SOFTWARE_PRODUCT, - props: { - softwareProductId, - version, - status - } - }); - }) - .catch(error => { - let errMessage = error.message || error.responseJSON.message; - let title = error.responseJSON - ? error.responseJSON.status - : i18n('Error'); - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: title, - msg: errMessage, - cancelButtonText: i18n('OK') - } + return new Promise((resolve, reject) => { + postVSPCertificationChecks( + tests, + version, + softwareProductId, + requestId + ) + .then(response => { + var testResultKeys = {}; + testResultKeys.endPoints = extractEndPoint(tests); + testResultKeys.requestId = requestId; + dispatch({ + type: actionTypes.POST_VSP_TESTS, + vspTestResults: response, + testResultKeys: testResultKeys + }); + ScreensHelper.loadScreen(dispatch, { + screen: + enums.SCREEN.SOFTWARE_PRODUCT_VALIDATION_RESULTS, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version, + status + } + }); + resolve(response); + }) + .catch(error => { + let errMessage = + error.message || error.responseJSON.message; + let title = error.responseJSON + ? error.responseJSON.status + : i18n('Error'); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: title, + msg: errMessage, + cancelButtonText: i18n('OK') + } + }); + reject(error); }); - }); + }); }, fetchVspChecks(dispatch) { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js index 4513e23205..4a7f257e73 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationReducer.js @@ -20,7 +20,8 @@ export default (state = {}, action) => { case actionTypes.POST_VSP_TESTS: return { ...state, - vspTestResults: action.vspTestResults + vspTestResults: action.vspTestResults, + testResultKeys: action.testResultKeys }; case actionTypes.FETCH_VSP_CHECKS: return { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx index fac69616bb..36cc7c7672 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx @@ -15,7 +15,7 @@ */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; - +import Configuration from 'sdc-app/config/Configuration.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import { Button } from 'onap-ui-react'; import { Tab, Tabs } from 'onap-ui-react'; @@ -74,7 +74,9 @@ class SoftwareProductValidation extends Component { buildChildElements(setItem, testScenario) { let parentElement = {}; parentElement.value = setItem.name; - parentElement.label = setItem.description; + parentElement.label = setItem.description + ? setItem.description + : setItem.name; parentElement.children = []; if (setItem.children !== undefined) { setItem.children.forEach(element => { @@ -89,11 +91,13 @@ class SoftwareProductValidation extends Component { } if (setItem.tests !== undefined) { setItem.tests.forEach(element => { - parentElement.children.push({ - value: element.testCaseName, - label: element.description - }); - this.setMapAndGeneralData(element, testScenario); + if (element.inputs) { + parentElement.children.push({ + value: element.testCaseName, + label: element.testCaseName + }); + this.setMapAndGeneralData(element, testScenario); + } }); } return parentElement; @@ -115,6 +119,8 @@ class SoftwareProductValidation extends Component { parentNode.children.push({ value: element.testCaseName, label: element.description + ? element.description + : element.testCaseName }); this.setMapAndGeneralData(element, scenario); }); @@ -129,10 +135,11 @@ class SoftwareProductValidation extends Component { let certificationList = []; let { setVspTestsMap } = this.props; if (Object.keys(res).length !== 0 && res.children) { + let allTestScenario = Configuration.get('allTestScenario'); res.children.forEach(element => { if (element.name === 'certification') { certificationData = element; - } else if (element.name === 'compliance') { + } else if (element.name === allTestScenario) { complianceData = element; } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx index 8888c92f6d..cda3fe2c92 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx @@ -15,7 +15,7 @@ */ import React, { Component } from 'react'; import PropTypes from 'prop-types'; - +import UUID from 'uuid-js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import { Button } from 'onap-ui-react'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; @@ -35,23 +35,51 @@ class VspInputs extends React.Component { changeInputs(e, check, parameterName) { let { testsRequest, generalInfo, setTestsRequest } = this.props; - testsRequest[check].parameters[parameterName] = e; + if (e instanceof File) { + var timestamp = new Date().getTime(); + var fileExtension = ( + e.name.match(/[^\\\/]\.([^.\\\/]+)$/) || [null] + ).pop(); + var fileName = fileExtension + ? timestamp + '.' + fileExtension + : timestamp; + testsRequest[check].parameters[parameterName] = + 'file://' + fileName; + + testsRequest[check].files = testsRequest[check].files + ? testsRequest[check].files + : []; + testsRequest[check].files.push({ file: e, name: fileName }); + } else { + testsRequest[check].parameters[parameterName] = e; + } + generalInfo[check][parameterName] = { isValid: true, errorText: '' }; setTestsRequest(testsRequest, generalInfo); } - renderInputs(check) { + renderInputs(check, indexKey) { let { vspTestsMap, testsRequest, generalInfo } = this.props; return ( -
+
{vspTestsMap[check].parameters.map((parameter, index) => { + parameter.metadata = parameter.metadata + ? parameter.metadata + : {}; + if ( + !this.props.filterField(parameter) || + parameter.metadata.hidden + ) { + return; + } if ( - parameter.type === 'text' && - !parameter.metadata.hidden + parameter.type === 'text' || + parameter.type === 'string' || + parameter.type === 'json' ) { return ( @@ -112,6 +140,31 @@ class VspInputs extends React.Component { ); + } else if (parameter.type === 'binary') { + return ( + + { + this.changeInputs( + e.target ? e.target.value : e, + check, + parameter.name + ); + }} + /> + + ); } })} @@ -127,18 +180,18 @@ class VspInputs extends React.Component { } = this.props; return (
- {complianceChecked.map(complianceCheck => { + {complianceChecked.map((complianceCheck, index) => { if (vspTestsMap[complianceCheck].parameters.length === 0) { return
; } else { - return this.renderInputs(complianceCheck); + return this.renderInputs(complianceCheck, index); } })} - {certificationChecked.map(certificateCheck => { + {certificationChecked.map((certificateCheck, index) => { if (vspTestsMap[certificateCheck].parameters.length === 0) { return
; } else { - return this.renderInputs(certificateCheck); + return this.renderInputs(certificateCheck, index); } })}
@@ -159,7 +212,19 @@ class VspValidationInputs extends Component { shouldComponentUpdate() { return true; } - + filterField(parameter) { + if ( + parameter.name === 'host-username' || + parameter.name === 'vsp' || + parameter.name === 'vsp-zip' || + parameter.name === 'host-password' || + parameter.name === 'host-url' + ) { + return false; + } else { + return true; + } + } validateInputs() { let areInputsValid = true; let { softwareProductValidation, setGeneralInfo } = this.props; @@ -178,43 +243,57 @@ class VspValidationInputs extends Component { ); let isParameterValid = true; let errorText = ''; - if ( - parameter.type === 'text' && - parameter.metadata.choices - ) { - if ( - !parameter.isOptional && - !requestParameters[parameterName] - ) { - isParameterValid = false; - errorText = i18n('Field is required'); - } - } else if (parameter.type === 'text') { + if (!this.filterField(parameter)) { + // Not required any action + } else { if ( - !parameter.isOptional && - !requestParameters[parameterName] + (parameter.type === 'text' || + parameter.type === 'string') && + parameter.metadata.choices ) { - isParameterValid = false; - errorText = i18n('Field is required'); + if ( + !parameter.isOptional && + !requestParameters[parameterName] + ) { + isParameterValid = false; + errorText = i18n('Field is required'); + } } else if ( - (!parameter.isOptional && - !requestParameters[parameterName]) || - (parameter.metadata.maxLength && - requestParameters[parameterName].length > - parseInt(parameter.metadata.maxLength)) || - (parameter.metadata.minLength && - requestParameters[parameterName].length < - parseInt(parameter.metadata.minLength) && - requestParameters[parameterName].length > 0) + parameter.type === 'text' || + parameter.type === 'string' || + parameter.type === 'json' || + parameter.type === 'binary' ) { - isParameterValid = false; - errorText = i18n( - 'Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters', - { - minLength: parameter.metadata.minLength, - maxLength: parameter.metadata.maxLength - } - ); + if ( + !parameter.isOptional && + !requestParameters[parameterName] + ) { + isParameterValid = false; + errorText = i18n('Field is required'); + } else if ( + (!parameter.isOptional && + !requestParameters[parameterName]) || + (parameter.metadata.maxLength && + requestParameters[parameterName].length > + parseInt( + parameter.metadata.maxLength + )) || + (parameter.metadata.minLength && + requestParameters[parameterName].length < + parseInt( + parameter.metadata.minLength + ) && + requestParameters[parameterName].length > 0) + ) { + isParameterValid = false; + errorText = i18n( + 'Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters', + { + minLength: parameter.metadata.minLength, + maxLength: parameter.metadata.maxLength + } + ); + } } } generalInfo[testCaseName][ @@ -244,13 +323,22 @@ class VspValidationInputs extends Component { } = this.props; Object.keys(softwareProductValidation.testsRequest).forEach(key => { - tests.push(softwareProductValidation.testsRequest[key]); + var testReq = softwareProductValidation.testsRequest[key]; + this.removeParameterFromTest(testReq); + tests.push(testReq); }); if (this.validateInputs()) { - onTestSubmit(softwareProductId, version, status, tests); + var requestId = UUID.create() + .toString() + .split('-')[0]; + onTestSubmit(softwareProductId, version, status, tests, requestId); } } - + removeParameterFromTest(testReq) { + delete testReq.parameters['host-username']; + delete testReq.parameters['host-password']; + delete testReq.parameters['host-url']; + } prepareDataForVspInputs() { let { setTestsRequest } = this.props; let { @@ -279,7 +367,10 @@ class VspValidationInputs extends Component { isValid={true} onSubmit={() => this.performVSPTests()} isReadOnlyMode={false}> - +