insomnia/app/containers/RequestActionsDropdown.js
2016-07-14 15:48:56 -07:00

72 lines
1.7 KiB
JavaScript

import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import Dropdown from '../components/base/Dropdown'
import CurlExportModal from '../components/CurlExportModal'
import PromptModal from '../components/PromptModal'
import * as db from '../database'
class RequestActionsDropdown extends Component {
_promptUpdateName () {
const {request} = this.props;
PromptModal.show({
headerName: 'Rename Request',
defaultValue: request.name
}).then(name => {
db.requestUpdate(request, {name});
})
}
render () {
const {request, ...other} = this.props;
return (
<Dropdown {...other}>
<button>
<i className="fa fa-gear"></i>
</button>
<ul>
<li>
<button onClick={e => db.requestCopy(request)}>
<i className="fa fa-copy"></i> Clone
</button>
</li>
<li>
<button onClick={e => this._promptUpdateName()}>
<i className="fa fa-edit"></i> Rename
</button>
</li>
<li>
<button onClick={e => CurlExportModal.show(request)}>
<i className="fa fa-share-square-o"></i> Export as cURL
</button>
</li>
<li>
<button onClick={e => db.requestRemove(request)}>
<i className="fa fa-trash-o"></i> Delete
</button>
</li>
</ul>
</Dropdown>
)
}
}
RequestActionsDropdown.propTypes = {
request: PropTypes.object.isRequired
};
function mapStateToProps (state) {
return {};
}
function mapDispatchToProps (dispatch) {
return {}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(RequestActionsDropdown);