From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- .../src/nfvo-components/SubmitErrorResponse.jsx | 175 ++++++++++++--------- 1 file changed, 102 insertions(+), 73 deletions(-) (limited to 'openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx') diff --git a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx index f2ec1582f3..0759f2c28d 100644 --- a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx +++ b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx @@ -1,9 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ import React, {Component} from 'react'; import ListGroupItem from 'react-bootstrap/lib/ListGroupItem.js'; -import ListGroup from 'react-bootstrap/lib/ListGroup.js'; -import Panel from 'react-bootstrap/lib/Panel.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; - +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import Icon from 'nfvo-components/icon/Icon.jsx'; +import {Collapse} from 'react-bootstrap'; /** * parsing and showing the following Java Response object * @@ -31,103 +46,117 @@ class SubmitErrorResponse extends Component { render() { - let {validationResponse} = this.props; + let {validationResponse : {vspErrors, licensingDataErrors, questionnaireValidationResult, uploadDataErrors}} = this.props; return (
- {validationResponse.vspErrors && this.renderVspErrors(validationResponse.vspErrors)} - {validationResponse.licensingDataErrors && this.renderVspErrors(validationResponse.licensingDataErrors)} - {validationResponse.compilationErrors && this.renderCompilationErrors(validationResponse.compilationErrors)} - {validationResponse.uploadDataErrors && this.renderUploadDataErrors(validationResponse.uploadDataErrors)} - {validationResponse.questionnaireValidationResult && this.renderQuestionnaireValidationResult(validationResponse.questionnaireValidationResult)} + {vspErrors && this.renderVspErrors(vspErrors)} + {licensingDataErrors && this.renderVspErrors(licensingDataErrors)} + {questionnaireValidationResult && this.renderComponentsErrors(questionnaireValidationResult)} + {uploadDataErrors && this.renderUploadDataErrors(uploadDataErrors)}
); } - renderVspErrors(vspErrors) { + renderVspErrors(errors) { return ( - {this.parseErrorCodeCollection(vspErrors)} + +
+ {errors.length && errors.map(error=>{return ();})} +
+
); } - renderLicensingDataErrors(licensingDataErrors) { + + renderComponentsErrors(errors) { return ( - {this.parseErrorCodeCollection(licensingDataErrors)} - + +
+ {errors.validationData.length && errors.validationData.map(item =>{ return ();})} +
+
); } renderUploadDataErrors(uploadDataErrors) { return ( - {this.parseMapOfErrorMessagesList(uploadDataErrors)} - + +
+ +
+
); } +} - renderCompilationErrors(compilationErrors) { - return ( - {this.parseMapOfErrorMessagesList(compilationErrors)} - - ); - } - parseErrorCodeCollection(errors) { - return ( - {errors.map(error => - -
{i18n('Category: ')}{error.category}
-
{i18n('Message: ')}{error.message}
-
- )}
- ); - } +const ComponentError = ({item}) => { + let i = 0; + return ( +
+
{item.entityName}
+ {item.errors.map(error => {return();})} +
+ ); +}; - parseMapOfErrorMessagesList(errorMap) { - return ( - - {Object.keys(errorMap).map(errorStringKey => - - {errorMap[errorStringKey].map(error => - -
{i18n('Level: ')}{error.level}
-
{i18n('Message: ')}{error.message}
-
- )}
-
- )} -
- ); +function* entries(obj) { + for (let key of Object.keys(obj)) { + yield {header: key, list: obj[key]}; } +} +const UploadErrorList = ({items}) => { + let generator = entries(items); + + let errors = []; + let i = 0; + for (let item of generator) {errors.push( +
+
{item.header}
+ {item.list.map(error => )} +
+ );} + return ( +
+ {errors} +
+ ); +}; + +class ErrorBlock extends React.Component { + state = { + collapsed: false + }; - renderQuestionnaireValidationResult(questionnaireValidationResult) { - if (!questionnaireValidationResult.valid) { - return this.parseAndRenderCompositionEntityValidationData(questionnaireValidationResult.validationData); - } - } - - parseAndRenderCompositionEntityValidationData(validationData) { - let {entityType, entityId, errors = [], subEntitiesValidationData = []} = validationData; + render() { + let {errorType, children} = this.props; return ( - - - {errors.map(error => - -
{error}
-
- )}
- {subEntitiesValidationData.map(subValidationData => this.parseAndRenderCompositionEntityValidationData(subValidationData))} -
-
+
+ {this.setState({collapsed: !this.state.collapsed});}} errorType={errorType}/> + + {children} + +
); } - - } +const ErrorHeader = ({errorType, collapsed, onClick}) => { + return( +
+ + {errorType} +
+ ); +}; + +const ErrorMessage = ({error, warning}) => { + return ( + + + + ); +}; + export default SubmitErrorResponse; -- cgit 1.2.3-korg