1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Add version info to error screen

This commit is contained in:
Laurent Cozic 2020-08-02 16:21:30 +01:00
parent 0718828d60
commit ee358f70dd
5 changed files with 79 additions and 31 deletions

View File

@ -174,6 +174,7 @@ ReactNativeClient/lib/services/synchronizer/utils/types.js
ReactNativeClient/lib/services/UndoRedoService.js
ReactNativeClient/lib/ShareExtension.js
ReactNativeClient/lib/shareHandler.js
ReactNativeClient/lib/versionInfo.js
ReactNativeClient/PluginAssetsLoader.js
ReactNativeClient/setUpQuickActions.js
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD

1
.gitignore vendored
View File

@ -165,6 +165,7 @@ ReactNativeClient/lib/services/synchronizer/utils/types.js
ReactNativeClient/lib/services/UndoRedoService.js
ReactNativeClient/lib/ShareExtension.js
ReactNativeClient/lib/shareHandler.js
ReactNativeClient/lib/versionInfo.js
ReactNativeClient/PluginAssetsLoader.js
ReactNativeClient/setUpQuickActions.js
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD

View File

@ -34,6 +34,7 @@ const KeymapService = require('lib/services/KeymapService.js').default;
const TemplateUtils = require('lib/TemplateUtils');
const CssUtils = require('lib/CssUtils');
const resourceEditWatcherReducer = require('lib/services/ResourceEditWatcher/reducer').default;
const versionInfo = require('lib/versionInfo').default;
const commands = [
require('./gui/Header/commands/focusSearch'),
@ -598,37 +599,17 @@ class Application extends BaseApplication {
}
function _showAbout() {
const p = packageInfo;
let gitInfo = '';
if ('git' in p) {
gitInfo = _('Revision: %s (%s)', p.git.hash, p.git.branch);
}
const copyrightText = 'Copyright © 2016-YYYY Laurent Cozic';
const message = [
p.description,
'',
copyrightText.replace('YYYY', new Date().getFullYear()),
_('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), process.platform),
'',
_('Client ID: %s', Setting.value('clientId')),
_('Sync Version: %s', Setting.value('syncVersion')),
_('Profile Version: %s', reg.db().version()),
_('Keychain Supported: %s', Setting.value('keychain.supported') >= 1 ? _('Yes') : _('No')),
];
if (gitInfo) {
message.push(`\n${gitInfo}`);
console.info(gitInfo);
}
const text = message.join('\n');
const v = versionInfo(packageInfo);
const copyToClipboard = bridge().showMessageBox(text, {
const copyToClipboard = bridge().showMessageBox(v.message, {
icon: `${bridge().electronApp().buildDir()}/icons/128x128.png`,
buttons: [_('Copy'), _('OK')],
cancelId: 1,
defaultId: 1,
});
if (copyToClipboard === 0) {
clipboard.writeText(message.splice(3).join('\n'));
clipboard.writeText(v.message);
}
}
@ -1096,7 +1077,7 @@ class Application extends BaseApplication {
return { action: 'upgradeSyncTarget' };
}
const dir = Setting.value('profileDir');
const dir = Setting.value('profileDir');
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
const filename = Setting.custom_css_files.JOPLIN_APP;

View File

@ -1,4 +1,7 @@
import * as React from 'react';
import versionInfo from 'lib/versionInfo';
const packageInfo = require('../packageInfo.js');
const ipcRenderer = require('electron').ipcRenderer;
export default class ErrorBoundary extends React.Component {
@ -8,22 +11,52 @@ export default class ErrorBoundary extends React.Component {
this.setState({ error: error, errorInfo: errorInfo });
}
componentDidMount() {
const onAppClose = () => {
ipcRenderer.send('asynchronous-message', 'appCloseReply', {
canClose: true,
});
};
ipcRenderer.on('appClose', onAppClose);
}
render() {
if (this.state.error) {
try {
const output = [];
output.push(<h2>Message</h2>);
output.push(<p>{this.state.error.message}</p>);
output.push(
<section key="message">
<h2>Message</h2>
<p>{this.state.error.message}</p>
</section>
);
output.push(
<section key="versionInfo">
<h2>Version info</h2>
<pre>{versionInfo(packageInfo).message}</pre>
</section>
);
if (this.state.error.stack) {
output.push(<h2>Stack trace</h2>);
output.push(<pre>{this.state.error.stack}</pre>);
output.push(
<section key="stacktrace">
<h2>Stack trace</h2>
<pre>{this.state.error.stack}</pre>
</section>
);
}
if (this.state.errorInfo) {
if (this.state.errorInfo.componentStack) {
output.push(<h2>Component stack</h2>);
output.push(<pre>{this.state.errorInfo.componentStack}</pre>);
output.push(
<section key="componentStack">
<h2>Component stack</h2>
<pre>{this.state.errorInfo.componentStack}</pre>
</section>
);
}
}

View File

@ -0,0 +1,32 @@
const Setting = require('lib/models/Setting.js');
const { _ } = require('lib/locale.js');
const { reg } = require('lib/registry.js');
export default function versionInfo(packageInfo:any) {
const p = packageInfo;
let gitInfo = '';
if ('git' in p) {
gitInfo = _('Revision: %s (%s)', p.git.hash, p.git.branch);
}
const copyrightText = 'Copyright © 2016-YYYY Laurent Cozic';
const now = new Date();
const message = [
p.description,
'',
copyrightText.replace('YYYY', `${now.getFullYear()}`),
_('%s %s (%s, %s)', p.name, p.version, Setting.value('env'), process.platform),
'',
_('Client ID: %s', Setting.value('clientId')),
_('Sync Version: %s', Setting.value('syncVersion')),
_('Profile Version: %s', reg.db().version()),
_('Keychain Supported: %s', Setting.value('keychain.supported') >= 1 ? _('Yes') : _('No')),
];
if (gitInfo) {
message.push(`\n${gitInfo}`);
console.info(gitInfo);
}
return {
message: message.join('\n'),
};
}