insomnia/app/containers/RequestGroupActionsDropdown.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-04-09 21:41:27 +00:00
import React, {Component, PropTypes} from 'react'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
2016-04-23 06:16:23 +00:00
import Dropdown from '../components/base/Dropdown'
import * as RequestGroupActions from '../redux/modules/requestGroups'
import * as db from '../database'
2016-04-09 21:41:27 +00:00
class RequestGroupActionsDropdown extends Component {
render () {
const {actions, requestGroup, ...other} = this.props;
return (
<Dropdown {...other}>
<button>
<i className="fa fa-caret-down"></i>
</button>
<ul>
<li>
2016-04-16 23:24:57 +00:00
<button onClick={e => actions.showUpdateNamePrompt(requestGroup)}>
2016-04-09 21:41:27 +00:00
<i className="fa fa-edit"></i> Rename
</button>
</li>
2016-04-15 02:13:49 +00:00
<li>
<button onClick={e => actions.showEnvironmentEditModal(requestGroup)}>
2016-04-15 02:13:49 +00:00
<i className="fa fa-code"></i> Environment
</button>
</li>
2016-04-09 21:41:27 +00:00
<li>
2016-04-16 23:24:57 +00:00
<button onClick={e => db.remove(requestGroup)}>
2016-04-09 21:41:27 +00:00
<i className="fa fa-trash-o"></i> Delete
</button>
</li>
</ul>
</Dropdown>
)
}
}
RequestGroupActionsDropdown.propTypes = {
actions: PropTypes.shape({
2016-04-16 23:24:57 +00:00
update: PropTypes.func.isRequired,
remove: PropTypes.func.isRequired,
showUpdateNamePrompt: PropTypes.func.isRequired,
showEnvironmentEditModal: PropTypes.func.isRequired
2016-04-09 21:41:27 +00:00
}),
requestGroup: PropTypes.object
};
function mapStateToProps (state) {
return {actions: state.actions};
}
function mapDispatchToProps (dispatch) {
return {
actions: bindActionCreators(RequestGroupActions, dispatch)
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(RequestGroupActionsDropdown);