mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -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:
committed by
GitHub
parent
4c58634010
commit
252456536c
@@ -395,6 +395,11 @@ function readConfigFileSync() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const readConfigFromFile = (key) => {
|
||||||
|
let data = readConfigFileSync();
|
||||||
|
return data[key];
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
configFileName,
|
configFileName,
|
||||||
@@ -411,6 +416,7 @@ module.exports = {
|
|||||||
clearCachedConfigs,
|
clearCachedConfigs,
|
||||||
|
|
||||||
readConfigFileSync,
|
readConfigFileSync,
|
||||||
|
readConfigFromFile,
|
||||||
|
|
||||||
// use only if you specifically need to read global config fields
|
// use only if you specifically need to read global config fields
|
||||||
getGlobalConfigField,
|
getGlobalConfigField,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const electron = require('electron');
|
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 { isMac, isWindowsOS } = require('../utils/misc.js');
|
||||||
const archiveHandler = require('../utils/archiveHandler');
|
const archiveHandler = require('../utils/archiveHandler');
|
||||||
const log = require('../log.js');
|
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'),
|
label: i18n.getMessageFor('More Information'),
|
||||||
click(item, focusedWindow) {
|
click(item, focusedWindow) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const logLevels = require('./enums/logLevels.js');
|
|||||||
const notify = require('./notify/electron-notify.js');
|
const notify = require('./notify/electron-notify.js');
|
||||||
const eventEmitter = require('./eventEmitter');
|
const eventEmitter = require('./eventEmitter');
|
||||||
const throttle = require('./utils/throttle.js');
|
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 { isMac, isWindowsOS, isDevEnv } = require('./utils/misc');
|
||||||
const { isWhitelisted, parseDomain } = require('./utils/whitelistHandler');
|
const { isWhitelisted, parseDomain } = require('./utils/whitelistHandler');
|
||||||
const { initCrashReporterMain, initCrashReporterRenderer } = require('./crashReporter.js');
|
const { initCrashReporterMain, initCrashReporterRenderer } = require('./crashReporter.js');
|
||||||
@@ -614,8 +614,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
|||||||
|
|
||||||
function devTools() {
|
function devTools() {
|
||||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||||
|
devToolsEnabled = readConfigFromFile('devToolsEnabled');
|
||||||
|
|
||||||
if (focusedWindow && !focusedWindow.isDestroyed()) {
|
if (focusedWindow && !focusedWindow.isDestroyed()) {
|
||||||
if (devToolsEnabled) {
|
if (devToolsEnabled) {
|
||||||
focusedWindow.webContents.toggleDevTools();
|
focusedWindow.webContents.toggleDevTools();
|
||||||
|
|||||||
Reference in New Issue
Block a user