mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
ELECTRON-800: add dev tools menu item (#532)
- add dev tools menu item to the troubleshooting menu - add support to dynamically read the dev tools config from file
This commit is contained in:
parent
4c58634010
commit
252456536c
@ -395,6 +395,11 @@ function readConfigFileSync() {
|
||||
|
||||
}
|
||||
|
||||
const readConfigFromFile = (key) => {
|
||||
let data = readConfigFileSync();
|
||||
return data[key];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
configFileName,
|
||||
@ -411,6 +416,7 @@ module.exports = {
|
||||
clearCachedConfigs,
|
||||
|
||||
readConfigFileSync,
|
||||
readConfigFromFile,
|
||||
|
||||
// use only if you specifically need to read global config fields
|
||||
getGlobalConfigField,
|
||||
|
@ -3,7 +3,7 @@
|
||||
const fs = require('fs');
|
||||
const electron = require('electron');
|
||||
|
||||
const { updateConfigField, getMultipleConfigField } = require('../config.js');
|
||||
const { updateConfigField, getMultipleConfigField, readConfigFromFile } = require('../config.js');
|
||||
const { isMac, isWindowsOS } = require('../utils/misc.js');
|
||||
const archiveHandler = require('../utils/archiveHandler');
|
||||
const log = require('../log.js');
|
||||
@ -191,6 +191,24 @@ function getTemplate(app) {
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
|
||||
click(item, focusedWindow) {
|
||||
let devToolsEnabled = readConfigFromFile('devToolsEnabled');
|
||||
if (focusedWindow && devToolsEnabled) {
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
} else {
|
||||
log.send(logLevels.INFO, `dev tools disabled for ${focusedWindow.winName} window`);
|
||||
electron.dialog.showMessageBox(focusedWindow, {
|
||||
type: 'warning',
|
||||
buttons: ['Ok'],
|
||||
title: i18n.getMessageFor('Dev Tools disabled'),
|
||||
message: i18n.getMessageFor('Dev Tools has been disabled! Please contact your system administrator to enable it!'),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: i18n.getMessageFor('More Information'),
|
||||
click(item, focusedWindow) {
|
||||
|
@ -20,7 +20,7 @@ const logLevels = require('./enums/logLevels.js');
|
||||
const notify = require('./notify/electron-notify.js');
|
||||
const eventEmitter = require('./eventEmitter');
|
||||
const throttle = require('./utils/throttle.js');
|
||||
const { getConfigField, updateConfigField, readConfigFileSync, getMultipleConfigField } = require('./config.js');
|
||||
const { getConfigField, updateConfigField, readConfigFileSync, getMultipleConfigField, readConfigFromFile } = require('./config.js');
|
||||
const { isMac, isWindowsOS, isDevEnv } = require('./utils/misc');
|
||||
const { isWhitelisted, parseDomain } = require('./utils/whitelistHandler');
|
||||
const { initCrashReporterMain, initCrashReporterRenderer } = require('./crashReporter.js');
|
||||
@ -614,8 +614,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
||||
|
||||
function devTools() {
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
|
||||
|
||||
devToolsEnabled = readConfigFromFile('devToolsEnabled');
|
||||
if (focusedWindow && !focusedWindow.isDestroyed()) {
|
||||
if (devToolsEnabled) {
|
||||
focusedWindow.webContents.toggleDevTools();
|
||||
|
Loading…
Reference in New Issue
Block a user