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 classnames from 'classnames';
18 import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx';
20 const ListEditorHeader = ({onAdd, isReadOnlyMode, title, plusButtonTitle}) => {
22 <div className='list-editor-view-header'>
23 {title && <div className='list-editor-view-title'>{title}</div>}
24 <div className={`list-editor-view-add-controller${isReadOnlyMode ? ' disabled' : ''}`}>
26 <div className='list-editor-view-add-title' data-test-id='add-button' onClick={onAdd}>
27 <span>{`+ ${plusButtonTitle}`}</span>
35 const ListEditorScroller = ({children, twoColumns}) => {
37 <div className='list-editor-view-list-scroller'>
38 <div className={classnames('list-editor-view-list', {'two-columns': twoColumns})}>
45 const FilterWrapper = ({onFilter, filterValue}) => {
47 <div className='expandble-search-wrapper'>
56 class ListEditorView extends React.Component {
58 static defaultProps = {
64 title: React.PropTypes.string,
65 plusButtonTitle: React.PropTypes.string,
66 children: React.PropTypes.node,
67 filterValue: React.PropTypes.string,
68 onFilter: React.PropTypes.func,
69 className: React.PropTypes.string,
70 isReadOnlyMode: React.PropTypes.bool,
71 placeholder: React.PropTypes.string,
72 twoColumns: React.PropTypes.bool
76 let {title, plusButtonTitle, onAdd, children, onFilter, className, isReadOnlyMode, twoColumns, filterValue} = this.props;
78 <div className={classnames('list-editor-view', className)}>
79 <ListEditorHeader onAdd={onAdd} isReadOnlyMode={isReadOnlyMode} plusButtonTitle={plusButtonTitle} title={title}/>
80 {onFilter && (children.length || filterValue) && <FilterWrapper onFilter={onFilter} filterValue={filterValue}/>}
81 <ListEditorScroller children={children} twoColumns={twoColumns}/>
87 export default ListEditorView;