blob: 17d8a17c09ac47e488b704a00308ac071e0ab6e8 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001import React from 'react';
2import SVGIcon from '../icon/SVGIcon.jsx';
3import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js';
4import Tooltip from 'react-bootstrap/lib/Tooltip.js';
5
6function tooltip (msg) {
7 return (
8 <Tooltip className='select-action-table-error-tooltip' id='error-tooltip'>{msg}</Tooltip>
9 );
10};
11
12const IconWithOverlay = ({overlayMsg}) => (
13 <OverlayTrigger placement='bottom' overlay={tooltip(overlayMsg)}>
14 <SVGIcon name='error-circle'/>
15 </OverlayTrigger>
16);
17
18const SelectActionTableRow = ({children, onDelete, hasError, overlayMsg}) => (
19 <div className='select-action-table-row-wrapper'>
20 <div className={`select-action-table-row ${hasError ? 'has-error' : ''}`}>
21 {children}
22 </div>
23 {onDelete ? <SVGIcon name='trash-o' data-test-id='select-action-table-delete' onClick={onDelete} /> : <SVGIcon name='angle-left' className='dummy-icon' />}
24 {hasError ? overlayMsg ? <IconWithOverlay overlayMsg={overlayMsg}/> : <SVGIcon name='error-circle'/>
25 : hasError === undefined ? <SVGIcon name='angle-left' className='dummy-icon'/> : <SVGIcon name='check-circle'/>}
26
27 </div>
28);
29
30export default SelectActionTableRow;