diff options
author | atulpurohit <atul.purohit1@vodafone.com> | 2019-11-05 14:31:56 +0530 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-01-13 09:33:40 +0000 |
commit | 8b346842194edb8a9e8c4cd2764ae8ebbce988f0 (patch) | |
tree | 3ea20981d4cdd5858c4a99eb49c0370503c3c6cb /openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx | |
parent | 0ef638b2eb44c9f473e5ad8bea119845d968fde7 (diff) |
Refresh option in validation result page
Issue-ID: SDC-2585
Co-authored-by: nikhil.soni@vodafone.com
Signed-off-by: atulpurohit <atul.purohit1@vodafone.com>
Change-Id: I78f1385d219837c300cb33aff82b7459f137babb
Signed-off-by: atulpurohit <atul.purohit1@vodafone.com>
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx')
-rw-r--r-- | openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx | 189 |
1 files changed, 140 insertions, 49 deletions
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 ( - <div className="div-clear-both"> + <div key={indexKey} className="div-clear-both"> <GridSection title={i18n('{title} Inputs :', { - title: vspTestsMap[check].title + title: vspTestsMap[check].title.split(/\r?\n/)[0] })}> {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 ( <GridItem key={index}> @@ -112,6 +140,31 @@ class VspInputs extends React.Component { </Input> </GridItem> ); + } else if (parameter.type === 'binary') { + return ( + <GridItem key={index}> + <Input + label={parameter.description} + type="file" + isRequired={!parameter.isOptional} + isValid={ + generalInfo[check][parameter.name] + .isValid + } + errorText={ + generalInfo[check][parameter.name] + .errorText + } + onChange={e => { + this.changeInputs( + e.target ? e.target.value : e, + check, + parameter.name + ); + }} + /> + </GridItem> + ); } })} </GridSection> @@ -127,18 +180,18 @@ class VspInputs extends React.Component { } = this.props; return ( <div> - {complianceChecked.map(complianceCheck => { + {complianceChecked.map((complianceCheck, index) => { if (vspTestsMap[complianceCheck].parameters.length === 0) { return <div />; } else { - return this.renderInputs(complianceCheck); + return this.renderInputs(complianceCheck, index); } })} - {certificationChecked.map(certificateCheck => { + {certificationChecked.map((certificateCheck, index) => { if (vspTestsMap[certificateCheck].parameters.length === 0) { return <div />; } else { - return this.renderInputs(certificateCheck); + return this.renderInputs(certificateCheck, index); } })} </div> @@ -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}> - <VspInputs {...this.prepareDataForVspInputs()} /> + <VspInputs + {...this.prepareDataForVspInputs()} + filterField={this.filterField} + /> <Button size="default" data-test-id="proceed-to-validation-results-btn" |