insomnia/app/components/dropdowns/RequestActionsDropdown.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

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-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-04 07:15:30 +00:00
<li><button>Rename</button></li>
<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) {
return {actions: bindActionCreators(RequestActions, dispatch)}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(RequestActionsDropdown);