ELECTRON-907: add more info menu item

- add a new menu item that displays version information about the app
- bump up the version number
This commit is contained in:
Vishwas Shashidhar 2018-11-28 16:42:46 -08:00
parent 7e8814f862
commit afdaa39836
13 changed files with 249 additions and 10 deletions

View File

@ -12,7 +12,7 @@ delete_app()
compare_versions()
{
# Get the installer version:
CURRENT_VERSION=3.4.0
CURRENT_VERSION=4.0.0-beta.7
# Get the currently installed version:
INSTALLED_VERSION=$(plutil -p /Applications/Symphony.app/Contents/Info.plist | awk '/CFBundleShortVersionString/ {print substr($3, 2, length($3)-2)}')

View File

@ -14,7 +14,7 @@ const { version, clientVersion, buildNumber } = require('../package.json');
const log = require('./log.js');
const logLevels = require('./enums/logLevels.js');
log.send(logLevels.INFO, `-----------------Starting the app-----------------`);
log.send(logLevels.INFO, `-----------------Starting the app with version ${version}-----------------`);
// Local Dependencies
require('./stats');
@ -28,12 +28,6 @@ const compareSemVersions = require('./utils/compareSemVersions.js');
const { isMac, isDevEnv } = require('./utils/misc.js');
const getCmdLineArg = require('./utils/getCmdLineArg.js');
const symDebug = getCmdLineArg(process.argv, '--sym-debug', true) || isDevEnv;
if (symDebug) {
log.send(logLevels.INFO, `-----------------DEBUG MODE-----------------`);
process.env.ELECTRON_ENABLE_LOGGING = true;
}
//setting the env path child_process issue https://github.com/electron/electron/issues/7688
shellPath()
.then((path) => {
@ -471,4 +465,4 @@ const handlePowerEvents = () => {
log.send(logLevels.INFO, `Power Monitor Event Occurred: ${appEvent}`)
});
});
}
};

View File

@ -10,6 +10,7 @@ const log = require('../log.js');
const logLevels = require('../enums/logLevels.js');
const eventEmitter = require('../eventEmitter');
const aboutApp = require('../aboutApp');
const moreInfo = require('../moreInfo');
const titleBarStyles = require('../enums/titleBarStyles');
const i18n = require('../translation/i18n');
const autoLaunch = require('../autoLaunch');
@ -189,6 +190,13 @@ function getTemplate(app) {
}
});
}
},
{
label: i18n.getMessageFor('More Information'),
click(item, focusedWindow) {
let windowName = focusedWindow ? focusedWindow.name : '';
moreInfo.openMoreInfoWindow(windowName);
}
}
]
}

132
js/moreInfo/index.js Normal file
View File

