2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 import React from 'react';
27 import ReactDOM from 'react-dom';
28 import Tabs from 'react-bootstrap/lib/Tabs.js';
29 import Overlay from 'react-bootstrap/lib/Overlay.js';
30 import Tooltip from 'react-bootstrap/lib/Tooltip.js';
32 import i18n from 'utils/i18n/i18n.js';
35 class ValidationTab extends React.Component {
38 children: React.PropTypes.node
46 const {invalidTabs} = this.state;
47 return React.cloneElement(
50 key: element.props.eventKey,
51 tabClassName: invalidTabs.indexOf(element.props.eventKey) > -1
54 onValidationStateChange: (
55 eventKey, isValid) => this.validTabStateChanged(eventKey, isValid)
60 validTabStateChanged(eventKey, isValid) {
61 let {invalidTabs} = this.state;
62 let invalidTabIndex = invalidTabs.indexOf(eventKey);
63 if (isValid && invalidTabIndex > -1) {
65 invalidTabs: invalidTabs.filter(
66 otherEventKey => eventKey !== otherEventKey)
68 } else if (!isValid && invalidTabIndex === -1) {
69 this.setState({invalidTabs: [...invalidTabs, eventKey]});
74 const {invalidTabs} = this.state;
75 return invalidTabs.length >
77 (invalidTabs.length > 1 || invalidTabs[0] !== this.props.activeKey);
83 <Tabs {...this.props} ref='tabsList'>
84 {this.props.children.map(element => this.cloneTab(element))}
88 show={this.showTabsError()}
91 let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.active):nth-of-type(n)');
92 return target && target.offsetParent ? target : undefined;
97 id='error-some-tabs-contain-errors'
98 className='validation-error-message'>
99 {i18n('One or more tabs are invalid')}