mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Some autocomplete tweaks and added ctrl+Enter shortcut
This commit is contained in:
parent
39d512c77f
commit
e95dafcf75
@ -60,6 +60,7 @@ export const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
|
||||
export const MOD_SYM = isMac() ? '⌘' : 'ctrl';
|
||||
export const ALT_SYM = isMac() ? '⌃' : 'alt';
|
||||
export const SHIFT_SYM = isMac() ? '⇧' : 'shift';
|
||||
export const CTRL_SYM = isMac() ? '⌃' : 'ctrl';
|
||||
export function joinHotKeys (keys) {
|
||||
return keys.join(isMac() ? '' : '+');
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import {setDefaultProtocol} from './misc';
|
||||
import * as db from './database';
|
||||
import * as templating from '../templating';
|
||||
|
||||
export async function buildRenderContext (ancestors, rootEnvironment, subEnvironment) {
|
||||
export async function buildRenderContext (ancestors, rootEnvironment, subEnvironment, variablesOnly = true) {
|
||||
if (!Array.isArray(ancestors)) {
|
||||
ancestors = [];
|
||||
}
|
||||
@ -52,7 +52,7 @@ export async function buildRenderContext (ancestors, rootEnvironment, subEnviron
|
||||
* original base_url of google.com would be lost.
|
||||
*/
|
||||
if (typeof renderContext[key] === 'string') {
|
||||
renderContext[key] = await render(environment[key], renderContext, null, true);
|
||||
renderContext[key] = await render(environment[key], renderContext, null, variablesOnly);
|
||||
} else {
|
||||
renderContext[key] = environment[key];
|
||||
}
|
||||
@ -64,7 +64,7 @@ export async function buildRenderContext (ancestors, rootEnvironment, subEnviron
|
||||
|
||||
// Render up to 5 levels of recursive references.
|
||||
for (let i = 0; i < 3; i++) {
|
||||
finalRenderContext = await render(finalRenderContext, finalRenderContext, null, true);
|
||||
finalRenderContext = await render(finalRenderContext, finalRenderContext, null, variablesOnly);
|
||||
}
|
||||
|
||||
return finalRenderContext;
|
||||
@ -137,7 +137,7 @@ export async function render (obj, context = {}, blacklistPathRegex = null, vari
|
||||
return next(newObj);
|
||||
}
|
||||
|
||||
export async function getRenderContext (request, environmentId, ancestors = null) {
|
||||
export async function getRenderContext (request, environmentId, ancestors = null, variablesOnly = true) {
|
||||
if (!request) {
|
||||
return {};
|
||||
}
|
||||
@ -154,7 +154,7 @@ export async function getRenderContext (request, environmentId, ancestors = null
|
||||
const subEnvironment = await models.environment.getById(environmentId);
|
||||
|
||||
// Generate the context we need to render
|
||||
return buildRenderContext(ancestors, rootEnvironment, subEnvironment);
|
||||
return buildRenderContext(ancestors, rootEnvironment, subEnvironment, variablesOnly);
|
||||
}
|
||||
|
||||
export async function getRenderedRequest (request, environmentId) {
|
||||
|
@ -148,6 +148,9 @@ CodeMirror.defineOption('environmentAutocomplete', null, (cm, options) => {
|
||||
'Ctrl-Space': completeForce, // Force autocomplete on hotkey
|
||||
"' '": completeIfAfterTagOrVarOpen
|
||||
});
|
||||
|
||||
// Close dropdown whenever something is clicked
|
||||
document.addEventListener('click', () => cm.closeHint());
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,15 @@
|
||||
import React, {PropTypes, PureComponent} from 'react';
|
||||
import {ALT_SYM, isMac, joinHotKeys, MOD_SYM, SHIFT_SYM} from '../../common/constants';
|
||||
import {ALT_SYM, CTRL_SYM, isMac, joinHotKeys, MOD_SYM, SHIFT_SYM} from '../../common/constants';
|
||||
|
||||
class Hotkey extends PureComponent {
|
||||
render () {
|
||||
const {char, shift, alt, className} = this.props;
|
||||
const {char, shift, alt, ctrl, className} = this.props;
|
||||
const chars = [ ];
|
||||
|
||||
alt && chars.push(ALT_SYM);
|
||||
shift && chars.push(SHIFT_SYM);
|
||||
chars.push(MOD_SYM);
|
||||
ctrl && chars.push(CTRL_SYM);
|
||||
!ctrl && chars.push(MOD_SYM);
|
||||
chars.push(char);
|
||||
|
||||
return (
|
||||
@ -25,6 +26,7 @@ Hotkey.propTypes = {
|
||||
// Optional
|
||||
alt: PropTypes.bool,
|
||||
shift: PropTypes.bool,
|
||||
ctrl: PropTypes.bool,
|
||||
className: PropTypes.string
|
||||
};
|
||||
|
||||
|
@ -2,12 +2,12 @@ import React, {PureComponent} from 'react';
|
||||
import Hotkey from '../hotkey';
|
||||
|
||||
class Shortcuts extends PureComponent {
|
||||
renderHotkey (name, char, shift, alt) {
|
||||
renderHotkey (name, char, shift, alt, ctrl) {
|
||||
return (
|
||||
<tr>
|
||||
<td>{name}</td>
|
||||
<td className="text-right">
|
||||
<code><Hotkey char={char} shift={shift} alt={alt}/></code>
|
||||
<code><Hotkey char={char} shift={shift} alt={alt} ctrl={ctrl}/></code>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
@ -26,6 +26,7 @@ class Shortcuts extends PureComponent {
|
||||
{this.renderHotkey('Show Environment Editor', 'E')}
|
||||
{this.renderHotkey('Focus URL Bar', 'L')}
|
||||
{this.renderHotkey('Toggle Sidebar', '\\')}
|
||||
{this.renderHotkey('Show Autocomplete Dropdown', 'Enter', false, false, true)}
|
||||
{this.renderHotkey('Show App Preferences', ',')}
|
||||
{this.renderHotkey('Show Workspace Settings', ',', true)}
|
||||
{this.renderHotkey('Show Request Settings', ',', true, true)}
|
||||
|
@ -228,7 +228,7 @@ class App extends PureComponent {
|
||||
async _fetchRenderContext () {
|
||||
const {activeEnvironment, activeRequest} = this.props;
|
||||
const environmentId = activeEnvironment ? activeEnvironment._id : null;
|
||||
return render.getRenderContext(activeRequest, environmentId);
|
||||
return render.getRenderContext(activeRequest, environmentId, null, false);
|
||||
}
|
||||
|
||||
async _handleGetRenderContext () {
|
||||
|
Loading…
Reference in New Issue
Block a user