2021-02-02 22:23:42 +00:00
|
|
|
import { autoBindMethodsForReact } from 'class-autobind-decorator';
|
2022-02-16 18:28:23 +00:00
|
|
|
import { OpenDialogOptions } from 'electron';
|
2021-10-14 14:59:45 +00:00
|
|
|
import { HotKeyRegistry } from 'insomnia-common';
|
2021-07-22 23:04:56 +00:00
|
|
|
import React, { PureComponent, ReactNode } from 'react';
|
|
|
|
|
|
|
|
import { AUTOBIND_CFG, DEBOUNCE_MILLIS, isMac } from '../../common/constants';
|
|
|
|
import { hotKeyRefs } from '../../common/hotkeys';
|
|
|
|
import { executeHotKey } from '../../common/hotkeys-listener';
|
|
|
|
import type { Request } from '../../models/request';
|
2021-09-15 20:16:04 +00:00
|
|
|
import { Dropdown } from './base/dropdown/dropdown';
|
|
|
|
import { DropdownButton } from './base/dropdown/dropdown-button';
|
|
|
|
import { DropdownDivider } from './base/dropdown/dropdown-divider';
|
|
|
|
import { DropdownHint } from './base/dropdown/dropdown-hint';
|
|
|
|
import { DropdownItem } from './base/dropdown/dropdown-item';
|
2021-09-27 13:47:22 +00:00
|
|
|
import { PromptButton } from './base/prompt-button';
|
|
|
|
import { OneLineEditor } from './codemirror/one-line-editor';
|
|
|
|
import { MethodDropdown } from './dropdowns/method-dropdown';
|
|
|
|
import { KeydownBinder } from './keydown-binder';
|
2021-07-22 23:04:56 +00:00
|
|
|
import { showPrompt } from './modals/index';
|
2021-05-12 06:35:00 +00:00
|
|
|
|
|
|
|
interface Props {
|
2021-09-08 15:38:07 +00:00
|
|
|
handleAutocompleteUrls: () => Promise<string[]>;
|
2021-05-12 06:35:00 +00:00
|
|
|
handleGenerateCode: Function;
|
|
|
|
handleImport: Function;
|
|
|
|
handleSend: () => void;
|
|
|
|
handleSendAndDownload: (filepath?: string) => Promise<void>;
|
|
|
|
handleUpdateDownloadPath: Function;
|
|
|
|
nunjucksPowerUserMode: boolean;
|
|
|
|
onMethodChange: (r: Request, method: string) => Promise<Request>;
|
|
|
|
onUrlChange: (r: Request, url: string) => Promise<Request>;
|
|
|
|
request: Request;
|
|
|
|
uniquenessKey: string;
|
|
|
|
hotKeyRegistry: HotKeyRegistry;
|
|
|
|
downloadPath: string | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
currentInterval: number | null;
|
|
|
|
currentTimeout: number | null;
|
|
|
|
}
|
2016-11-07 20:24:38 +00:00
|
|
|
|
2021-02-02 22:23:42 +00:00
|
|
|
@autoBindMethodsForReact(AUTOBIND_CFG)
|
2021-09-27 13:47:22 +00:00
|
|
|
export class RequestUrlBar extends PureComponent<Props, State> {
|
2021-05-12 06:35:00 +00:00
|
|
|
_urlChangeDebounceTimeout: NodeJS.Timeout | null = null;
|
|
|
|
_sendTimeout: NodeJS.Timeout | null = null;
|
|
|
|
_sendInterval: NodeJS.Timeout | null = null;
|
|
|
|
_dropdown: Dropdown | null = null;
|
|
|
|
_methodDropdown: MethodDropdown | null = null;
|
|
|
|
_input: OneLineEditor | null = null;
|
|
|
|
state: State = {
|
|
|
|
currentInterval: null,
|
|
|
|
currentTimeout: null,
|
2021-09-01 14:50:26 +00:00
|
|
|
};
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2021-09-08 15:38:07 +00:00
|
|
|
_lastPastedText?: string;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
|
|
|
_setDropdownRef(n: Dropdown) {
|
2017-03-03 01:44:07 +00:00
|
|
|
this._dropdown = n;
|
|
|
|
}
|
2017-02-08 00:31:48 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_setMethodDropdownRef(n: MethodDropdown) {
|
2017-09-17 14:04:56 +00:00
|
|
|
this._methodDropdown = n;
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_setInputRef(n: OneLineEditor) {
|
2017-03-03 01:44:07 +00:00
|
|
|
this._input = n;
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleMetaClickSend(e: React.MouseEvent<HTMLButtonElement>) {
|
2017-02-08 00:31:48 +00:00
|
|
|
e.preventDefault();
|
2021-07-30 03:32:08 +00:00
|
|
|
this._dropdown?.show();
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-02-08 00:31:48 +00:00
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleFormSubmit(e: React.SyntheticEvent<HTMLFormElement>) {
|
2018-12-16 01:37:40 +00:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2017-02-01 20:21:14 +00:00
|
|
|
|
|
|
|
this._handleSend();
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-27 21:42:38 +00:00
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
_handleMethodChange(method: string) {
|
|
|
|
this.props.onMethodChange(this.props.request, method);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-27 21:42:38 +00:00
|
|
|
|
2018-12-14 23:10:57 +00:00
|
|
|
_handleUrlChange(url: string) {
|
2021-05-12 06:35:00 +00:00
|
|
|
if (this._urlChangeDebounceTimeout !== null) {
|
|
|
|
clearTimeout(this._urlChangeDebounceTimeout);
|
|
|
|
}
|
2017-02-02 18:30:13 +00:00
|
|
|
this._urlChangeDebounceTimeout = setTimeout(async () => {
|
2017-03-03 01:44:07 +00:00
|
|
|
const pastedText = this._lastPastedText;
|
2017-02-02 18:30:13 +00:00
|
|
|
|
|
|
|
// If no pasted text in the queue, just fire the regular change handler
|
|
|
|
if (!pastedText) {
|
2018-12-14 23:10:57 +00:00
|
|
|
this.props.onUrlChange(this.props.request, url);
|
2017-04-04 23:06:43 +00:00
|
|
|
return;
|
2017-02-02 18:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reset pasted text cache
|
2021-09-08 15:38:07 +00:00
|
|
|
this._lastPastedText = undefined;
|
2017-02-02 18:30:13 +00:00
|
|
|
// Attempt to import the pasted text
|
|
|
|
const importedRequest = await this.props.handleImport(pastedText);
|
|
|
|
|
|
|
|
// Update depending on whether something was imported
|
2017-04-04 23:06:43 +00:00
|
|
|
if (!importedRequest) {
|
2018-12-14 23:10:57 +00:00
|
|
|
this.props.onUrlChange(this.props.request, url);
|
2017-02-02 18:30:13 +00:00
|
|
|
}
|
2016-11-07 20:24:38 +00:00
|
|
|
}, DEBOUNCE_MILLIS);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-07 20:24:38 +00:00
|
|
|
|
2021-09-08 15:38:07 +00:00
|
|
|
_handleUrlPaste(e: ClipboardEvent) {
|
2017-02-02 18:30:13 +00:00
|
|
|
// NOTE: We're not actually doing the import here to avoid races with onChange
|
2021-09-08 15:38:07 +00:00
|
|
|
this._lastPastedText = e.clipboardData?.getData('text/plain');
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-01-28 06:09:01 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleGenerateCode() {
|
2016-11-28 07:12:17 +00:00
|
|
|
this.props.handleGenerateCode();
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2020-07-28 05:18:26 +00:00
|
|
|
async _handleSetDownloadLocation() {
|
2019-06-03 18:45:22 +00:00
|
|
|
const { request } = this.props;
|
2021-05-12 06:35:00 +00:00
|
|
|
const options: OpenDialogOptions = {
|
2017-02-01 20:21:14 +00:00
|
|
|
title: 'Select Download Location',
|
|
|
|
buttonLabel: 'Select',
|
2018-12-12 17:36:11 +00:00
|
|
|
properties: ['openDirectory'],
|
2017-02-01 20:21:14 +00:00
|
|
|
};
|
2022-02-16 18:28:23 +00:00
|
|
|
const { canceled, filePaths } = await window.dialog.showOpenDialog(options);
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2020-07-28 05:18:26 +00:00
|
|
|
if (canceled) {
|
|
|
|
return;
|
|
|
|
}
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2020-07-28 05:18:26 +00:00
|
|
|
this.props.handleUpdateDownloadPath(request._id, filePaths[0]);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleClearDownloadLocation() {
|
2019-06-03 18:45:22 +00:00
|
|
|
const { request } = this.props;
|
|
|
|
this.props.handleUpdateDownloadPath(request._id, null);
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2021-12-13 14:23:56 +00:00
|
|
|
async _handleKeyDown(event: KeyboardEvent) {
|
2016-11-28 07:12:17 +00:00
|
|
|
if (!this._input) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-13 14:23:56 +00:00
|
|
|
executeHotKey(event, hotKeyRefs.REQUEST_FOCUS_URL, () => {
|
2021-07-30 03:32:08 +00:00
|
|
|
this._input?.focus();
|
|
|
|
this._input?.selectAll();
|
2017-09-17 14:04:56 +00:00
|
|
|
});
|
2021-12-13 14:23:56 +00:00
|
|
|
executeHotKey(event, hotKeyRefs.REQUEST_TOGGLE_HTTP_METHOD_MENU, () => {
|
2021-07-30 03:32:08 +00:00
|
|
|
this._methodDropdown?.toggle();
|
2017-09-17 14:04:56 +00:00
|
|
|
});
|
2021-12-13 14:23:56 +00:00
|
|
|
executeHotKey(event, hotKeyRefs.REQUEST_SHOW_OPTIONS, () => {
|
2021-07-30 03:32:08 +00:00
|
|
|
this._dropdown?.toggle(true);
|
2017-09-17 14:04:56 +00:00
|
|
|
});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleSend() {
|
2016-11-28 07:12:17 +00:00
|
|
|
// Don't stop interval because duh, it needs to keep going!
|
2017-01-28 06:09:01 +00:00
|
|
|
// XXX this._handleStopInterval(); XXX
|
2016-11-28 07:12:17 +00:00
|
|
|
this._handleStopTimeout();
|
2017-02-01 20:21:14 +00:00
|
|
|
|
2019-06-03 18:45:22 +00:00
|
|
|
const { downloadPath } = this.props;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2017-02-01 20:21:14 +00:00
|
|
|
if (downloadPath) {
|
|
|
|
this.props.handleSendAndDownload(downloadPath);
|
|
|
|
} else {
|
|
|
|
this.props.handleSend();
|
|
|
|
}
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-10-17 20:15:25 +00:00
|
|
|
_handleClickSendAndDownload() {
|
|
|
|
this.props.handleSendAndDownload();
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleSendAfterDelay() {
|
2017-06-01 02:04:27 +00:00
|
|
|
showPrompt({
|
2016-11-28 07:12:17 +00:00
|
|
|
inputType: 'decimal',
|
2017-07-20 01:55:40 +00:00
|
|
|
title: 'Send After Delay',
|
2016-11-28 07:12:17 +00:00
|
|
|
label: 'Delay in seconds',
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2016-11-28 07:12:17 +00:00
|
|
|
defaultValue: 3,
|
2017-06-01 02:04:27 +00:00
|
|
|
submitName: 'Start',
|
|
|
|
onComplete: seconds => {
|
|
|
|
this._handleStopTimeout();
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2017-06-01 02:04:27 +00:00
|
|
|
this._sendTimeout = setTimeout(this._handleSend, seconds * 1000);
|
2021-05-12 06:35:00 +00:00
|
|
|
this.setState({
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2021-05-12 06:35:00 +00:00
|
|
|
currentTimeout: seconds,
|
|
|
|
});
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-06-01 02:04:27 +00:00
|
|
|
});
|
2017-03-03 20:09:08 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleSendOnInterval() {
|
2017-06-01 02:04:27 +00:00
|
|
|
showPrompt({
|
2016-11-28 07:12:17 +00:00
|
|
|
inputType: 'decimal',
|
2017-07-20 01:55:40 +00:00
|
|
|
title: 'Send on Interval',
|
2016-11-28 07:12:17 +00:00
|
|
|
label: 'Interval in seconds',
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2016-11-28 07:12:17 +00:00
|
|
|
defaultValue: 3,
|
2017-06-01 02:04:27 +00:00
|
|
|
submitName: 'Start',
|
|
|
|
onComplete: seconds => {
|
|
|
|
this._handleStopInterval();
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2017-06-01 02:04:27 +00:00
|
|
|
this._sendInterval = setInterval(this._handleSend, seconds * 1000);
|
2021-05-12 06:35:00 +00:00
|
|
|
this.setState({
|
2021-06-02 01:46:26 +00:00
|
|
|
// @ts-expect-error TSCONVERSION string vs number issue
|
2021-05-12 06:35:00 +00:00
|
|
|
currentInterval: seconds,
|
|
|
|
});
|
2018-12-12 17:36:11 +00:00
|
|
|
},
|
2017-06-01 02:04:27 +00:00
|
|
|
});
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleStopInterval() {
|
2021-05-12 06:35:00 +00:00
|
|
|
if (this._sendInterval) {
|
|
|
|
clearInterval(this._sendInterval);
|
|
|
|
}
|
|
|
|
|
2016-11-28 07:12:17 +00:00
|
|
|
if (this.state.currentInterval) {
|
2021-05-12 06:35:00 +00:00
|
|
|
this.setState({
|
|
|
|
currentInterval: null,
|
|
|
|
});
|
2016-11-28 07:12:17 +00:00
|
|
|
}
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleStopTimeout() {
|
2021-05-12 06:35:00 +00:00
|
|
|
if (this._sendTimeout !== null) {
|
|
|
|
clearTimeout(this._sendTimeout);
|
|
|
|
}
|
|
|
|
|
2016-11-28 07:12:17 +00:00
|
|
|
if (this.state.currentTimeout) {
|
2021-05-12 06:35:00 +00:00
|
|
|
this.setState({
|
|
|
|
currentTimeout: null,
|
|
|
|
});
|
2016-11-28 07:12:17 +00:00
|
|
|
}
|
2017-03-03 20:09:08 +00:00
|
|
|
}
|
2016-11-28 07:12:17 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
_handleResetTimeouts() {
|
2017-04-10 20:07:33 +00:00
|
|
|
this._handleStopTimeout();
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2017-04-10 20:07:33 +00:00
|
|
|
this._handleStopInterval();
|
|
|
|
}
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
_handleClickSend(e: React.MouseEvent<HTMLButtonElement>) {
|
2016-12-21 23:37:48 +00:00
|
|
|
const metaPressed = isMac() ? e.metaKey : e.ctrlKey;
|
|
|
|
|
|
|
|
// If we're pressing a meta key, let the dropdown open
|
|
|
|
if (metaPressed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're not pressing a meta key, cancel dropdown and send the request
|
|
|
|
e.stopPropagation(); // Don't trigger the dropdown
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2018-12-16 01:37:40 +00:00
|
|
|
this._handleSend();
|
2017-03-03 01:44:07 +00:00
|
|
|
}
|
2016-12-21 23:37:48 +00:00
|
|
|
|
2020-01-06 20:51:52 +00:00
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
2018-12-14 23:10:57 +00:00
|
|
|
if (nextProps.request._id !== this.props.request._id) {
|
2017-04-10 20:07:33 +00:00
|
|
|
this._handleResetTimeouts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
renderSendButton() {
|
2019-06-03 18:45:22 +00:00
|
|
|
const { hotKeyRegistry, downloadPath } = this.props;
|
|
|
|
const { currentInterval, currentTimeout } = this.state;
|
2021-05-12 06:35:00 +00:00
|
|
|
let cancelButton: ReactNode = null;
|
2016-11-28 07:12:17 +00:00
|
|
|
|
|
|
|
if (currentInterval) {
|
|
|
|
cancelButton = (
|
2018-06-25 17:42:50 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
key="cancel-interval"
|
|
|
|
className="urlbar__send-btn danger"
|
2021-08-07 08:03:56 +00:00
|
|
|
onClick={this._handleStopInterval}
|
|
|
|
>
|
2016-11-28 07:12:17 +00:00
|
|
|
Stop
|
|
|
|
</button>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-28 07:12:17 +00:00
|
|
|
} else if (currentTimeout) {
|
|
|
|
cancelButton = (
|
2018-06-25 17:42:50 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
key="cancel-timeout"
|
|
|
|
className="urlbar__send-btn danger"
|
2021-08-07 08:03:56 +00:00
|
|
|
onClick={this._handleStopTimeout}
|
|
|
|
>
|
2016-11-28 07:12:17 +00:00
|
|
|
Cancel
|
|
|
|
</button>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-28 07:12:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let sendButton;
|
2021-05-12 06:35:00 +00:00
|
|
|
|
2016-11-28 07:12:17 +00:00
|
|
|
if (!cancelButton) {
|
2016-12-21 23:37:48 +00:00
|
|
|
sendButton = (
|
2018-10-17 16:42:33 +00:00
|
|
|
<Dropdown key="dropdown" className="tall" right ref={this._setDropdownRef}>
|
2018-06-25 17:42:50 +00:00
|
|
|
<DropdownButton
|
|
|
|
className="urlbar__send-btn"
|
|
|
|
onContextMenu={this._handleMetaClickSend}
|
2021-08-07 08:03:56 +00:00
|
|
|
onClick={this._handleClickSend}
|
|
|
|
>
|
2017-03-03 20:09:08 +00:00
|
|
|
{downloadPath ? 'Download' : 'Send'}
|
2016-11-28 07:12:17 +00:00
|
|
|
</DropdownButton>
|
2016-12-21 23:37:48 +00:00
|
|
|
<DropdownDivider>Basic</DropdownDivider>
|
2018-12-16 01:34:42 +00:00
|
|
|
<DropdownItem onClick={this._handleClickSend}>
|
|
|
|
<i className="fa fa-arrow-circle-o-right" /> Send Now
|
2019-03-12 16:38:30 +00:00
|
|
|
<DropdownHint keyBindings={hotKeyRegistry[hotKeyRefs.REQUEST_SEND.id]} />
|
2016-11-28 07:12:17 +00:00
|
|
|
</DropdownItem>
|
|
|
|
<DropdownItem onClick={this._handleGenerateCode}>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-code" /> Generate Client Code
|
2016-11-28 07:12:17 +00:00
|
|
|
</DropdownItem>
|
2016-12-21 23:37:48 +00:00
|
|
|
<DropdownDivider>Advanced</DropdownDivider>
|
2016-11-28 07:12:17 +00:00
|
|
|
<DropdownItem onClick={this._handleSendAfterDelay}>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-clock-o" /> Send After Delay
|
2016-11-28 07:12:17 +00:00
|
|
|
</DropdownItem>
|
|
|
|
<DropdownItem onClick={this._handleSendOnInterval}>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-repeat" /> Repeat on Interval
|
2016-11-28 07:12:17 +00:00
|
|
|
</DropdownItem>
|
2017-02-01 20:21:14 +00:00
|
|
|
{downloadPath ? (
|
2018-06-25 17:42:50 +00:00
|
|
|
<DropdownItem
|
|
|
|
stayOpenAfterClick
|
|
|
|
addIcon
|
|
|
|
buttonClass={PromptButton}
|
2021-08-07 08:03:56 +00:00
|
|
|
onClick={this._handleClearDownloadLocation}
|
|
|
|
>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-stop-circle" /> Stop Auto-Download
|
2017-04-04 23:06:43 +00:00
|
|
|
</DropdownItem>
|
|
|
|
) : (
|
|
|
|
<DropdownItem onClick={this._handleSetDownloadLocation}>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-download" /> Download After Send
|
2017-04-04 23:06:43 +00:00
|
|
|
</DropdownItem>
|
|
|
|
)}
|
2018-10-17 20:15:25 +00:00
|
|
|
<DropdownItem onClick={this._handleClickSendAndDownload}>
|
2018-12-16 01:34:42 +00:00
|
|
|
<i className="fa fa-download" /> Send And Download
|
2018-10-17 20:15:25 +00:00
|
|
|
</DropdownItem>
|
2016-11-28 07:12:17 +00:00
|
|
|
</Dropdown>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-28 07:12:17 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
return [cancelButton, sendButton];
|
2016-11-07 20:24:38 +00:00
|
|
|
}
|
|
|
|
|
2022-01-05 14:43:28 +00:00
|
|
|
// note: not an unused function, used by parent, RequestPane
|
|
|
|
focusInput() {
|
|
|
|
this._input?.focus(true);
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
render() {
|
2017-03-23 22:10:42 +00:00
|
|
|
const {
|
2018-12-14 23:10:57 +00:00
|
|
|
request,
|
2017-04-10 20:07:33 +00:00
|
|
|
handleAutocompleteUrls,
|
2018-12-12 17:36:11 +00:00
|
|
|
uniquenessKey,
|
2017-03-23 22:10:42 +00:00
|
|
|
} = this.props;
|
2018-12-14 23:10:57 +00:00
|
|
|
const { url, method } = request;
|
2022-01-05 14:43:28 +00:00
|
|
|
|
2016-11-07 20:24:38 +00:00
|
|
|
return (
|
2017-09-17 14:04:56 +00:00
|
|
|
<KeydownBinder onKeydown={this._handleKeyDown}>
|
|
|
|
<div className="urlbar">
|
2018-06-25 17:42:50 +00:00
|
|
|
<MethodDropdown
|
|
|
|
ref={this._setMethodDropdownRef}
|
|
|
|
onChange={this._handleMethodChange}
|
2021-08-07 08:03:56 +00:00
|
|
|
method={method}
|
|
|
|
>
|
2018-12-16 01:34:42 +00:00
|
|
|
{method} <i className="fa fa-caret-down" />
|
2017-09-17 14:04:56 +00:00
|
|
|
</MethodDropdown>
|
|
|
|
<form onSubmit={this._handleFormSubmit}>
|
|
|
|
<OneLineEditor
|
|
|
|
key={uniquenessKey}
|
|
|
|
ref={this._setInputRef}
|
|
|
|
onPaste={this._handleUrlPaste}
|
|
|
|
forceEditor
|
|
|
|
type="text"
|
|
|
|
getAutocompleteConstants={handleAutocompleteUrls}
|
|
|
|
placeholder="https://api.myproduct.com/v1/users"
|
|
|
|
defaultValue={url}
|
2018-06-25 17:42:50 +00:00
|
|
|
onChange={this._handleUrlChange}
|
|
|
|
/>
|
2017-09-17 14:04:56 +00:00
|
|
|
{this.renderSendButton()}
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</KeydownBinder>
|
2016-11-07 20:24:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|