mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Desktop: Automatically create a bug report when import faild, and allow uploading it to the forum
This commit is contained in:
parent
df9db9c702
commit
11eead1cd5
@ -627,6 +627,7 @@ packages/lib/import-enex.js
|
|||||||
packages/lib/initLib.js
|
packages/lib/initLib.js
|
||||||
packages/lib/locale.test.js
|
packages/lib/locale.test.js
|
||||||
packages/lib/locale.js
|
packages/lib/locale.js
|
||||||
|
packages/lib/makeDiscourseDebugUrl.js
|
||||||
packages/lib/markdownUtils.test.js
|
packages/lib/markdownUtils.test.js
|
||||||
packages/lib/markdownUtils.js
|
packages/lib/markdownUtils.js
|
||||||
packages/lib/markdownUtils2.test.js
|
packages/lib/markdownUtils2.test.js
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -609,6 +609,7 @@ packages/lib/import-enex.js
|
|||||||
packages/lib/initLib.js
|
packages/lib/initLib.js
|
||||||
packages/lib/locale.test.js
|
packages/lib/locale.test.js
|
||||||
packages/lib/locale.js
|
packages/lib/locale.js
|
||||||
|
packages/lib/makeDiscourseDebugUrl.js
|
||||||
packages/lib/markdownUtils.test.js
|
packages/lib/markdownUtils.test.js
|
||||||
packages/lib/markdownUtils.js
|
packages/lib/markdownUtils.js
|
||||||
packages/lib/markdownUtils2.test.js
|
packages/lib/markdownUtils2.test.js
|
||||||
|
@ -184,11 +184,16 @@ export class Bridge {
|
|||||||
return dialog.showMessageBoxSync(window, options);
|
return dialog.showMessageBoxSync(window, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public showErrorMessageBox(message: string) {
|
public showErrorMessageBox(message: string, options: any = null) {
|
||||||
|
options = {
|
||||||
|
buttons: [_('OK')],
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
return this.showMessageBox_(this.window(), {
|
return this.showMessageBox_(this.window(), {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: message,
|
message: message,
|
||||||
buttons: [_('OK')],
|
buttons: options.buttons,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import { PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins
|
|||||||
import shim from '@joplin/lib/shim';
|
import shim from '@joplin/lib/shim';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
import versionInfo from '@joplin/lib/versionInfo';
|
import versionInfo from '@joplin/lib/versionInfo';
|
||||||
|
import makeDiscourseDebugUrl from '@joplin/lib/makeDiscourseDebugUrl';
|
||||||
import { ImportModule } from '@joplin/lib/services/interop/Module';
|
import { ImportModule } from '@joplin/lib/services/interop/Module';
|
||||||
import InteropServiceHelper from '../InteropServiceHelper';
|
import InteropServiceHelper from '../InteropServiceHelper';
|
||||||
import { _ } from '@joplin/lib/locale';
|
import { _ } from '@joplin/lib/locale';
|
||||||
@ -319,11 +320,27 @@ function useMenu(props: Props) {
|
|||||||
void CommandService.instance().execute('hideModalMessage');
|
void CommandService.instance().execute('hideModalMessage');
|
||||||
|
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
bridge().showErrorMessageBox('There was some errors importing the notes. Please check the console for more details.');
|
const response = bridge().showErrorMessageBox('There was some errors importing the notes - check the console for more details.\n\nPlease consider sending a bug report to the forum!', {
|
||||||
|
buttons: [_('Close'), _('Send bug report')],
|
||||||
|
});
|
||||||
|
|
||||||
props.dispatch({ type: 'NOTE_DEVTOOLS_SET', value: true });
|
props.dispatch({ type: 'NOTE_DEVTOOLS_SET', value: true });
|
||||||
|
|
||||||
|
if (response === 1) {
|
||||||
|
const url = makeDiscourseDebugUrl(
|
||||||
|
`Error importing notes from format: ${module.format}`,
|
||||||
|
`- Input format: ${module.format}\n- Output format: ${module.outputFormat}`,
|
||||||
|
errors,
|
||||||
|
packageInfo,
|
||||||
|
PluginService.instance(),
|
||||||
|
props.pluginSettings,
|
||||||
|
);
|
||||||
|
|
||||||
|
void bridge().openExternal(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied
|
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied
|
||||||
}, [props.selectedFolderId]);
|
}, [props.selectedFolderId, props.pluginSettings]);
|
||||||
|
|
||||||
const onMenuItemClickRef = useRef(null);
|
const onMenuItemClickRef = useRef(null);
|
||||||
onMenuItemClickRef.current = onMenuItemClick;
|
onMenuItemClickRef.current = onMenuItemClick;
|
||||||
|
25
packages/lib/makeDiscourseDebugUrl.ts
Normal file
25
packages/lib/makeDiscourseDebugUrl.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { PluginSettings } from './services/plugins/PluginService';
|
||||||
|
import type PluginService from './services/plugins/PluginService';
|
||||||
|
import versionInfo from './versionInfo';
|
||||||
|
|
||||||
|
const renderErrorBlock = (errors: any[]): string => {
|
||||||
|
if (!errors.length) return '';
|
||||||
|
return `\`\`\`\n${errors.map(e => typeof e === 'string' ? e.trim() : e.message.trim())}\n\`\`\``;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (title: string, body: string, errors: any[], packageInfo: any, pluginService: PluginService, pluginSettings: PluginSettings) => {
|
||||||
|
const v = versionInfo(packageInfo, pluginService.enabledPlugins(pluginSettings));
|
||||||
|
|
||||||
|
const errorBlock = renderErrorBlock(errors);
|
||||||
|
|
||||||
|
const query: Record<string, string> = {
|
||||||
|
title,
|
||||||
|
body: `# About\n\n${v.body.trim()}\n\n# Body\n\n${body}${errorBlock ? `\n\n# Errors\n\n${errorBlock}` : ''}`,
|
||||||
|
category: 'support',
|
||||||
|
};
|
||||||
|
|
||||||
|
const queryString = Object.keys(query).map(k => `${k}=${encodeURIComponent(query[k])}`).join('&');
|
||||||
|
|
||||||
|
const url = `https://discourse.joplinapp.org/new-topic?${queryString}`;
|
||||||
|
return url;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user