@ -0,0 +1,132 @@
'use strict';
const electron = require('electron');
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const fs = require('fs');
const log = require('../log.js');
const logLevels = require('../enums/logLevels.js');
const { version, clientVersion, buildNumber } = require('../../package.json');
const { initCrashReporterMain, initCrashReporterRenderer } = require('../crashReporter.js');
const i18n = require('../translation/i18n');
const { isMac } = require('../utils/misc');
let moreInfoWindow;
let windowConfig = {
width: 800,
height: 600,
show: false,
modal: true,
autoHideMenuBar: true,
titleBarStyle: true,
resizable: false,
fullscreenable: false,
webPreferences: {
preload: path.join(__dirname, 'renderer.js'),
sandbox: true,
nodeIntegration: false,
devTools: false
}
};
/**
* method to get the HTML template path
* @returns {string}
*/
function getTemplatePath() {
let templatePath = path.join(__dirname, 'more-info.html');
try {
fs.statSync(templatePath).isFile();
} catch (err) {
log.send(logLevels.ERROR, 'more-info: Could not find template ("' + templatePath + '").');
}
return 'file://' + templatePath;
}
/**
* Opens the about application window for a specific window
* @param {String} windowName - name of the window upon
* which this window should show
*/
function openMoreInfoWindow(windowName) {
// This prevents creating multiple instances of the
// about window
if (moreInfoWindow) {
if (moreInfoWindow.isMinimized()) {
moreInfoWindow.restore();
}
moreInfoWindow.focus();
return;
}
let allWindows = BrowserWindow.getAllWindows();
allWindows = allWindows.find((window) => { return window.winName === windowName });
// if we couldn't find any window matching the window name
// it will render as a new window
if (allWindows) {
windowConfig.parent = allWindows;
}
moreInfoWindow = new BrowserWindow(windowConfig);
moreInfoWindow.setVisibleOnAllWorkspaces(true);
moreInfoWindow.loadURL(getTemplatePath());
// sets the AlwaysOnTop property for the about window
// if the main window's AlwaysOnTop is true
let focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow && focusedWindow.isAlwaysOnTop()) {
moreInfoWindow.setAlwaysOnTop(true);
}
moreInfoWindow.once('ready-to-show', () => {
moreInfoWindow.show();
});
moreInfoWindow.webContents.on('did-finish-load', () => {
// initialize crash reporter
initCrashReporterMain({ process: 'more info window' });
initCrashReporterRenderer(moreInfoWindow, { process: 'render | more info window' });
moreInfoWindow.webContents.send('versionInfo', { version, clientVersion, buildNumber });
if (!isMac) {
// prevents from displaying menu items when "alt" key is pressed
moreInfoWindow.setMenu(null);
}
});
moreInfoWindow.webContents.on('crashed', function () {
const options = {
type: 'error',
title: i18n.getMessageFor('Renderer Process Crashed'),
message: i18n.getMessageFor('Oops! Looks like we have had a crash.'),
buttons: ['Close']
};
electron.dialog.showMessageBox(options, function () {
if (moreInfoWindow && !moreInfoWindow.isDestroyed()) {
moreInfoWindow.close();
}
});
});
moreInfoWindow.on('close', () => {
destroyWindow();
});
moreInfoWindow.on('closed', () => {
destroyWindow();
});
}
/**
* Destroys a window
*/
function destroyWindow() {
moreInfoWindow = null;
}
module.exports = {
openMoreInfoWindow: openMoreInfoWindow
};

View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>More Information</title>
<style>
html, body {
margin: 0;
height: 100%;
font-family: sans-serif;
}
.version-text {
flex: 1;
font-size: 1em;
color: #2f2f2f;
}
.content {
text-align: center;
display: flex;
flex-direction: column;
padding-top: 20px
}
.logo {
margin: auto;
}
</style>
</head>
<body>
<div class="content">
<span><b>Version Information</b></span>
<span id="electron" class="content"></span>
<span id="chromium" class="content"></span>
<span id="v8" class="content"></span>
<span id="node" class="content"></span>
<span id="openssl" class="content"></span>
<span id="zlib" class="content"></span>
<span id="uv" class="content"></span>
<span id="ares" class="content"></span>
<span id="httpparser" class="content"></span>
</div>
</body>
</html>

54
js/moreInfo/renderer.js Normal file
View File

