mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-26 08:38:58 -04:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
70190b3dec
8 files changed
+105
-40
No files matched your search
@@ -77,6 +77,7 @@ the following tools:
|
||||
Here is a list of plugins available for installation via NPM.
|
||||
|
||||
- [Chance](https://www.npmjs.com/package/insomnia-plugin-chance) – Generates a random value using Chance.JS
|
||||
- [Cuid](https://www.npmjs.com/package/insomnia-plugin-cuid) – Generate random cuids
|
||||
- [Custom Timestamp](https://www.npmjs.com/package/insomnia-plugin-customtimestamp) – Advanced timestamp creator
|
||||
- [Default Headers](https://www.npmjs.com/package/insomnia-plugin-default-headers) – Set default headers on requests
|
||||
- [Defaults](https://www.npmjs.com/package/insomnia-plugin-defaults) - Set request defaults through your environment
|
||||
|
||||
@@ -29,6 +29,7 @@ type BaseSettings = {
|
||||
updateAutomatically: boolean,
|
||||
disableUpdateNotification: boolean,
|
||||
environmentHighlightColorStyle: string,
|
||||
autocompleteDelay: number,
|
||||
fontMonospace: string | null,
|
||||
fontInterface: string | null,
|
||||
fontSize: number,
|
||||
@@ -69,6 +70,7 @@ export function init(): BaseSettings {
|
||||
updateAutomatically: true,
|
||||
disableUpdateNotification: false,
|
||||
environmentHighlightColorStyle: 'sidebar-indicator',
|
||||
autocompleteDelay: 700,
|
||||
fontMonospace: null,
|
||||
fontInterface: null,
|
||||
fontSize: 13,
|
||||
|
||||
@@ -190,6 +190,12 @@ async function _getAccessToken(
|
||||
authentication.scope,
|
||||
);
|
||||
|
||||
// If we didn't receive an access token it means the refresh token didn't succeed,
|
||||
// so we tell caller to fetch brand new access and refresh tokens.
|
||||
if (!refreshResults.access_token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~ //
|
||||
// Update the DB //
|
||||
// ~~~~~~~~~~~~~ //
|
||||
|
||||
@@ -48,7 +48,14 @@ export default async function(
|
||||
});
|
||||
|
||||
const statusCode = response.statusCode || 0;
|
||||
if (statusCode < 200 || statusCode >= 300) {
|
||||
|
||||
if (statusCode === 401) {
|
||||
// If the refresh token was rejected due an unauthorized request, we will
|
||||
// return a null access_token to trigger an authentication request to fetch
|
||||
// brand new refresh and access tokens.
|
||||
|
||||
return responseToObject(null, [c.P_ACCESS_TOKEN]);
|
||||
} else if (statusCode < 200 || statusCode >= 300) {
|
||||
throw new Error(`[oauth2] Failed to refresh token url=${url} status=${statusCode}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import CodeMirror from 'codemirror';
|
||||
import 'codemirror/addon/mode/overlay';
|
||||
import * as models from '../../../../models';
|
||||
import { getDefaultFill } from '../../../../templating/utils';
|
||||
import { escapeHTML, escapeRegex } from '../../../../common/misc';
|
||||
|
||||
@@ -11,7 +12,6 @@ const COMPLETE_AFTER_WORD = /[\w.\][-]+/;
|
||||
const COMPLETE_AFTER_CURLIES = /[^{]*{[{%]\s*/;
|
||||
const COMPLETION_CLOSE_KEYS = /[}|-]/;
|
||||
const MAX_HINT_LOOK_BACK = 100;
|
||||
const HINT_DELAY_MILLIS = 700;
|
||||
const TYPE_VARIABLE = 'variable';
|
||||
const TYPE_TAG = 'tag';
|
||||
const TYPE_CONSTANT = 'constant';
|
||||
@@ -126,7 +126,7 @@ CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
|
||||
|
||||
let keydownDebounce = null;
|
||||
|
||||
cm.on('keydown', (cm, e) => {
|
||||
cm.on('keydown', async (cm, e) => {
|
||||
// Close autocomplete on Escape if it's open
|
||||
if (cm.isHintDropdownActive() && e.key === 'Escape') {
|
||||
if (!cm.state.completionActive) {
|
||||
@@ -146,9 +146,14 @@ CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
|
||||
}
|
||||
|
||||
clearTimeout(keydownDebounce);
|
||||
keydownDebounce = setTimeout(() => {
|
||||
completeIfInVariableName(cm);
|
||||
}, HINT_DELAY_MILLIS);
|
||||
|
||||
const { autocompleteDelay } = await models.settings.getOrCreate();
|
||||
|
||||
if (autocompleteDelay > 0) {
|
||||
keydownDebounce = setTimeout(() => {
|
||||
completeIfInVariableName(cm);
|
||||
}, autocompleteDelay);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear timeout if we already closed the completion
|
||||
|
||||
@@ -27,6 +27,7 @@ type Props = {
|
||||
handleGetRenderContext: Function,
|
||||
handleRemoveWorkspace: Function,
|
||||
handleDuplicateWorkspace: Function,
|
||||
handleClearAllResponses: Function,
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -78,6 +79,11 @@ class WorkspaceSettingsModal extends React.PureComponent<Props, State> {
|
||||
this.hide();
|
||||
}
|
||||
|
||||
_handleClearAllResponses() {
|
||||
this.props.handleClearAllResponses();
|
||||
this.hide();
|
||||
}
|
||||
|
||||
_handleDuplicateWorkspace() {
|
||||
this.props.handleDuplicateWorkspace(() => {
|
||||
this.hide();
|
||||
@@ -331,6 +337,12 @@ class WorkspaceSettingsModal extends React.PureComponent<Props, State> {
|
||||
className="width-auto btn btn--clicky inline-block space-left">
|
||||
<i className="fa fa-copy" /> Duplicate
|
||||
</button>
|
||||
<PromptButton
|
||||
onClick={this._handleClearAllResponses}
|
||||
addIcon
|
||||
className="width-auto btn btn--clicky inline-block space-left">
|
||||
<i className="fa fa-trash-o" /> Clear All Responses
|
||||
</PromptButton>
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel className="react-tabs__tab-panel pad scrollable">
|
||||
|
||||
@@ -209,22 +209,40 @@ class General extends React.PureComponent<Props, State> {
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="form-control form-control--outlined pad-top-sm">
|
||||
<label>
|
||||
Environment Highlight Color Style{' '}
|
||||
<HelpTooltip>Configures the appearance of environment's color indicator</HelpTooltip>
|
||||
<select
|
||||
defaultValue={settings.environmentHighlightColorStyle}
|
||||
name="environmentHighlightColorStyle"
|
||||
onChange={this._handleUpdateSetting}>
|
||||
<option value="sidebar-indicator">Sidebar indicator</option>
|
||||
<option value="sidebar-edge">Sidebar edge</option>
|
||||
<option value="window-top">Window top</option>
|
||||
<option value="window-bottom">Window bottom</option>
|
||||
<option value="window-left">Window left</option>
|
||||
<option value="window-right">Window right</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="form-row">
|
||||
<div className="form-control form-control--outlined pad-top-sm">
|
||||
<label>
|
||||
Environment Highlight Color Style{' '}
|
||||
<HelpTooltip>Configures the appearance of environment's color indicator</HelpTooltip>
|
||||
<select
|
||||
defaultValue={settings.environmentHighlightColorStyle}
|
||||
name="environmentHighlightColorStyle"
|
||||
onChange={this._handleUpdateSetting}>
|
||||
<option value="sidebar-indicator">Sidebar indicator</option>
|
||||
<option value="sidebar-edge">Sidebar edge</option>
|
||||
<option value="window-top">Window top</option>
|
||||
<option value="window-bottom">Window bottom</option>
|
||||
<option value="window-left">Window left</option>
|
||||
<option value="window-right">Window right</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div className="form-control form-control--outlined pad-top-sm">
|
||||
<label>
|
||||
Autocomplete popup delay
|
||||
<HelpTooltip className="space-left">
|
||||
Configure the autocomplete popup delay in milliseconds (0 to disable)
|
||||
</HelpTooltip>
|
||||
<input
|
||||
type="number"
|
||||
name="autocompleteDelay"
|
||||
min={0}
|
||||
max={3000}
|
||||
defaultValue={settings.autocompleteDelay}
|
||||
onChange={this._handleUpdateSetting}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
|
||||
@@ -43,6 +43,7 @@ import WorkspaceEnvironmentsEditModal from './modals/workspace-environments-edit
|
||||
import WorkspaceSettingsModal from './modals/workspace-settings-modal';
|
||||
import WorkspaceShareSettingsModal from './modals/workspace-share-settings-modal';
|
||||
import CodePromptModal from './modals/code-prompt-modal';
|
||||
import * as db from '../../common/database';
|
||||
import * as models from '../../models/index';
|
||||
import * as importers from 'insomnia-importers';
|
||||
import type { CookieJar } from '../../models/cookie-jar';
|
||||
@@ -304,6 +305,14 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
await models.workspace.remove(activeWorkspace);
|
||||
}
|
||||
|
||||
async _handleActiveWorkspaceClearAllResponses(): Promise<void> {
|
||||
const docs = await db.withDescendants(this.props.activeWorkspace, models.request.type);
|
||||
const requests = docs.filter(doc => doc.type === models.request.type);
|
||||
for (const req of requests) {
|
||||
await models.response.removeForRequest(req._id);
|
||||
}
|
||||
}
|
||||
|
||||
_handleSendRequestWithActiveEnvironment(): void {
|
||||
const { activeRequest, activeEnvironment, handleSendRequestWithEnvironment } = this.props;
|
||||
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
||||
@@ -320,7 +329,11 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
|
||||
const activeRequestId = activeRequest ? activeRequest._id : 'n/a';
|
||||
const activeEnvironmentId = activeEnvironment ? activeEnvironment._id : 'n/a';
|
||||
await handleSendAndDownloadRequestWithEnvironment(activeRequestId, activeEnvironmentId, filename);
|
||||
await handleSendAndDownloadRequestWithEnvironment(
|
||||
activeRequestId,
|
||||
activeEnvironmentId,
|
||||
filename,
|
||||
);
|
||||
}
|
||||
|
||||
_handleSetPreviewMode(previewMode: string): void {
|
||||
@@ -400,24 +413,24 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
const realSidebarWidth = sidebarHidden ? 0 : sidebarWidth;
|
||||
|
||||
const columns = `${realSidebarWidth}rem 0 minmax(0, ${paneWidth}fr) 0 minmax(0, ${1 -
|
||||
paneWidth}fr)`;
|
||||
paneWidth}fr)`;
|
||||
const rows = `minmax(0, ${paneHeight}fr) 0 minmax(0, ${1 - paneHeight}fr)`;
|
||||
|
||||
return [
|
||||
<div key="modals" className="modals">
|
||||
<ErrorBoundary showAlert>
|
||||
<AlertModal ref={registerModal}/>
|
||||
<ErrorModal ref={registerModal}/>
|
||||
<PromptModal ref={registerModal}/>
|
||||
<AlertModal ref={registerModal} />
|
||||
<ErrorModal ref={registerModal} />
|
||||
<PromptModal ref={registerModal} />
|
||||
|
||||
<WrapperModal ref={registerModal}/>
|
||||
<LoginModal ref={registerModal}/>
|
||||
<AskModal ref={registerModal}/>
|
||||
<SelectModal ref={registerModal}/>
|
||||
<RequestCreateModal ref={registerModal}/>
|
||||
<PaymentNotificationModal ref={registerModal}/>
|
||||
<FilterHelpModal ref={registerModal}/>
|
||||
<RequestRenderErrorModal ref={registerModal}/>
|
||||
<WrapperModal ref={registerModal} />
|
||||
<LoginModal ref={registerModal} />
|
||||
<AskModal ref={registerModal} />
|
||||
<SelectModal ref={registerModal} />
|
||||
<RequestCreateModal ref={registerModal} />
|
||||
<PaymentNotificationModal ref={registerModal} />
|
||||
<FilterHelpModal ref={registerModal} />
|
||||
<RequestRenderErrorModal ref={registerModal} />
|
||||
|
||||
<CodePromptModal
|
||||
ref={registerModal}
|
||||
@@ -472,7 +485,7 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
workspace={activeWorkspace}
|
||||
/>
|
||||
|
||||
<MoveRequestGroupModal ref={registerModal} workspaces={workspaces}/>
|
||||
<MoveRequestGroupModal ref={registerModal} workspaces={workspaces} />
|
||||
|
||||
<WorkspaceSettingsModal
|
||||
ref={registerModal}
|
||||
@@ -487,10 +500,11 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
nunjucksPowerUserMode={settings.nunjucksPowerUserMode}
|
||||
handleRemoveWorkspace={this._handleRemoveActiveWorkspace}
|
||||
handleDuplicateWorkspace={handleDuplicateWorkspace}
|
||||
handleClearAllResponses={this._handleActiveWorkspaceClearAllResponses}
|
||||
isVariableUncovered={isVariableUncovered}
|
||||
/>
|
||||
|
||||
<WorkspaceShareSettingsModal ref={registerModal} workspace={activeWorkspace}/>
|
||||
<WorkspaceShareSettingsModal ref={registerModal} workspace={activeWorkspace} />
|
||||
|
||||
<GenerateCodeModal
|
||||
ref={registerModal}
|
||||
@@ -510,7 +524,7 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
settings={settings}
|
||||
/>
|
||||
|
||||
<ResponseDebugModal ref={registerModal} settings={settings}/>
|
||||
<ResponseDebugModal ref={registerModal} settings={settings} />
|
||||
|
||||
<RequestSwitcherModal
|
||||
ref={registerModal}
|
||||
@@ -535,7 +549,7 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
isVariableUncovered={isVariableUncovered}
|
||||
/>
|
||||
|
||||
<SetupSyncModal ref={registerModal} workspace={activeWorkspace}/>
|
||||
<SetupSyncModal ref={registerModal} workspace={activeWorkspace} />
|
||||
|
||||
<WorkspaceEnvironmentsEditModal
|
||||
ref={registerModal}
|
||||
@@ -623,7 +637,7 @@ class Wrapper extends React.PureComponent<Props, State> {
|
||||
</ErrorBoundary>
|
||||
|
||||
<div className="drag drag--sidebar">
|
||||
<div onDoubleClick={handleResetDragSidebar} onMouseDown={this._handleStartDragSidebar}/>
|
||||
<div onDoubleClick={handleResetDragSidebar} onMouseDown={this._handleStartDragSidebar} />
|
||||
</div>
|
||||
|
||||
<ErrorBoundary showAlert>
|
||||
|
||||
Reference in new issue
Block a user