insomnia/app/components/SidebarRequestGroupRow.js

68 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-04-29 03:37:49 +00:00
import React, {PropTypes} from 'react'
import classnames from 'classnames'
import RequestGroupActionsDropdown from './../containers/RequestGroupActionsDropdown'
import SidebarRequestRow from './SidebarRequestRow'
2016-04-29 04:57:03 +00:00
const SidebarRequestGroupRow = ({
children,
requestGroup,
isActive,
toggleRequestGroup,
addRequestToRequestGroup
}) => {
2016-04-29 03:37:49 +00:00
let folderIconClass = 'fa-folder';
let expanded = !requestGroup.collapsed;
folderIconClass += !expanded ? '' : '-open';
folderIconClass += isActive ? '' : '-o';
2016-04-29 03:37:49 +00:00
const sidebarItemClassNames = classnames(
'sidebar__item',
'sidebar__item--bordered',
{'sidebar__item--active': isActive}
);
2016-04-29 03:37:49 +00:00
return (
<li key={requestGroup._id}>
<div className={sidebarItemClassNames}>
<div className="sidebar__item__row sidebar__item__row--heading">
<button onClick={e => toggleRequestGroup(requestGroup)}>
<i className={'fa ' + folderIconClass}></i>
&nbsp;&nbsp;&nbsp;{requestGroup.name}
</button>
</div>
2016-04-29 03:37:49 +00:00
<div className="sidebar__item__btn grid">
<button onClick={(e) => addRequestToRequestGroup(requestGroup)}>
<i className="fa fa-plus-circle"></i>
</button>
<RequestGroupActionsDropdown
requestGroup={requestGroup}
right={true}
className="tall"/>
</div>
</div>
<ul>
{!expanded || children.length > 0 ? null : (
<SidebarRequestRow
activateRequest={() => {}}
isActive={false}
request={null}
/>
)}
{expanded ? children : null}
</ul>
</li>
);
};
SidebarRequestGroupRow.propTypes = {
// Functions
toggleRequestGroup: PropTypes.func.isRequired,
addRequestToRequestGroup: PropTypes.func.isRequired,
2016-04-29 03:37:49 +00:00
// Other
isActive: PropTypes.bool.isRequired,
requestGroup: PropTypes.object.isRequired
};
export default SidebarRequestGroupRow;