2016-07-16 02:06:10 +00:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
2016-09-22 20:14:41 +00:00
|
|
|
import PromptButton from '../base/PromptButton';
|
2016-11-11 22:01:21 +00:00
|
|
|
import {Dropdown, DropdownHint, DropdownButton, DropdownItem} from '../base/dropdown';
|
2016-09-22 20:14:41 +00:00
|
|
|
import GenerateCodeModal from '../modals/GenerateCodeModal';
|
|
|
|
import PromptModal from '../modals/PromptModal';
|
2016-11-10 05:56:23 +00:00
|
|
|
import * as models from '../../../models';
|
2016-11-07 20:24:38 +00:00
|
|
|
import {showModal} from '../modals/index';
|
2016-11-23 19:33:24 +00:00
|
|
|
import {trackEvent} from '../../../analytics/index';
|
2016-07-14 22:48:56 +00:00
|
|
|
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
class RequestActionsDropdown extends Component {
|
2016-10-02 20:57:00 +00:00
|
|
|
async _promptUpdateName () {
|
2016-07-14 22:48:56 +00:00
|
|
|
const {request} = this.props;
|
|
|
|
|
2016-11-07 20:24:38 +00:00
|
|
|
const name = await showModal(PromptModal, {
|
2016-07-14 22:48:56 +00:00
|
|
|
headerName: 'Rename Request',
|
2016-07-19 20:21:33 +00:00
|
|
|
defaultValue: request.name,
|
2016-07-25 22:27:29 +00:00
|
|
|
hint: 'also rename requests by double clicking in the sidebar'
|
2016-10-02 20:57:00 +00:00
|
|
|
});
|
|
|
|
|
2016-11-10 01:15:27 +00:00
|
|
|
models.request.update(request, {name});
|
2016-07-14 22:48:56 +00:00
|
|
|
}
|
|
|
|
|
2016-04-03 22:54:39 +00:00
|
|
|
render () {
|
2016-07-14 22:48:56 +00:00
|
|
|
const {request, ...other} = this.props;
|
2016-04-03 22:54:39 +00:00
|
|
|
|
|
|
|
return (
|
2016-04-04 07:15:30 +00:00
|
|
|
<Dropdown {...other}>
|
2016-11-11 22:01:21 +00:00
|
|
|
<DropdownButton>
|
2016-08-15 17:04:36 +00:00
|
|
|
<i className="fa fa-caret-down"></i>
|
2016-11-11 22:01:21 +00:00
|
|
|
</DropdownButton>
|
2016-11-23 19:33:24 +00:00
|
|
|
<DropdownItem onClick={e => {
|
|
|
|
models.request.duplicate(request);
|
2016-11-23 20:44:46 +00:00
|
|
|
trackEvent('Request', 'Duplicate', 'Request Action');
|
2016-11-23 19:33:24 +00:00
|
|
|
}}>
|
2016-11-11 22:01:21 +00:00
|
|
|
<i className="fa fa-copy"></i> Duplicate
|
|
|
|
<DropdownHint char="D"></DropdownHint>
|
|
|
|
</DropdownItem>
|
2016-11-23 19:33:24 +00:00
|
|
|
<DropdownItem onClick={e => {
|
|
|
|
this._promptUpdateName();
|
2016-11-23 20:44:46 +00:00
|
|
|
trackEvent('Request', 'Rename', 'Request Action');
|
2016-11-23 19:33:24 +00:00
|
|
|
}}>
|
2016-11-11 22:01:21 +00:00
|
|
|
<i className="fa fa-edit"></i> Rename
|
|
|
|
</DropdownItem>
|
2016-11-23 19:33:24 +00:00
|
|
|
<DropdownItem onClick={e => {
|
|
|
|
showModal(GenerateCodeModal, request);
|
2016-11-23 20:44:46 +00:00
|
|
|
trackEvent('Request', 'Generate Code', 'Request Action');
|
2016-11-23 19:33:24 +00:00
|
|
|
}}>
|
2016-11-11 22:01:21 +00:00
|
|
|
<i className="fa fa-code"></i> Generate Code
|
|
|
|
</DropdownItem>
|
|
|
|
<DropdownItem buttonClass={PromptButton}
|
2016-11-23 19:33:24 +00:00
|
|
|
onClick={e => {
|
|
|
|
models.request.remove(request);
|
|
|
|
trackEvent('Request', 'Delete', 'Action');
|
|
|
|
}}
|
2016-11-11 22:01:21 +00:00
|
|
|
addIcon={true}>
|
|
|
|
<i className="fa fa-trash-o"></i> Delete
|
|
|
|
</DropdownItem>
|
2016-04-03 22:54:39 +00:00
|
|
|
</Dropdown>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestActionsDropdown.propTypes = {
|
2016-07-14 22:48:56 +00:00
|
|
|
request: PropTypes.object.isRequired
|
2016-04-03 22:54:39 +00:00
|
|
|
};
|
|
|
|
|
2016-09-22 20:14:41 +00:00
|
|
|
export default RequestActionsDropdown;
|