mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import PromptButton from '../base/PromptButton';
|
|
import {Dropdown, DropdownHint, DropdownButton, DropdownItem} from '../base/dropdown';
|
|
import GenerateCodeModal from '../modals/GenerateCodeModal';
|
|
import PromptModal from '../modals/PromptModal';
|
|
import * as models from '../../../models';
|
|
import {showModal} from '../modals/index';
|
|
|
|
|
|
class RequestActionsDropdown extends Component {
|
|
async _promptUpdateName () {
|
|
const {request} = this.props;
|
|
|
|
const name = await showModal(PromptModal, {
|
|
headerName: 'Rename Request',
|
|
defaultValue: request.name,
|
|
hint: 'also rename requests by double clicking in the sidebar'
|
|
});
|
|
|
|
models.request.update(request, {name});
|
|
}
|
|
|
|
render () {
|
|
const {request, ...other} = this.props;
|
|
|
|
return (
|
|
<Dropdown {...other}>
|
|
<DropdownButton>
|
|
<i className="fa fa-caret-down"></i>
|
|
</DropdownButton>
|
|
<DropdownItem onClick={e => models.request.duplicate(request)}>
|
|
<i className="fa fa-copy"></i> Duplicate
|
|
<DropdownHint char="D"></DropdownHint>
|
|
</DropdownItem>
|
|
<DropdownItem onClick={e => this._promptUpdateName()}>
|
|
<i className="fa fa-edit"></i> Rename
|
|
</DropdownItem>
|
|
<DropdownItem onClick={e => showModal(GenerateCodeModal, request)}>
|
|
<i className="fa fa-code"></i> Generate Code
|
|
</DropdownItem>
|
|
<DropdownItem buttonClass={PromptButton}
|
|
onClick={e => models.request.remove(request)}
|
|
addIcon={true}>
|
|
<i className="fa fa-trash-o"></i> Delete
|
|
</DropdownItem>
|
|
</Dropdown>
|
|
)
|
|
}
|
|
}
|
|
|
|
RequestActionsDropdown.propTypes = {
|
|
request: PropTypes.object.isRequired
|
|
};
|
|
|
|
export default RequestActionsDropdown;
|