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 Button from 'sdc-ui/lib/react/Button.js';
19 import classnames from 'classnames';
20 import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx';
22 const ListEditorHeader = ({onAdd, isReadOnlyMode, title, plusButtonTitle}) => {
24 <div className='list-editor-view-header'>
25 {title && <div className='list-editor-view-title'>{title}</div>}
28 <Button data-test-id='add-button' iconName='plusThin' btnType='link' onClick={onAdd} disabled={isReadOnlyMode === true}>{plusButtonTitle}</Button>
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: PropTypes.string,
65 plusButtonTitle: PropTypes.string,
66 children: PropTypes.node,
67 filterValue: PropTypes.string,
68 onFilter: PropTypes.func,
69 className: PropTypes.string,
70 isReadOnlyMode: PropTypes.bool,
71 placeholder: PropTypes.string,
72 twoColumns: 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;