@ -0,0 +1,54 @@
'use strict';
const { ipcRenderer, crashReporter } = require('electron');
renderDom();
/**
* Method that renders application data
*/
function renderDom() {
document.addEventListener('DOMContentLoaded', function () {
const electronV = document.getElementById('electron');
const chromiumV = document.getElementById('chromium');
const v8V = document.getElementById('v8');
const nodeV = document.getElementById('node');
const opensslV = document.getElementById('openssl');
const zlibV = document.getElementById('zlib');
const uvV = document.getElementById('uv');
const aresV = document.getElementById('ares');
const httpparserV = document.getElementById('httpparser');
electronV.innerHTML = `<u>Electron</u> ${process.versions.electron}`;
chromiumV.innerHTML = `<u>Chromium</u> ${process.versions.chrome}`;
v8V.innerHTML = `<u>V8</u> ${process.versions.v8}`;
nodeV.innerHTML = `<u>Node</u> ${process.versions.node}`;
opensslV.innerHTML = `<u>OpenSSL</u> ${process.versions.openssl}`;
zlibV.innerHTML = `<u>ZLib</u> ${process.versions.zlib}`;
uvV.innerHTML = `<u>UV</u> ${process.versions.uv}`;
aresV.innerHTML = `<u>Ares</u> ${process.versions.ares}`;
httpparserV.innerHTML = `<u>HTTP Parser</u> ${process.versions.http_parser}`;
});
}
ipcRenderer.on('register-crash-reporter', (event, arg) => {
if (arg && typeof arg === 'object') {
crashReporter.start(arg);
}
});
// note: this is a workaround until
// https://github.com/electron/electron/issues/8841
// is fixed on the electron. where 'will-navigate'
// is never fired in sandbox mode
//
// This is required in order to prevent from loading
// dropped content
window.addEventListener('drop', function(e) {
e.preventDefault();
e.stopPropagation();
});
window.addEventListener('dragover', function(e) {
e.preventDefault();
e.stopPropagation();
});

View File

@ -121,6 +121,7 @@
"Show All": "Show All",
"Show crash dump in Explorer": "Show crash dump in Explorer",
"Show crash dump in Finder": "Show crash dump in Finder",
"More Information": "More Information",
"Show Logs in Explorer": "Show Logs in Explorer",
"Show Logs in Finder": "Show Logs in Finder",
"SnackBar": {

View File

@ -119,6 +119,7 @@
"Show All": "Show All",
"Show crash dump in Explorer": "Show crash dump in Explorer",
"Show crash dump in Finder": "Show crash dump in Finder",
"More Information": "More Information",
"Show Logs in Explorer": "Show Logs in Explorer",
"Show Logs in Finder": "Show Logs in Finder",
"SnackBar": {

View File

@ -119,6 +119,7 @@
"Show All":"Tout afficher",
"Show crash dump in Explorer":"Afficher rapport de crash dans Explorateur",
"Show crash dump in Finder":"Afficher rapport de crash dans Finder",
"More Information": "Plus d'information",
"Show Logs in Explorer":"Afficher journal d'évenements dans Explorateur",
"Show Logs in Finder":"Afficher journal d'évenements dans Finder",
"SnackBar":{

View File

@ -119,6 +119,7 @@
"Show All":"Tout afficher",
"Show crash dump in Explorer":"Afficher rapport de crash dans Explorateur",
"Show crash dump in Finder":"Afficher rapport de crash dans Finder",
"More Information": "Plus d'information",
"Show Logs in Explorer":"Afficher journal d'évenements dans Explorateur",
"Show Logs in Finder":"Afficher journal d'évenements dans Finder",
"SnackBar":{

View File

@ -121,6 +121,7 @@
"Show All": "すべてを表示",
"Show crash dump in Explorer": "Explorerにクラッシュダンプを表示",
"Show crash dump in Finder": "ファインダーにクラッシュダンプを表示",
"More Information": "詳しくは",
"Show Logs in Explorer": "Explorerにログを表示",
"Show Logs in Finder": "ファインダーにログを表示",
"SnackBar": {

View File

@ -119,6 +119,7 @@
"Show All": "すべてを表示",
"Show crash dump in Explorer": "Explorerにクラッシュダンプを表示",
"Show crash dump in Finder": "ファインダーにクラッシュダンプを表示",
"More Information": "詳しくは",
"Show Logs in Explorer": "Explorerにログを表示",
"Show Logs in Finder": "ファインダーにログを表示",
"SnackBar": {

View File

@ -1,7 +1,7 @@
{
"name": "Symphony",
"productName": "Symphony",
"version": "3.5.0",
"version": "4.0.0-beta.1",
"clientVersion": "1.53",
"buildNumber": "0",
"description": "Symphony desktop app (Foundation ODP)",