insomnia/packages/insomnia-app/app/ui/components/dropdowns/request-actions-dropdown.js
Gregory Schier 549ce23ce8
Merge All Repositories into Monorepo for easier maintenance (#629)
* All projects into monorepo

* Update CI

* More CI updates

* Extracted a bunch of things into packages

* Publish

 - insomnia-plugin-base64@1.0.1
 - insomnia-plugin-default-headers@1.0.2
 - insomnia-plugin-file@1.0.1
 - insomnia-plugin-hash@1.0.1
 - insomnia-plugin-now@1.0.1
 - insomnia-plugin-request@1.0.1
 - insomnia-plugin-response@1.0.1
 - insomnia-plugin-uuid@1.0.1
 - insomnia-cookies@0.0.2
 - insomnia-importers@1.5.2
 - insomnia-prettify@0.0.3
 - insomnia-url@0.0.2
 - insomnia-xpath@0.0.2

* A bunch of small fixes

* Improved build script

* Fixed

* Merge dangling files

* Usability refactor

* Handle duplicate plugin names
2017-11-26 20:45:40 +00:00

89 lines
2.7 KiB
JavaScript

import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import autobind from 'autobind-decorator';
import PromptButton from '../base/prompt-button';
import {Dropdown, DropdownButton, DropdownDivider, DropdownHint, DropdownItem} from '../base/dropdown/index';
import * as models from '../../../models';
import {trackEvent} from '../../../common/analytics';
import * as hotkeys from '../../../common/hotkeys';
@autobind
class RequestActionsDropdown extends PureComponent {
_setDropdownRef (n) {
this._dropdown = n;
}
_handleDuplicate () {
const {request, handleDuplicateRequest} = this.props;
handleDuplicateRequest(request);
trackEvent('Request', 'Duplicate', 'Request Action');
}
_handleGenerateCode () {
this.props.handleGenerateCode(this.props.request);
trackEvent('Request', 'Generate Code', 'Request Action');
}
_handleCopyAsCurl () {
trackEvent('Request', 'Copy As Curl', 'Request Action');
this.props.handleCopyAsCurl(this.props.request);
}
_handleRemove () {
const {request} = this.props;
models.request.remove(request);
trackEvent('Request', 'Delete', 'Action');
}
show () {
this._dropdown.show();
}
render () {
const {
request, // eslint-disable-line no-unused-vars
handleShowSettings,
...other
} = this.props;
return (
<Dropdown ref={this._setDropdownRef} {...other}>
<DropdownButton>
<i className="fa fa-caret-down"/>
</DropdownButton>
<DropdownItem onClick={this._handleDuplicate}>
<i className="fa fa-copy"/> Duplicate
<DropdownHint hotkey={hotkeys.DUPLICATE_REQUEST}/>
</DropdownItem>
<DropdownItem onClick={this._handleGenerateCode}>
<i className="fa fa-code"/> Generate Code
<DropdownHint hotkey={hotkeys.GENERATE_CODE}/>
</DropdownItem>
<DropdownItem onClick={this._handleCopyAsCurl}>
<i className="fa fa-copy"/> Copy as Curl
</DropdownItem>
<DropdownItem buttonClass={PromptButton} onClick={this._handleRemove} addIcon>
<i className="fa fa-trash-o"/> Delete
</DropdownItem>
<DropdownDivider/>
<DropdownItem onClick={handleShowSettings}>
<i className="fa fa-wrench"/> Settings
<DropdownHint hotkey={hotkeys.SHOW_REQUEST_SETTINGS}/>
</DropdownItem>
</Dropdown>
);
}
}
RequestActionsDropdown.propTypes = {
handleDuplicateRequest: PropTypes.func.isRequired,
handleGenerateCode: PropTypes.func.isRequired,
handleCopyAsCurl: PropTypes.func.isRequired,
handleShowSettings: PropTypes.func.isRequired,
request: PropTypes.object.isRequired
};
export default RequestActionsDropdown;