2016-04-29 03:37:49 +00:00
|
|
|
import React, {PropTypes} from 'react'
|
2016-05-01 19:56:30 +00:00
|
|
|
import classnames from 'classnames'
|
|
|
|
|
2016-04-26 07:29:24 +00:00
|
|
|
import RequestActionsDropdown from './../containers/RequestActionsDropdown'
|
|
|
|
import MethodTag from './MethodTag'
|
2016-06-18 21:31:17 +00:00
|
|
|
import * as db from '../database'
|
2016-04-26 07:29:24 +00:00
|
|
|
|
2016-05-01 19:56:30 +00:00
|
|
|
const SidebarRequestRow = ({request, requestGroup, isActive, activateRequest}) => {
|
|
|
|
if (!request) {
|
|
|
|
return (
|
|
|
|
<li className="sidebar__item">
|
2016-06-18 21:31:17 +00:00
|
|
|
<button className="sidebar__clickable"
|
|
|
|
onClick={() => db.requestCreate({parentId: requestGroup._id})}>
|
|
|
|
<em>click to add first request...</em>
|
|
|
|
</button>
|
2016-05-01 19:56:30 +00:00
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<li className="sidebar__row">
|
|
|
|
|
|
|
|
<div className={classnames('sidebar__item', {active: isActive})}>
|
|
|
|
<button className="sidebar__clickable" onClick={() => {activateRequest(request)}}>
|
|
|
|
<MethodTag method={request.method}/> {request.name}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<div className="sidebar__actions">
|
|
|
|
<RequestActionsDropdown
|
|
|
|
right={true}
|
|
|
|
request={request}
|
|
|
|
requestGroup={requestGroup}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2016-04-29 03:37:49 +00:00
|
|
|
</div>
|
2016-05-01 19:56:30 +00:00
|
|
|
</li>
|
|
|
|
)
|
|
|
|
};
|
2016-04-26 07:29:24 +00:00
|
|
|
|
|
|
|
SidebarRequestRow.propTypes = {
|
|
|
|
// Functions
|
|
|
|
activateRequest: PropTypes.func.isRequired,
|
2016-04-29 03:37:49 +00:00
|
|
|
|
2016-04-26 07:29:24 +00:00
|
|
|
// Other
|
|
|
|
isActive: PropTypes.bool.isRequired,
|
2016-04-29 03:37:49 +00:00
|
|
|
|
2016-04-26 07:29:24 +00:00
|
|
|
// Optional
|
|
|
|
requestGroup: PropTypes.object,
|
|
|
|
request: PropTypes.object
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SidebarRequestRow;
|