1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop: Automatically create a bug report when import faild, and allow uploading it to the forum

This commit is contained in:
Laurent Cozic
2023-10-24 12:20:54 +01:00
parent df9db9c702
commit 11eead1cd5
5 changed files with 53 additions and 4 deletions

View 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;
};