2017-11-07 18:16:42 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* InputSearchLi
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-12-04 15:03:53 +01:00
|
|
|
import { router } from 'app';
|
2017-11-07 18:16:42 +01:00
|
|
|
import styles from './styles.scss';
|
|
|
|
|
2017-11-23 13:09:05 +01:00
|
|
|
function InputSearchLi({ onClick, isAdding, item }) {
|
|
|
|
const icon = isAdding ? 'fa-plus' : 'fa-minus-circle';
|
2017-11-29 12:36:35 +01:00
|
|
|
const liStyle = isAdding ? { cursor: 'pointer' } : {};
|
|
|
|
const handleClick = isAdding ? () => onClick(item) : () => {};
|
2017-12-04 15:03:53 +01:00
|
|
|
const path = `/plugins/content-manager/user/${item.id}?redirectUrl=/plugins/content-manager/user/?page=1&limit=20&sort=id&source=users-permissions`;
|
|
|
|
const handleGoto = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
router.push(path);
|
|
|
|
};
|
2017-11-23 13:09:05 +01:00
|
|
|
|
2017-11-07 18:16:42 +01:00
|
|
|
return (
|
2017-11-29 12:36:35 +01:00
|
|
|
<li className={styles.li} style={liStyle} onClick={handleClick}>
|
2017-11-07 18:16:42 +01:00
|
|
|
<div>
|
2017-12-04 15:03:53 +01:00
|
|
|
<div className={styles.container}>
|
2017-11-27 14:26:54 +01:00
|
|
|
{item.username}
|
2017-12-04 15:03:53 +01:00
|
|
|
<i className="fa fa-external-link" onClick={handleGoto} />
|
2017-11-07 18:16:42 +01:00
|
|
|
</div>
|
2017-11-29 12:36:35 +01:00
|
|
|
<div
|
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
onClick(item);
|
|
|
|
}}
|
|
|
|
>
|
2017-11-23 13:09:05 +01:00
|
|
|
<i className={`fa ${icon}`} />
|
2017-11-07 18:16:42 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputSearchLi.defaultProps = {
|
|
|
|
item: {
|
|
|
|
name: '',
|
2017-11-08 16:06:21 +01:00
|
|
|
},
|
|
|
|
};
|
2017-11-07 18:16:42 +01:00
|
|
|
|
2017-11-08 16:06:21 +01:00
|
|
|
InputSearchLi.propTypes = {
|
2017-11-23 13:09:05 +01:00
|
|
|
isAdding: PropTypes.bool.isRequired,
|
2017-11-07 18:16:42 +01:00
|
|
|
item: PropTypes.object,
|
2017-11-23 13:09:05 +01:00
|
|
|
onClick: PropTypes.func.isRequired,
|
2017-11-07 18:16:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default InputSearchLi;
|