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 i18n from 'nfvo-utils/i18n/i18n.js';
20 import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx';
21 import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx';
22 import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx';
24 class SoftwareProductNetworksView extends React.Component {
27 networksList: PropTypes.arrayOf(PropTypes.shape({
28 id: PropTypes.string.isRequired,
29 name: PropTypes.string.isRequired,
30 dhcp: PropTypes.bool.isRequired
32 isReadOnlyMode: PropTypes.bool.isRequired
40 const {localFilter} = this.state;
41 const {isReadOnlyMode} = this.props;
44 <div className='vsp-networks-page'>
46 title={i18n('Networks')}
47 filterValue={localFilter}
48 placeholder={i18n('Filter Networks')}
49 onFilter={value => this.setState({localFilter: value})}
51 {this.filterList().map(network => this.renderNetworksListItem({network, isReadOnlyMode}))}
57 renderNetworksListItem({network, isReadOnlyMode}) {
58 let {id, name, dhcp} = network;
62 className='list-editor-item-view'
63 isReadOnlyMode={isReadOnlyMode}>
65 <ListEditorItemViewField>
66 <div className='name'>{name}</div>
67 </ListEditorItemViewField>
68 <ListEditorItemViewField>
69 <div className='details'>
70 <div className='title'>{i18n('DHCP')}</div>
71 <div className='artifact-name'>{dhcp ? i18n('YES') : i18n('NO')}</div>
73 </ListEditorItemViewField>
79 let {networksList} = this.props;
81 let {localFilter} = this.state;
82 if (localFilter.trim()) {
83 const filter = new RegExp(escape(localFilter), 'i');
84 return networksList.filter(({name = ''}) => {
85 return escape(name).match(filter);
94 export default SoftwareProductNetworksView;