insomnia/app/components/SidebarRequestGroupRow.js
Gregory Schier 0bab94bb24 Minor things
2016-07-19 09:15:03 -07:00

69 lines
2.0 KiB
JavaScript

import React, {PropTypes} from 'react';
import classnames from 'classnames';
import RequestGroupActionsDropdown from './../containers/RequestGroupActionsDropdown';
import SidebarRequestRow from './SidebarRequestRow';
import * as db from '../database';
const SidebarRequestGroupRow = ({
children,
requestGroup,
isActive,
toggleRequestGroup,
addRequestToRequestGroup,
}) => {
let folderIconClass = 'fa-folder';
let expanded = !requestGroup.meta.collapsed;
folderIconClass += !expanded ? '' : '-open';
folderIconClass += isActive ? '' : '-o';
return (
<li key={requestGroup._id}
className={classnames('sidebar__row', {active: isActive})}>
<div className={classnames('sidebar__item sidebar__item--big', {active: isActive})}>
<button onClick={e => toggleRequestGroup(requestGroup)}>
<div className="sidebar__clickable">
<i className={'sidebar__item__icon fa ' + folderIconClass}></i>
<span>{requestGroup.name}</span>
</div>
</button>
<div className="sidebar__actions">
<button onClick={(e) => addRequestToRequestGroup(requestGroup)}>
<i className="fa fa-plus-circle"></i>
</button>
<RequestGroupActionsDropdown
requestGroup={requestGroup}
right={true}
/>
</div>
</div>
<ul className="sidebar__list">
{!expanded || children.length > 0 ? null : (
<SidebarRequestRow
activateRequest={() => {}}
isActive={false}
request={null}
requestGroup={requestGroup}
/>
)}
{expanded ? children : null}
</ul>
</li>
);
};
SidebarRequestGroupRow.propTypes = {
// Functions
toggleRequestGroup: PropTypes.func.isRequired,
addRequestToRequestGroup: PropTypes.func.isRequired,
// Other
isActive: PropTypes.bool.isRequired,
requestGroup: PropTypes.object.isRequired
};
export default SidebarRequestGroupRow;