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'
|
|
|
|
|
|
|
|
class RequestActionsDropdown extends Component {
|
|
|
|
render () {
|
2016-04-09 21:41:27 +00:00
|
|
|
const {actions, request, requestGroup, ...other} = this.props;
|
2016-04-05 05:35:21 +00:00
|
|
|
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}>
|
2016-04-09 21:41:27 +00:00
|
|
|
<button>
|
2016-04-04 07:15:30 +00:00
|
|
|
<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)}>
|
2016-04-08 06:49:42 +00:00
|
|
|
<i className="fa fa-copy"></i> Duplicate
|
2016-04-05 05:35:21 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-08 04:05:08 +00:00
|
|
|
<li>
|
2016-04-09 19:24:33 +00:00
|
|
|
<button onClick={e => actions.showRequestUpdateNamePrompt(request)}>
|
2016-04-08 06:49:42 +00:00
|
|
|
<i className="fa fa-edit"></i> Rename
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button>
|
|
|
|
<i className="fa fa-share-square-o"></i> Export
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button onClick={e => actions.deleteRequest(request.id)}>
|
|
|
|
<i className="fa fa-trash-o"></i> Delete
|
2016-04-08 04:05:08 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
2016-04-03 22:54:39 +00:00
|
|
|
</ul>
|
|
|
|
</Dropdown>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestActionsDropdown.propTypes = {
|
|
|
|
request: PropTypes.object.isRequired,
|
|
|
|
actions: PropTypes.shape({
|
2016-04-09 21:41:27 +00:00
|
|
|
deleteRequest: PropTypes.func.isRequired,
|
|
|
|
showRequestUpdateNamePrompt: PropTypes.func.isRequired,
|
|
|
|
duplicateRequest: PropTypes.func.isRequired
|
2016-04-04 07:15:30 +00:00
|
|
|
}),
|
2016-04-09 21:41:27 +00:00
|
|
|
requestGroup: PropTypes.object
|
2016-04-03 22:54:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
2016-04-09 21:41:27 +00:00
|
|
|
return {
|
|
|
|
actions: state.actions
|
|
|
|
};
|
2016-04-03 22:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
2016-04-08 04:05:08 +00:00
|
|
|
return {
|
2016-04-09 21:41:27 +00:00
|
|
|
actions: bindActionCreators(RequestActions, dispatch)
|
2016-04-08 04:05:08 +00:00
|
|
|
}
|
2016-04-03 22:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(RequestActionsDropdown);
|