From f66340cb63d149786f09d8979266484ad1502346 Mon Sep 17 00:00:00 2001 From: SethBurkart123 Date: Sun, 25 May 2025 10:21:24 +1000 Subject: [PATCH] feat: add beta tag to global search plugin --- docs/plugins/README.md | 38 +++++++++++++++++-- docs/plugins/api-reference.md | 30 +++++++++++++++ src/interface/pages/settings/general.svelte | 10 ++++- .../built-in/globalSearch/src/core/index.ts | 1 + src/plugins/built-in/test/index.ts | 1 + src/plugins/core/manager.ts | 2 + src/plugins/core/types.ts | 1 + 7 files changed, 78 insertions(+), 5 deletions(-) diff --git a/docs/plugins/README.md b/docs/plugins/README.md index 23e9ce68..35510f09 100644 --- a/docs/plugins/README.md +++ b/docs/plugins/README.md @@ -29,6 +29,9 @@ const myFirstPlugin: Plugin = { // This tells BetterSEQTA+ that users can turn our plugin on/off disableToggle: true, + // Optional: Mark your plugin as beta to show a "Beta" tag in settings + beta: true, + // This is where the magic happens! run: async (api) => { // Wait for the homepage to load @@ -65,10 +68,11 @@ Let's break down what's happening here: - `description`: Explain what your plugin does - `version`: Your plugin's version number 3. We set `disableToggle: true` so users can turn our plugin on/off in settings -4. The `run` function is where we put our plugin's code -5. We use `api.seqta.onMount` to wait for the homepage to load -6. We create and style a message element -7. We return a cleanup function that removes our changes when the plugin is disabled +4. We set `beta: true` to mark the plugin as beta +5. The `run` function is where we put our plugin's code +6. We use `api.seqta.onMount` to wait for the homepage to load +7. We create and style a message element +8. We return a cleanup function that removes our changes when the plugin is disabled ## The Plugin API @@ -246,6 +250,32 @@ Here are some tips to make your plugin awesome: - Add clear settings with good descriptions - Use `disableToggle: true` so users can turn it off if needed - Add helpful error messages if something goes wrong + - Use `beta: true` for experimental features to let users know they're trying something new + +## Plugin Metadata Options + +Your plugin object supports several optional flags to customize how it appears and behaves: + +```typescript +const myPlugin: Plugin = { + id: "my-plugin", + name: "My Plugin", + description: "What my plugin does", + version: "1.0.0", + + // Optional flags: + disableToggle: true, // Show enable/disable toggle in settings + defaultEnabled: false, // Start disabled by default (requires disableToggle: true) + beta: true, // Show "Beta" tag in settings UI + + // Your plugin code... + run: async (api) => { /* ... */ }, +}; +``` + +- **`disableToggle`**: When `true`, users can enable/disable your plugin in settings +- **`defaultEnabled`**: When `false`, your plugin starts disabled (only works with `disableToggle: true`) +- **`beta`**: When `true`, shows an orange "Beta" tag next to your plugin name in settings ## Examples diff --git a/docs/plugins/api-reference.md b/docs/plugins/api-reference.md index c2613205..c057a277 100644 --- a/docs/plugins/api-reference.md +++ b/docs/plugins/api-reference.md @@ -41,6 +41,7 @@ const myPlugin: Plugin = { version: "1.0.0", settings: settingsInstance.settings, disableToggle: true, + beta: true, run: async (api) => { console.log("Plugin is running!"); @@ -62,6 +63,35 @@ const myPlugin: Plugin = { export default myPlugin; ``` +## Plugin Metadata + +The plugin object supports several metadata fields and options: + +```typescript +interface Plugin { + // Required fields + id: string; // Unique identifier (lowercase, dashes) + name: string; // Display name shown to users + description: string; // Brief description of what the plugin does + version: string; // Semantic version (e.g., "1.0.0") + settings: PluginSettings; // Plugin settings object + run: (api: PluginAPI) => void; // Main plugin function + + // Optional fields + styles?: string; // CSS styles to inject + disableToggle?: boolean; // Show enable/disable toggle in settings + defaultEnabled?: boolean; // Start enabled/disabled (requires disableToggle) + beta?: boolean; // Show "Beta" tag in settings UI +} +``` + +### Metadata Options + +- **`disableToggle`**: When `true`, users can enable/disable your plugin in the settings page +- **`defaultEnabled`**: When `false`, your plugin starts disabled by default (only works with `disableToggle: true`) +- **`beta`**: When `true`, displays an orange "Beta" tag next to your plugin name in the settings UI +- **`styles`**: CSS string that gets injected into the page when your plugin runs + ## SEQTA API The SEQTA API helps you interact with SEQTA's pages: diff --git a/src/interface/pages/settings/general.svelte b/src/interface/pages/settings/general.svelte index 8b2533a7..76efb822 100644 --- a/src/interface/pages/settings/general.svelte +++ b/src/interface/pages/settings/general.svelte @@ -33,6 +33,7 @@ pluginId: string; name: string; description: string; + beta?: boolean; settings: Record; } @@ -194,7 +195,14 @@ {#if (plugin as any).disableToggle}
-

Enable {plugin.name}

+

+ Enable {plugin.name} + {#if plugin.beta} + + Beta + + {/if} +

{plugin.description}

diff --git a/src/plugins/built-in/globalSearch/src/core/index.ts b/src/plugins/built-in/globalSearch/src/core/index.ts index 5f101c92..3c26c524 100644 --- a/src/plugins/built-in/globalSearch/src/core/index.ts +++ b/src/plugins/built-in/globalSearch/src/core/index.ts @@ -93,6 +93,7 @@ const globalSearchPlugin: Plugin = { settings: settingsInstance.settings, disableToggle: true, defaultEnabled: false, + beta: true, styles: styles, run: async (api) => { diff --git a/src/plugins/built-in/test/index.ts b/src/plugins/built-in/test/index.ts index 4e3494d1..b9fd4bc6 100644 --- a/src/plugins/built-in/test/index.ts +++ b/src/plugins/built-in/test/index.ts @@ -31,6 +31,7 @@ const testPlugin: Plugin = { version: "1.0.0", settings: settingsInstance.settings, disableToggle: true, + beta: true, run: async (api) => { console.log("Test plugin running"); diff --git a/src/plugins/core/manager.ts b/src/plugins/core/manager.ts index c5ded4d8..f973a08c 100644 --- a/src/plugins/core/manager.ts +++ b/src/plugins/core/manager.ts @@ -182,6 +182,7 @@ export class PluginManager { pluginId: string; name: string; description: string; + beta?: boolean; settings: { [key: string]: | (Omit & { type: "boolean"; id: string }) @@ -235,6 +236,7 @@ export class PluginManager { pluginId: id, name: plugin.name, description: plugin.description, + beta: plugin.beta, settings: Object.fromEntries(settingsEntries), disableToggle: plugin.disableToggle, }; diff --git a/src/plugins/core/types.ts b/src/plugins/core/types.ts index e11e7df9..eb8cfce8 100644 --- a/src/plugins/core/types.ts +++ b/src/plugins/core/types.ts @@ -132,6 +132,7 @@ export interface Plugin { styles?: string; // Optional CSS styles for the plugin disableToggle?: boolean; // Optional flag to show/hide the plugin's enable/disable toggle in settings defaultEnabled?: boolean; // Optional flag to set the plugin's default enabled state + beta?: boolean; // Optional flag to mark the plugin as beta run: ( api: PluginAPI, ) => void | Promise | (() => void) | Promise<() => void>;