2016-04-03 22:54:39 +00:00
|
|
|
import React, {Component, PropTypes} from 'react'
|
|
|
|
import {bindActionCreators} from 'redux'
|
|
|
|
import {connect} from 'react-redux'
|
|
|
|
import Dropdown from '../base/Dropdown'
|
|
|
|
import * as RequestActions from '../../actions/requests'
|
2016-04-08 04:05:08 +00:00
|
|
|
import * as GlobalActions from '../../actions/global'
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
class RequestActionsDropdown extends Component {
|
|
|
|
render () {
|
2016-04-05 05:35:21 +00:00
|
|
|
const {actions, request, requestGroup, buttonClassName, ...other} = this.props;
|
|
|
|
const requestGroupId = requestGroup ? requestGroup.id : null;
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
return (
|
2016-04-04 07:15:30 +00:00
|
|
|
<Dropdown {...other}>
|
|
|
|
<button className={buttonClassName}>
|
|
|
|
<i className="fa fa-gear"></i>
|
2016-04-03 22:54:39 +00:00
|
|
|
</button>
|
2016-04-04 07:15:30 +00:00
|
|
|
<ul>
|
2016-04-05 05:35:21 +00:00
|
|
|
<li>
|
|
|
|
<button onClick={e => actions.duplicateRequest(request, requestGroupId)}>
|
|
|
|
Duplicate
|
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-08 04:05:08 +00:00
|
|
|
<li>
|
|
|
|
<button onClick={e => actions.showRequestUpdateNamePrompt(request.id)}>
|
|
|
|
Rename
|
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-04 07:15:30 +00:00
|
|
|
<li><button>Export</button></li>
|
|
|
|
<li><button onClick={e => actions.deleteRequest(request.id)}>Delete</button></li>
|
2016-04-03 22:54:39 +00:00
|
|
|
</ul>
|
|
|
|
</Dropdown>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestActionsDropdown.propTypes = {
|
|
|
|
request: PropTypes.object.isRequired,
|
|
|
|
actions: PropTypes.shape({
|
|
|
|
deleteRequest: PropTypes.func.isRequired
|
2016-04-04 07:15:30 +00:00
|
|
|
}),
|
2016-04-05 05:35:21 +00:00
|
|
|
requestGroup: PropTypes.object,
|
2016-04-04 07:15:30 +00:00
|
|
|
buttonClassName: PropTypes.string
|
2016-04-03 22:54:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {actions: state.actions};
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
2016-04-08 04:05:08 +00:00
|
|
|
return {
|
|
|
|
actions: Object.assign(
|
|
|
|
{},
|
|
|
|
bindActionCreators(RequestActions, dispatch),
|
|
|
|
bindActionCreators(GlobalActions, dispatch)
|
|
|
|
)
|
|
|
|
}
|
2016-04-03 22:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(RequestActionsDropdown);
|