2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import ReactDOM from 'react-dom';
19 import {default as SDCTabs} from 'sdc-ui/lib/react/Tabs.js';
20 import Overlay from 'react-bootstrap/lib/Overlay.js';
21 import Tooltip from 'react-bootstrap/lib/Tooltip.js';
23 import i18n from 'nfvo-utils/i18n/i18n.js';
26 class Tabs extends React.Component {
29 children: PropTypes.node
33 const {invalidTabs} = this.props;
34 return React.cloneElement(
37 key: element.props.tabId,
38 className: invalidTabs.indexOf(element.props.tabId) > -1 ? 'invalid-tab' : 'valid-tab'
44 const {invalidTabs} = this.props;
45 const showError = ((invalidTabs.length === 1 && invalidTabs[0] !== this.props.activeTab) || (invalidTabs.length > 1));
50 // eslint-disable-next-line no-unused-vars
51 let {invalidTabs, ...tabProps} = this.props;
54 <SDCTabs {...tabProps} ref='tabsList' id='tabsList' >
55 {this.props.children.map(element => this.cloneTab(element))}
59 show={this.showTabsError()}
62 let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)');
63 return target && target.offsetParent ? target : undefined;
67 let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)');
68 return target && target.offsetParent ? target.offsetParent : this;
71 id='error-some-tabs-contain-errors'
72 className='validation-error-message'>
73 {i18n('One or more tabs are invalid')}