insomnia/app/containers/RequestGroupActionsDropdown.js

65 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-04-09 21:41:27 +00:00
import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
2016-04-23 06:16:23 +00:00
import Dropdown from '../components/base/Dropdown'
2016-07-14 22:48:56 +00:00
import EnvironmentEditModal from '../components/EnvironmentEditModal'
import PromptModal from '../components/PromptModal'
2016-04-23 06:16:23 +00:00
import * as db from '../database'
2016-04-09 21:41:27 +00:00
class RequestGroupActionsDropdown extends Component {
2016-07-14 22:48:56 +00:00
_promptUpdateName () {
const {requestGroup} = this.props;
PromptModal.show({
headerName: 'Rename Request Group',
defaultValue: requestGroup.name
}).then(name => {
db.requestGroupUpdate(requestGroup, {name});
})
}
2016-04-09 21:41:27 +00:00
render () {
2016-07-14 22:48:56 +00:00
const {requestGroup, ...other} = this.props;
2016-04-09 21:41:27 +00:00
return (
<Dropdown {...other}>
<button>
<i className="fa fa-caret-down"></i>
</button>
<ul>
<li>
2016-07-14 22:48:56 +00:00
<button onClick={e => this._promptUpdateName()}>
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>
2016-07-14 22:48:56 +00:00
<button onClick={e => EnvironmentEditModal.show()}>
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>
<button onClick={e => db.requestGroupRemove(requestGroup)}>
2016-04-09 21:41:27 +00:00
<i className="fa fa-trash-o"></i> Delete
</button>
</li>
</ul>
</Dropdown>
)
}
}
RequestGroupActionsDropdown.propTypes = {
requestGroup: PropTypes.object
};
function mapStateToProps (state) {
2016-07-14 22:48:56 +00:00
return {};
2016-04-09 21:41:27 +00:00
}
function mapDispatchToProps (dispatch) {
2016-07-14 22:48:56 +00:00
return {}
2016-04-09 21:41:27 +00:00
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(RequestGroupActionsDropdown);