From ade31f993b61722c16e97c79bd542a6d111049fc Mon Sep 17 00:00:00 2001 From: V Date: Fri, 12 May 2023 03:41:00 +0200 Subject: [PATCH] Implement plugin tags --- .github/workflows/test.yml | 7 +++++-- scripts/generatePluginList.ts | 9 +++++++++ src/components/PluginSettings/index.tsx | 7 +++++-- src/plugins/imageZoom/index.tsx | 2 ++ src/plugins/reverseImageSearch.tsx | 2 ++ src/plugins/validUser.tsx | 1 + src/plugins/viewIcons.tsx | 1 + 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83fc57c55..46d564184 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,5 +26,8 @@ jobs: - name: Lint & Test if desktop version compiles run: pnpm test - - name: Lint & Test if web version compiles - run: pnpm testWeb + - name: Test if web version compiles + run: pnpm buildWeb + + - name: Test if plugin structure is valid + run: pnpm generatePluginJson diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index e4ae20ad8..8442e4290 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -29,6 +29,7 @@ interface Dev { interface PluginData { name: string; description: string; + tags: string[]; authors: Dev[]; dependencies: string[]; hasPatches: boolean; @@ -106,6 +107,7 @@ async function parseFile(fileName: string) { hasCommands: false, enabledByDefault: false, required: false, + tags: [] as string[] } as PluginData; for (const prop of pluginObj.properties) { @@ -131,6 +133,13 @@ async function parseFile(fileName: string) { return devs[getName(e)!]; }); break; + case "tags": + if (!isArrayLiteralExpression(value)) throw fail("tags is not an array literal"); + data.tags = value.elements.map(e => { + if (!isStringLiteral(e)) throw fail("tags array contains non-string literals"); + return e.text; + }); + break; case "dependencies": if (!isArrayLiteralExpression(value)) throw fail("dependencies is not an array literal"); const { elements } = value; diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 8ccc74073..e1b36ef25 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -228,9 +228,12 @@ export default function PluginSettings() { if (enabled && searchValue.status === SearchStatus.DISABLED) return false; if (!enabled && searchValue.status === SearchStatus.ENABLED) return false; if (!searchValue.value.length) return true; + + const v = searchValue.value.toLowerCase(); return ( - plugin.name.toLowerCase().includes(searchValue.value.toLowerCase()) || - plugin.description.toLowerCase().includes(searchValue.value.toLowerCase()) + plugin.name.toLowerCase().includes(v) || + plugin.description.toLowerCase().includes(v) || + plugin.tags?.some(t => t.toLowerCase().includes(v)) ); }; diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index da6ac697f..d4adcdcae 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -130,6 +130,8 @@ export default definePlugin({ name: "ImageZoom", description: "Lets you zoom in to images and gifs. Use scroll wheel to zoom in and shift + scroll wheel to increase lens radius / size", authors: [Devs.Aria], + tags: ["ImageUtilities"], + patches: [ { find: '"renderLinkComponent","maxWidth"', diff --git a/src/plugins/reverseImageSearch.tsx b/src/plugins/reverseImageSearch.tsx index fd98d0fad..c375e19c3 100644 --- a/src/plugins/reverseImageSearch.tsx +++ b/src/plugins/reverseImageSearch.tsx @@ -76,6 +76,8 @@ export default definePlugin({ name: "ReverseImageSearch", description: "Adds ImageSearch to image context menus", authors: [Devs.Ven, Devs.Nuckyz], + tags: ["ImageUtilities"], + patches: [ { find: ".Messages.MESSAGE_ACTIONS_MENU_LABEL", diff --git a/src/plugins/validUser.tsx b/src/plugins/validUser.tsx index d92269ce3..42349b456 100644 --- a/src/plugins/validUser.tsx +++ b/src/plugins/validUser.tsx @@ -116,6 +116,7 @@ export default definePlugin({ name: "ValidUser", description: "Fix mentions for unknown users showing up as '<@343383572805058560>' (hover over a mention to fix it)", authors: [Devs.Ven], + tags: ["MentionCacheFix"], patches: [{ find: 'className:"mention"', diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 0543a640e..9e7494935 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -145,6 +145,7 @@ export default definePlugin({ name: "ViewIcons", authors: [Devs.Ven, Devs.TheKodeToad, Devs.Nuckyz], description: "Makes avatars and banners in user profiles clickable, and adds View Icon/Banner entries in the user and server context menu", + tags: ["ImageUtilities"], settings,