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 classnames from 'classnames';
19 import i18n from 'nfvo-utils/i18n/i18n.js';
20 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
21 import store from 'sdc-app/AppStore.js';
22 import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js';
24 class ListEditorItem extends React.Component {
26 onSelect: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
27 onDelete: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
28 onEdit: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
29 children: PropTypes.node,
30 isReadOnlyMode: PropTypes.bool
34 let {onDelete, onSelect, onEdit, children, isReadOnlyMode} = this.props;
35 let isAbilityToDelete = isReadOnlyMode === undefined ? true : !isReadOnlyMode;
37 <div className={classnames('list-editor-item-view', {'selectable': Boolean(onSelect)})} data-test-id='list-editor-item'>
38 <div className='list-editor-item-view-content' onClick={onSelect}>
41 {(onEdit || onDelete) && <div className='list-editor-item-view-controller'>
42 {onEdit && <SVGIcon name='sliders' onClick={() => this.onClickedItem(onEdit)}/>}
43 {onDelete && isAbilityToDelete && <SVGIcon name='trashO' data-test-id='delete-list-item' onClick={() => this.onClickedItem(onDelete)}/>}
49 onClickedItem(callBackFunc) {
50 if(typeof callBackFunc === 'function') {
51 let {isCheckedOut} = this.props;
52 if (isCheckedOut === false) {
54 type: modalActionTypes.GLOBAL_MODAL_WARNING,
57 msg: i18n('This item is checkedin/submitted, Click Check Out to continue')
68 export default ListEditorItem;