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';
24 class SoftwareProductProcessesListView extends React.Component {
31 onAddProcess: PropTypes.func.isRequired,
32 onEditProcess: PropTypes.func.isRequired,
33 onDeleteProcess: PropTypes.func.isRequired,
34 isReadOnlyMode: PropTypes.bool.isRequired,
35 currentSoftwareProduct:PropTypes.object,
36 addButtonTitle: PropTypes.string
40 const {localFilter} = this.state;
41 let {onAddProcess, isReadOnlyMode, addButtonTitle} = this.props;
45 plusButtonTitle={addButtonTitle}
46 filterValue={localFilter}
47 placeholder={i18n('Filter Process')}
49 isReadOnlyMode={isReadOnlyMode}
50 title={i18n('Process Details')}
51 onFilter={value => this.setState({localFilter: value})}>
52 {this.filterList().map(processes => this.renderProcessListItem(processes, isReadOnlyMode))}
56 renderProcessListItem(process, isReadOnlyMode) {
57 let {id, name, description, artifactName = ''} = process;
58 let {currentSoftwareProduct: {version}, onEditProcess, onDeleteProcess} = this.props;
62 className='list-editor-item-view'
63 isReadOnlyMode={isReadOnlyMode}
64 onSelect={() => onEditProcess(process)}
65 onDelete={() => onDeleteProcess(process, version)}>
67 <div className='list-editor-item-view-field'>
68 <div className='title'>{i18n('Name')}</div>
69 <div className='name'>{name}</div>
71 <div className='list-editor-item-view-field'>
72 <div className='title'>{i18n('Artifact name')}</div>
73 <div className='artifact-name'>{artifactName}</div>
75 <div className='list-editor-item-view-field'>
76 <div className='title'>{i18n('Notes')}</div>
77 <div className='description'>{description}</div>
84 let {processesList} = this.props;
85 let {localFilter} = this.state;
87 if (localFilter.trim()) {
88 const filter = new RegExp(escape(localFilter), 'i');
89 return processesList.filter(({name = '', description = ''}) => {
90 return escape(name).match(filter) || escape(description).match(filter);
99 export default SoftwareProductProcessesListView;