insomnia/app/containers/RequestActionsDropdown.js
Gregory Schier d369f85a12 Analytics and Sentry (#29)
* Segment integratrion + stats object

* Some things
2016-07-25 15:27:29 -07:00

75 lines
1.9 KiB
JavaScript

import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux'
import Dropdown from '../components/base/Dropdown';
import DropdownHint from '../components/base/DropdownHint';
import CurlExportModal from '../components/modals/CurlExportModal';
import PromptModal from '../components/modals/PromptModal';
import * as db from '../database';
class RequestActionsDropdown extends Component {
_promptUpdateName () {
const {request} = this.props;
PromptModal.show({
headerName: 'Rename Request',
defaultValue: request.name,
hint: 'also rename requests by double clicking in the sidebar'
}).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> Duplicate
<DropdownHint char="D"></DropdownHint>
</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);