mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
e7bc8bb860
* Styles and editor done for requests * Add description markdown to WOrkspace settings * Show file icon beside request with description * Add tracking
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import React, {PropTypes, PureComponent} from 'react';
|
|
import autobind from 'autobind-decorator';
|
|
import PromptButton from '../base/prompt-button';
|
|
import {Dropdown, DropdownButton, DropdownHint, DropdownItem} from '../base/dropdown';
|
|
import * as models from '../../../models';
|
|
import {trackEvent} from '../../../analytics/index';
|
|
import {DropdownDivider} from '../base/dropdown/index';
|
|
|
|
@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');
|
|
}
|
|
|
|
_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 char="D"/>
|
|
</DropdownItem>
|
|
<DropdownItem onClick={this._handleGenerateCode}>
|
|
<i className="fa fa-code"/> Generate Code
|
|
</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 alt shift char=","/>
|
|
</DropdownItem>
|
|
</Dropdown>
|
|
);
|
|
}
|
|
}
|
|
|
|
RequestActionsDropdown.propTypes = {
|
|
handleDuplicateRequest: PropTypes.func.isRequired,
|
|
handleGenerateCode: PropTypes.func.isRequired,
|
|
handleShowSettings: PropTypes.func.isRequired,
|
|
request: PropTypes.object.isRequired
|
|
};
|
|
|
|
export default RequestActionsDropdown;
|