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 React, { Component } from 'react';
17 import PropTypes from 'prop-types';
19 import i18n from 'nfvo-utils/i18n/i18n.js';
20 import GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
22 import CheckboxTree from 'react-checkbox-tree';
25 check: <span className="glyphicon glyphicon-check" />,
26 uncheck: <span className="glyphicon glyphicon-unchecked" />,
27 halfCheck: <span className="glyphicon glyphicon-stop" />,
28 expandClose: <span className="glyphicon glyphicon-plus" />,
29 expandOpen: <span className="glyphicon glyphicon-minus" />,
30 expandAll: <span className="glyphicon glyphicon-collapse-down" />,
31 collapseAll: <span className="glyphicon glyphicon-collapse-up" />,
32 parentClose: <span className="glyphicon glyphicon-folder-close" />,
33 parentOpen: <span className="glyphicon glyphicon-folder-open" />,
34 leaf: <span className="glyphicon glyphicon-bookmark" />
37 class CertificationQuery extends React.Component {
40 let { certificationChecked, certificationNodes } = this.props;
43 certificationChecked === undefined ? [] : certificationChecked,
44 expanded: certificationNodes[0] ? [certificationNodes[0].value] : []
49 let { certificationNodes } = this.props;
51 expanded: certificationNodes[0] ? [certificationNodes[0].value] : []
56 this.expandFirstNode();
59 shouldComponentUpdate() {
63 componentWillReceiveProps(nextProps) {
65 nextProps.certificationChecked !== this.props.certificationChecked
67 let expand = this.state.expanded;
69 checked: nextProps.certificationChecked || [],
75 populateOptions(checkedCertificationQuery) {
76 let { flatTestsMap } = this.props;
79 {flatTestsMap[checkedCertificationQuery].title +
81 checkedCertificationQuery +
88 let { certificationNodes, setCertificationChecked } = this.props;
90 <div className="validation-setup-checkbox-tree-section">
91 <GridSection title={i18n('Certifications Query')}>
92 <GridItem colSpan={2}>
93 <div className="validation-view-title">
94 {certificationNodes[0]
95 ? certificationNodes[0].value
99 className="validation-setup-available-tests-section"
101 'vsp-validation-certifications-query-checkbox-tree'
103 {certificationNodes.length > 0 && (
105 nodes={certificationNodes}
106 checked={this.state.checked}
107 expanded={this.state.expanded}
108 onCheck={checked => {
111 setCertificationChecked({
116 onExpand={expanded =>
117 this.setState({ expanded })
120 className="field-section"
123 {certificationNodes.length === 0 && (
126 'No Certifications Query are Available'
132 <GridItem colSpan={2}>
133 {certificationNodes.length > 0 && (
135 <div className="validation-view-title">
136 {i18n('Selected Certifications Query')}
140 className="validation-setup-selected-tests"
142 {this.state.checked.map(row =>
143 this.populateOptions(row)
156 class ComplianceTests extends React.Component {
159 let { complianceChecked, complianceNodes } = this.props;
161 checked: complianceChecked === undefined ? [] : complianceChecked,
162 expanded: complianceNodes[0] ? [complianceNodes[0].value] : []
166 shouldComponentUpdate() {
171 let { complianceNodes } = this.props;
173 expanded: complianceNodes[0] ? [complianceNodes[0].value] : []
177 componentDidMount() {
178 this.expandFirstNode();
181 componentWillUnmount() {}
183 componentWillReceiveProps(nextProps) {
184 let expand = this.state.expanded;
186 if (nextProps.complianceChecked !== this.props.complianceChecked) {
188 checked: nextProps.complianceChecked || [],
194 populateOptions(checkedComplianceTests) {
195 let { flatTestsMap } = this.props;
198 {flatTestsMap[checkedComplianceTests].title +
200 checkedComplianceTests +
206 let { complianceNodes, setComplianceChecked } = this.props;
208 <div className="validation-setup-checkbox-tree-section">
209 <GridSection title={i18n('Available Tests')}>
210 <GridItem colSpan={2}>
211 <div className="validation-view-title">
212 {complianceNodes[0] && complianceNodes[0].value ? (
213 complianceNodes[0].value
219 className="validation-setup-available-tests-section"
221 'vsp-validation-compliance-checks-checkbox-tree'
223 {complianceNodes.length > 0 && (
225 nodes={complianceNodes}
226 checked={this.state.checked}
227 expanded={this.state.expanded}
228 onCheck={checked => {
231 setComplianceChecked({
236 onExpand={expanded =>
237 this.setState({ expanded })
240 className="field-section"
243 {complianceNodes.length === 0 && (
244 <div>{i18n('No Tests are Available')}</div>
248 <GridItem colSpan={2}>
249 {complianceNodes.length > 0 && (
251 <div className="validation-view-title">
252 {i18n('Selected Tests')}
256 className="validation-setup-selected-tests"
258 {this.state.checked.map(row =>
259 this.populateOptions(row)
272 class VspValidationSetup extends Component {
274 softwareProductValidation: PropTypes.object,
275 setComplianceChecked: PropTypes.func,
276 setCertificationChecked: PropTypes.func
282 complianceCheckList: [],
283 certificationCheckList: []
287 shouldComponentUpdate() {
293 softwareProductValidation,
294 setComplianceChecked,
295 setCertificationChecked,
297 certificationCheckList
300 <div className="vsp-validation-view">
302 certificationNodes={certificationCheckList}
303 flatTestsMap={softwareProductValidation.vspTestsMap}
304 setCertificationChecked={setCertificationChecked}
305 certificationChecked={
306 softwareProductValidation.certificationChecked
310 complianceNodes={complianceCheckList}
311 flatTestsMap={softwareProductValidation.vspTestsMap}
312 setComplianceChecked={setComplianceChecked}
314 softwareProductValidation.complianceChecked
322 export default VspValidationSetup;