1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-30 23:44:55 +02:00

Desktop: Sort plugin results according to recommended property, and display Recommended tag

This commit is contained in:
Laurent Cozic
2021-09-01 12:17:20 +01:00
parent 9c44133bd0
commit d97ba57dda
5 changed files with 56 additions and 1 deletions

View File

@ -24,6 +24,13 @@ export default function manifestFromObject(o: any): PluginManifest {
return o[name];
};
const getBoolean = (name: string, required: boolean = true, defaultValue: boolean = false): boolean => {
if (required && !o[name]) throw new Error(`Missing required field: ${name}`);
if (!o[name]) return defaultValue;
if (typeof o[name] !== 'boolean') throw new Error(`Field must be a boolean: ${name}`);
return o[name];
};
const permissions: PluginPermission[] = [];
const manifest: PluginManifest = {
@ -39,6 +46,8 @@ export default function manifestFromObject(o: any): PluginManifest {
repository_url: getString('repository_url', false),
keywords: getStrings('keywords', false),
permissions: permissions,
_recommended: getBoolean('_recommended', false, false),
};
validatePluginId(manifest.id);