insomnia/app/components/SidebarRequestGroupRow.js

67 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
return (
2016-05-01 19:56:30 +00:00
<li key={requestGroup._id}
className={classnames('sidebar__row', {active: isActive})}>
<div className={classnames('sidebar__item sidebar__item--big', {active: isActive})}>
<button className="sidebar__clickable" onClick={e => toggleRequestGroup(requestGroup)}>
<i className={'fa ' + folderIconClass}></i>
&nbsp;&nbsp;&nbsp;{requestGroup.name}
</button>
<div className="sidebar__actions">
2016-04-29 03:37:49 +00:00
<button onClick={(e) => addRequestToRequestGroup(requestGroup)}>
<i className="fa fa-plus-circle"></i>
</button>
<RequestGroupActionsDropdown
requestGroup={requestGroup}
right={true}
2016-05-01 19:56:30 +00:00
/>
2016-04-29 03:37:49 +00:00
</div>
2016-05-01 19:56:30 +00:00
2016-04-29 03:37:49 +00:00
</div>
2016-05-01 19:56:30 +00:00
<ul className="sidebar__list">
2016-04-29 03:37:49 +00:00
{!expanded || children.length > 0 ? null : (
<SidebarRequestRow
activateRequest={() => {}}
isActive={false}
request={null}
2016-06-18 21:31:17 +00:00
requestGroup={requestGroup}
2016-04-29 03:37:49 +00:00
/>
)}
{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;