insomnia/app/components/SidebarRequestGroupRow.js

69 lines
2.0 KiB
JavaScript
Raw Normal View History

import React, {PropTypes} from 'react';
import classnames from 'classnames';
2016-07-08 06:02:40 +00:00
import RequestGroupActionsDropdown from './../containers/RequestGroupActionsDropdown';
import SidebarRequestRow from './SidebarRequestRow';
import * as db from '../database';
2016-04-29 04:57:03 +00:00
const SidebarRequestGroupRow = ({
children,
requestGroup,
isActive,
toggleRequestGroup,
2016-07-08 06:02:40 +00:00
addRequestToRequestGroup,
2016-04-29 04:57:03 +00:00
}) => {
2016-04-29 03:37:49 +00:00
let folderIconClass = 'fa-folder';
2016-07-19 16:15:03 +00:00
let expanded = !requestGroup.meta.collapsed;
2016-04-29 03:37:49 +00:00
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})}>
2016-07-08 06:02:40 +00:00
<button onClick={e => toggleRequestGroup(requestGroup)}>
<div className="sidebar__clickable">
<i className={'sidebar__item__icon fa ' + folderIconClass}></i>
<span>{requestGroup.name}</span>
</div>
2016-05-01 19:56:30 +00:00
</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>
</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;