insomnia/app/components/dropdowns/RequestActionsDropdown.js

47 lines
1.2 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-04 07:15:30 +00:00
const {actions, request, buttonClassName, ...other} = this.props;
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>
<li><button>Duplicate</button></li>
<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
}),
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);