AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame^] | 1 | import React from 'react'; |
| 2 | import SVGIcon from '../icon/SVGIcon.jsx'; |
| 3 | import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; |
| 4 | import Tooltip from 'react-bootstrap/lib/Tooltip.js'; |
| 5 | |
| 6 | function tooltip (msg) { |
| 7 | return ( |
| 8 | <Tooltip className='select-action-table-error-tooltip' id='error-tooltip'>{msg}</Tooltip> |
| 9 | ); |
| 10 | }; |
| 11 | |
| 12 | const IconWithOverlay = ({overlayMsg}) => ( |
| 13 | <OverlayTrigger placement='bottom' overlay={tooltip(overlayMsg)}> |
| 14 | <SVGIcon name='error-circle'/> |
| 15 | </OverlayTrigger> |
| 16 | ); |
| 17 | |
| 18 | const 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 | |
| 30 | export default SelectActionTableRow; |