From 544a045cba51ed82359d2c7ce3bfa97cbc72d49a Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 1 Nov 2017 15:54:57 +0100 Subject: [PATCH] Add shortcut to reload plugins (Closes #544) --- app/main/window-utils.js | 19 ++++++++++++++++++- .../modals/workspace-settings-modal.js | 2 +- app/ui/containers/app.js | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/main/window-utils.js b/app/main/window-utils.js index acd506072..64c4e5aaa 100644 --- a/app/main/window-utils.js +++ b/app/main/window-utils.js @@ -282,7 +282,7 @@ export function createWindow () { position: 'before=help', submenu: [{ label: 'Reload', - accelerator: 'CmdOrCtrl+Shift+R', + accelerator: 'Shift+F5', click: () => mainWindow.reload() }, { label: 'Toggle DevTools', @@ -308,12 +308,29 @@ export function createWindow () { }] }; + const toolsMenu = { + label: 'Tools', + submenu: [{ + label: 'Reload Plugins', + accelerator: 'CmdOrCtrl+Shift+R', + click: () => { + const window = BrowserWindow.getFocusedWindow(); + if (!window || !window.webContents) { + return; + } + + window.webContents.send('reload-plugins'); + } + }] + }; + let template = []; template.push(applicationMenu); template.push(editMenu); template.push(viewMenu); template.push(windowMenu); + template.push(toolsMenu); template.push(helpMenu); if (isDevelopment() || process.env.INSOMNIA_FORCE_DEBUG) { diff --git a/app/ui/components/modals/workspace-settings-modal.js b/app/ui/components/modals/workspace-settings-modal.js index 47667320a..9c0950450 100644 --- a/app/ui/components/modals/workspace-settings-modal.js +++ b/app/ui/components/modals/workspace-settings-modal.js @@ -371,7 +371,7 @@ class WorkspaceSettingsModal extends React.PureComponent {
diff --git a/app/ui/containers/app.js b/app/ui/containers/app.js index f6ede601d..87d95c157 100644 --- a/app/ui/containers/app.js +++ b/app/ui/containers/app.js @@ -39,6 +39,8 @@ import * as hotkeys from '../../common/hotkeys'; import {executeHotKey} from '../../common/hotkeys'; import KeydownBinder from '../components/keydown-binder'; import ErrorBoundary from '../components/error-boundary'; +import * as plugins from '../../plugins'; +import * as templating from '../../templating/index'; @autobind class App extends PureComponent { @@ -685,6 +687,12 @@ class App extends PureComponent { showModal(SettingsModal); }); + ipcRenderer.on('reload-plugins', async () => { + await plugins.getPlugins(true); + templating.reload(); + console.log('[plugins] reloaded'); + }); + ipcRenderer.on('toggle-preferences-shortcuts', () => { showModal(SettingsModal, TAB_INDEX_SHORTCUTS); });