Agent Zero AI framework
cleanup plugin installer and store wiring
Alessandro4515502cea29
diff --git a/plugins/plugin_installer/webui/install-detail.html b/plugins/plugin_installer/webui/install-detail.htmlindex 7cb027cd1..8f2ffa67c 100644--- a/plugins/plugin_installer/webui/install-detail.html+++ b/plugins/plugin_installer/webui/install-detail.html@@ -97,7 +97,7 @@<img class="pi-screenshot-thumb":src="url":alt="$store.pluginInstallStore.selectedPlugin.title + ' screenshot ' + (i + 1)"- @click="$store.imageViewer.open(url, { name: $store.pluginInstallStore.selectedPlugin.title })">+ @click="$store.pluginInstallStore.openScreenshot(url)"></template></div></div>diff --git a/plugins/plugin_installer/webui/install-git.html b/plugins/plugin_installer/webui/install-git.htmlindex 891c029b4..d4c66f951 100644--- a/plugins/plugin_installer/webui/install-git.html+++ b/plugins/plugin_installer/webui/install-git.html@@ -8,8 +8,7 @@<body><div x-data><template x-if="$store.pluginInstallStore">- <div x-init="$store.pluginInstallStore.resetGit()"- x-destroy="$store.pluginInstallStore.refreshPluginList()">+ <div x-create="$store.pluginInstallStore.resetGit()"><div class="pi-form-group"><label class="pi-label">Git Repository URL</label>diff --git a/plugins/plugin_installer/webui/install-index.html b/plugins/plugin_installer/webui/install-index.htmlindex ae16be980..c1db98331 100644--- a/plugins/plugin_installer/webui/install-index.html+++ b/plugins/plugin_installer/webui/install-index.html@@ -9,8 +9,7 @@<div x-data><template x-if="$store.pluginInstallStore"><div class="pi-browse-shell"- x-init="$store.pluginInstallStore.resetIndex(); $store.pluginInstallStore.fetchIndex()"- x-destroy="$store.pluginInstallStore.refreshPluginList()">+ x-create="$store.pluginInstallStore.resetIndex(); $store.pluginInstallStore.fetchIndex()"><section class="pi-browse-hero"><div class="pi-browse-copy">diff --git a/plugins/plugin_installer/webui/install-zip.html b/plugins/plugin_installer/webui/install-zip.htmlindex e9721fdd9..ea28816e6 100644--- a/plugins/plugin_installer/webui/install-zip.html+++ b/plugins/plugin_installer/webui/install-zip.html@@ -8,8 +8,7 @@<body><div x-data><template x-if="$store.pluginInstallStore">- <div x-init="$store.pluginInstallStore.resetZip()"- x-destroy="$store.pluginInstallStore.refreshPluginList()">+ <div x-create="$store.pluginInstallStore.resetZip()"><div class="pi-upload-section"><label for="plugin-zip-file" class="pi-upload-btn button confirm"diff --git a/plugins/plugin_installer/webui/main.html b/plugins/plugin_installer/webui/main.htmlindex 30413d077..bf7a98089 100644--- a/plugins/plugin_installer/webui/main.html+++ b/plugins/plugin_installer/webui/main.html@@ -10,7 +10,7 @@<body><div x-data><template x-if="$store.pluginInstallStore">- <div x-init="$store.pluginInstallStore.setTab('store')"+ <div x-create="$store.pluginInstallStore.setTab('store')"x-destroy="$store.pluginInstallStore.refreshPluginList()"><ul class="nav nav-tabs" role="tablist">@@ -34,244 +34,17 @@</li></ul>- <!-- ═══ Store Tab ═══ -->- <div x-show="$store.pluginInstallStore.activeTab === 'store'"- x-init="$store.pluginInstallStore.resetIndex(); $store.pluginInstallStore.fetchIndex()">-- <div class="pi-browse-shell">- <section class="pi-browse-hero">- <div class="pi-browse-copy">- <div class="pi-browse-eyebrow">Community Marketplace</div>- <h2 class="pi-browse-title">Discover community plugins for Agent Zero</h2>- <p class="pi-browse-description">- These plugins are provided by the community of Agent Zero. Contribute by publishing- in the <a href="https://github.com/agent0ai/a0-plugins" target="_blank">index- repository</a>.- </p>- </div>- <div class="pi-browse-summary" x-text="$store.pluginInstallStore.browseResultsSummary">- </div>- </section>-- <div class="pi-index-toolbar">- <label class="pi-search-field">- <span class="material-symbols-outlined">search</span>- <input type="text" class="pi-search-input" x-model="$store.pluginInstallStore.search"- @input="$store.pluginInstallStore.page = 1"- placeholder="Search plugins, authors, or tags...">- </label>-- <label class="pi-sort-field">- <span class="pi-field-label">Sort</span>- <select class="pi-sort-select" x-model="$store.pluginInstallStore.sortBy">- <option value="stars">Stars</option>- <option value="name">Name</option>- </select>- </label>- </div>-- <div class="pi-filter-row" x-show="$store.pluginInstallStore.browseFilters.length > 1">- <template x-for="filter in $store.pluginInstallStore.browseFilters" :key="filter.key">- <button type="button" class="pi-filter-chip"- :class="{ active: $store.pluginInstallStore.browseFilter === filter.key }"- @click="$store.pluginInstallStore.setBrowseFilter(filter.key)">- <span x-text="filter.label"></span>- <span class="pi-filter-count" x-text="filter.count"></span>- </button>- </template>- </div>-- <div x-show="$store.pluginInstallStore.loading" class="pi-state-card pi-state-loading">- <span class="material-symbols-outlined">progress_activity</span>- <div>- <div class="pi-state-title">Loading marketplace</div>- <div class="pi-state-text"- x-text="$store.pluginInstallStore.loadingMessage || 'Loading plugins...'"></div>- </div>- </div>-- <div x-show="$store.pluginInstallStore.error && !$store.pluginInstallStore.loading"- class="pi-state-card pi-state-error">- <span class="material-symbols-outlined">error</span>- <div>- <div class="pi-state-title">Marketplace unavailable</div>- <div class="pi-state-text" x-text="$store.pluginInstallStore.error"></div>- </div>- </div>-- <div x-show="$store.pluginInstallStore.index && !$store.pluginInstallStore.loading && $store.pluginInstallStore.filteredPlugins.length > 0"- class="pi-grid">- <template x-for="plugin in $store.pluginInstallStore.paginatedPlugins" :key="plugin.key">- <button type="button" class="pi-card"- @click="$store.pluginInstallStore.openDetail(plugin)">- <div class="pi-card-thumb">- <template x-if="plugin.thumbnail">- <img :src="plugin.thumbnail" :alt="plugin.title" loading="lazy">- </template>- <template x-if="!plugin.thumbnail">- <span class="material-symbols-outlined pi-card-placeholder">extension</span>- </template>-- <template x-if="plugin.installed">- <span class="pi-card-installed-pill">Installed</span>- </template>- </div>-- <div class="pi-card-body">- <div class="pi-card-head">- <div class="pi-card-heading">- <h3 class="pi-card-title" x-text="plugin.title || plugin.key"></h3>- <div class="pi-card-subtitle"- x-text="$store.pluginInstallStore.getBrowseSubtitle(plugin)">- </div>- </div>- <span class="material-symbols-outlined pi-card-arrow">arrow_outward</span>- </div>-- <div class="pi-card-desc"- x-text="$store.pluginInstallStore.truncate(plugin.description, 110)">- </div>- </div>-- <div class="pi-card-footer">- <span class="pi-card-stars">- <span class="material-symbols-outlined">star</span>- <span x-text="plugin.stars || 0"></span>- </span>-- <template x-if="$store.pluginInstallStore.getBrowsePrimaryTag(plugin)">- <span class="pi-card-tag"- x-text="$store.pluginInstallStore.getBrowsePrimaryTag(plugin)">- </span>- </template>- </div>- </button>- </template>- </div>-- <div x-show="$store.pluginInstallStore.index && !$store.pluginInstallStore.loading && $store.pluginInstallStore.filteredPlugins.length === 0"- class="pi-state-card pi-state-empty">- <span class="material-symbols-outlined">search_off</span>- <div>- <div class="pi-state-title">No plugins match this view</div>- <div class="pi-state-text">- Try a different search or switch to another marketplace filter.- </div>- </div>- </div>-- <div x-show="$store.pluginInstallStore.totalPages > 1" class="pi-pagination">- <button class="button" :disabled="$store.pluginInstallStore.page <= 1"- @click="$store.pluginInstallStore.setPage($store.pluginInstallStore.page - 1)">- <span class="material-symbols-outlined">chevron_left</span>- </button>- <span class="pi-page-info"- x-text="'Page ' + $store.pluginInstallStore.page + ' of ' + $store.pluginInstallStore.totalPages">- </span>- <button class="button"- :disabled="$store.pluginInstallStore.page >= $store.pluginInstallStore.totalPages"- @click="$store.pluginInstallStore.setPage($store.pluginInstallStore.page + 1)">- <span class="material-symbols-outlined">chevron_right</span>- </button>- </div>- </div>- </div>-- <!-- ═══ Git Tab ═══ -->- <div x-show="$store.pluginInstallStore.activeTab === 'git'"- x-init="$store.pluginInstallStore.resetGit()">-- <div class="pi-form-group">- <label class="pi-label">Git Repository URL</label>- <input type="text" class="pi-input" x-model="$store.pluginInstallStore.gitUrl"- :disabled="$store.pluginInstallStore.loading"- placeholder="https://github.com/user/my-plugin.git">- </div>-- <div class="pi-form-group">- <label class="pi-label">Access Token <span class="pi-optional">(optional, for private- repos)</span></label>- <input type="password" class="pi-input" x-model="$store.pluginInstallStore.gitToken"- :disabled="$store.pluginInstallStore.loading" placeholder="ghp_xxxx or glpat-xxxx">- <div class="pi-hint">Token is used only for cloning and is not stored.</div>- </div>-- <div class="pi-actions">- <button class="button confirm" @click="$store.pluginInstallStore.installGit()"- :disabled="$store.pluginInstallStore.loading || !$store.pluginInstallStore.gitUrl.trim()">- <template x-if="$store.pluginInstallStore.loading">- <span class="pi-button-loading">- <span class="spinner"></span>- <span x-text="$store.pluginInstallStore.loadingMessage || 'Cloning...'"></span>- </span>- </template>- <template x-if="!$store.pluginInstallStore.loading">- <span>- <span class="icon material-symbols-outlined">terminal</span> Clone & Install- </span>- </template>- </button>- </div>-- <div x-show="$store.pluginInstallStore.error" class="pi-error">- <span x-text="$store.pluginInstallStore.error"></span>- </div>-- <div x-show="$store.pluginInstallStore.result" class="pi-result">- <div class="pi-result-icon">- <span class="material-symbols-outlined">check_circle</span>- </div>- <div class="pi-result-text">- <strong- x-text="'Plugin installed: ' + ($store.pluginInstallStore.result?.title || $store.pluginInstallStore.result?.plugin_name || '')"></strong>- <div class="pi-result-path" x-text="$store.pluginInstallStore.result?.path || ''"></div>- </div>- </div>- </div>-- <!-- ═══ ZIP Tab ═══ -->- <div x-show="$store.pluginInstallStore.activeTab === 'zip'"- x-init="$store.pluginInstallStore.resetZip()">-- <div class="pi-upload-section">- <label for="plugin-zip-file" class="pi-upload-btn button confirm"- :class="{ 'pi-has-file': $store.pluginInstallStore.zipFile }">- <span class="icon material-symbols-outlined">upload_file</span>- <span x-text="$store.pluginInstallStore.zipFileName || 'Select Plugin ZIP File'"></span>- </label>- <input type="file" id="plugin-zip-file" accept=".zip" style="display:none"- @change="$store.pluginInstallStore.handleFileUpload($event)">- <div class="pi-hint">- The ZIP should contain a folder with a plugin.yaml file.- </div>- </div>-- <div x-show="$store.pluginInstallStore.zipFile" class="pi-actions-center">- <button class="button confirm" @click="$store.pluginInstallStore.installZip()"- :disabled="$store.pluginInstallStore.loading">- <span class="icon material-symbols-outlined">download</span> Install Plugin- </button>- </div>-- <div x-show="$store.pluginInstallStore.loading" class="pi-loading">- <span x-text="$store.pluginInstallStore.loadingMessage || 'Processing...'"></span>- </div>-- <div x-show="$store.pluginInstallStore.error" class="pi-error">- <span x-text="$store.pluginInstallStore.error"></span>- </div>-- <div x-show="$store.pluginInstallStore.result" class="pi-result">- <div class="pi-result-icon">- <span class="material-symbols-outlined">check_circle</span>- </div>- <div class="pi-result-text">- <strong- x-text="'Plugin installed: ' + ($store.pluginInstallStore.result?.title || $store.pluginInstallStore.result?.plugin_name || '')"></strong>- <div class="pi-result-path" x-text="$store.pluginInstallStore.result?.path || ''"></div>- </div>- </div>- </div>+ <template x-if="$store.pluginInstallStore.activeTab === 'store'">+ <x-component path="/plugins/plugin_installer/webui/install-index.html"></x-component>+ </template>++ <template x-if="$store.pluginInstallStore.activeTab === 'git'">+ <x-component path="/plugins/plugin_installer/webui/install-git.html"></x-component>+ </template>++ <template x-if="$store.pluginInstallStore.activeTab === 'zip'">+ <x-component path="/plugins/plugin_installer/webui/install-zip.html"></x-component>+ </template></div></template>@@ -819,4 +592,4 @@</style></body>-</html>\ No newline at end of file+</html>diff --git a/plugins/plugin_installer/webui/pluginInstallStore.js b/plugins/plugin_installer/webui/pluginInstallStore.jsindex 45e47c179..7c2197e54 100644--- a/plugins/plugin_installer/webui/pluginInstallStore.js+++ b/plugins/plugin_installer/webui/pluginInstallStore.js@@ -1,12 +1,12 @@-import { createStore, getStore } from "/js/AlpineStore.js";+import { createStore } from "/js/AlpineStore.js";import * as api from "/js/api.js";import { openModal } from "/js/modals.js";import { marked } from "/vendor/marked/marked.esm.js";import { toastFrontendSuccess } from "/components/notifications/notification-store.js";import { showConfirmDialog } from "/js/confirmDialog.js";-import {store as pluginListStore } from "/components/plugins/list/pluginListStore.js";-// import {store as pluginInitStore } from "/components/plugins/list/plugin-init-store.js";-// import {store as imageViewerStore } from "/components/modals/image-viewer/image-viewer-store.js";+import { store as imageViewerStore } from "/components/modals/image-viewer/image-viewer-store.js";+import { store as pluginListStore } from "/components/plugins/list/pluginListStore.js";+import { store as pluginInitStore } from "/components/plugins/list/plugin-init-store.js";const PLUGIN_API = "plugins/plugin_installer/plugin_install";const PER_PAGE = 20;@@ -49,6 +49,7 @@ const model = {loading: false,loadingMessage: "",error: "",+ result: null,// README statereadmeContent: null,@@ -65,6 +66,7 @@ const model = {setTab(tab) {this.activeTab = tab;this.error = "";+ this.result = null;},setBrowseFilter(filter) {@@ -129,6 +131,7 @@ const model = {this.zipFile = file;this.zipFileName = file.name;this.error = "";+ this.result = null;},async installZip() {@@ -144,6 +147,7 @@ const model = {this.loading = true;this.loadingMessage = "Installing plugin from ZIP...";this.error = "";+ this.result = null;const formData = new FormData();formData.append("action", "install_zip");@@ -160,6 +164,8 @@ const model = {return;}+ this.result = data;+toastFrontendSuccess(`Plugin "${data.title || data.plugin_name}" installed`,"Plugin Installer"@@ -189,6 +195,7 @@ const model = {this.loading = true;this.loadingMessage = "Cloning repository...";this.error = "";+ this.result = null;const data = await api.callJsonApi(PLUGIN_API, {action: "install_git",@@ -201,6 +208,8 @@ const model = {return;}+ this.result = data;+toastFrontendSuccess(`Plugin "${data.title || data.plugin_name}" installed`,"Plugin Installer"@@ -350,8 +359,9 @@ const model = {},openDetail(plugin) {- this.selectedPlugin = {...plugin, name: this._pluginName(plugin) };+ this.selectedPlugin = { ...plugin, name: this._pluginName(plugin) };this.error = "";+ this.result = null;this.installedPluginInfo = null;this.readmeContent = null;this.detailThumbnailUrl = this.getThumbnailUrl(this.selectedPlugin);@@ -491,9 +501,8 @@ const model = {},manageOpenInit() {- const initStore = this._pluginInitStore();- if (initStore?.open && this.installedPluginInfo) {- initStore.open(this.installedPluginInfo);+ if (this.installedPluginInfo) {+ pluginInitStore.open(this.installedPluginInfo);}},@@ -527,18 +536,27 @@ const model = {return this.detailThumbnailUrl;},+ openScreenshot(url) {+ if (!url) return;+ imageViewerStore.open(url, {+ name: this.selectedPlugin?.title || this.selectedPlugin?.key || "Plugin screenshot",+ });+ },+// ── Shared ───────────────────────────────────resetZip() {this.zipFile = null;this.zipFileName = "";this.error = "";+ this.result = null;},resetGit() {this.gitUrl = "";this.gitToken = "";this.error = "";+ this.result = null;},resetIndex() {@@ -547,6 +565,7 @@ const model = {this.sortBy = "stars";this.browseFilter = "all";this.error = "";+ this.result = null;this.selectedPlugin = null;},diff --git a/webui/components/plugins/list/plugin-list.html b/webui/components/plugins/list/plugin-list.htmlindex 5c90e2198..999d39659 100644--- a/webui/components/plugins/list/plugin-list.html+++ b/webui/components/plugins/list/plugin-list.html@@ -113,7 +113,7 @@<button type="button"class="button"title="Run initializer script"- @click="$store.pluginInitStore.open(plugin)">+ @click="$store.pluginListStore.openPluginInit(plugin)"><span class="icon material-symbols-outlined">terminal</span> Init</button></template>diff --git a/webui/components/plugins/list/pluginListStore.js b/webui/components/plugins/list/pluginListStore.jsindex 6426e4d91..fdbb3b4c5 100644--- a/webui/components/plugins/list/pluginListStore.js+++ b/webui/components/plugins/list/pluginListStore.js@@ -1,9 +1,9 @@import { createStore } from "/js/AlpineStore.js";import * as api from "/js/api.js";-import "/components/plugins/plugin-settings-store.js";-import "/components/plugins/toggle/plugin-toggle-store.js";-import "/components/plugins/list/plugin-init-store.js";-import "/components/modals/markdown/markdown-store.js";+import { store as pluginSettingsStore } from "/components/plugins/plugin-settings-store.js";+import { store as pluginToggleStore } from "/components/plugins/toggle/plugin-toggle-store.js";+import { store as pluginInitStore } from "/components/plugins/list/plugin-init-store.js";+import { store as markdownModalStore } from "/components/modals/markdown/markdown-store.js";import {store as notificationStore,defaultPriority,@@ -56,14 +56,17 @@ const model = {window.openModal?.(`/plugins/${plugin.name}/webui/main.html`);},+ openPluginInit(plugin) {+ if (!plugin?.name || !plugin?.has_init_script) return;+ pluginInitStore.open(plugin);+ },+async openPluginConfig(plugin) {if (!plugin?.name || !plugin?.has_config_screen) return;try {// Initialize toggle store for activation state UI in settings modal- const pluginToggleStore = Alpine.store("pluginToggle");if (pluginToggleStore?.open) await pluginToggleStore.open(plugin);- const pluginSettingsStore = Alpine.store("pluginSettingsPrototype");if (!pluginSettingsStore?.open) {throw new Error("Plugin settings store is unavailable.");}@@ -85,7 +88,6 @@ const model = {if (!plugin?.name) return;this.selectedPlugin = plugin;try {- const pluginToggleStore = Alpine.store("pluginToggle");if (!pluginToggleStore?.open) {throw new Error("Plugin toggle store is unavailable.");}@@ -136,9 +138,8 @@ const model = {doc,});if (response?.error) throw new Error(response.error);- const markdownModal = Alpine.store("markdownModal");- if (!markdownModal) throw new Error("Markdown modal store unavailable.");- markdownModal.open(response.filename, response.content);+ if (!markdownModalStore?.open) throw new Error("Markdown modal store unavailable.");+ markdownModalStore.open(response.filename, response.content);window.openModal?.("components/modals/markdown/markdown-modal.html");} catch (e) {showErrorNotification(e, "Failed to open document");diff --git a/webui/components/plugins/plugin-settings-store.js b/webui/components/plugins/plugin-settings-store.jsindex 2bd43eed2..dc73b260d 100644--- a/webui/components/plugins/plugin-settings-store.js+++ b/webui/components/plugins/plugin-settings-store.js@@ -1,5 +1,7 @@import { createStore } from "/js/AlpineStore.js";import { showConfirmDialog } from "/js/confirmDialog.js";+import { store as settingsStore } from "/components/settings/settings-store.js";+import { store as pluginToggleStore } from "/components/plugins/toggle/plugin-toggle-store.js";const fetchApi = globalThis.fetchApi;const justToast = globalThis.justToast;@@ -56,11 +58,10 @@ const model = {await this.loadSettings();// Mirror scope change to pluginToggle so activation state stays in sync- const toggleStore = Alpine.store('pluginToggle');- if (toggleStore) {- toggleStore.projectName = nextProject;- toggleStore.agentProfileKey = nextProfile;- await toggleStore.loadToggleStatus();+ if (pluginToggleStore?.loadToggleStatus) {+ pluginToggleStore.projectName = nextProject;+ pluginToggleStore.agentProfileKey = nextProfile;+ await pluginToggleStore.loadToggleStatus();}},@@ -292,9 +293,8 @@ const model = {// Core-backed plugins (e.g. memory) delegate to the settings storeif (this.saveMode === 'core') {- const coreStore = Alpine.store('settings');- if (coreStore?.saveSettings) {- const ok = await coreStore.saveSettings();+ if (settingsStore?.saveSettings) {+ const ok = await settingsStore.saveSettings();if (ok) window.closeModal?.();}return;diff --git a/webui/components/plugins/toggle/plugin-toggle-advanced.html b/webui/components/plugins/toggle/plugin-toggle-advanced.htmlindex 26555d2dc..3d6ac275c 100644--- a/webui/components/plugins/toggle/plugin-toggle-advanced.html+++ b/webui/components/plugins/toggle/plugin-toggle-advanced.html@@ -63,7 +63,7 @@<label class="toggle" :class="{ 'disabled-appearance': !$store.pluginToggle.hasExplicitRuleForScope && !$store.pluginToggle.alwaysEnabled }"><input type="checkbox":checked="$store.pluginToggle.status === 'enabled'"- :disabled="$store.pluginToggle.alwaysEnabled || $store.pluginToggle.isSaving || !$store.pluginToggle.hasExplicitRuleForScope"+ :disabled="$store.pluginToggle.alwaysEnabled || $store.pluginToggle.isSaving"@change="$store.pluginToggle.setEnabled($event.target.checked)"><span class="toggler"></span></label>diff --git a/webui/components/settings/plugins/plugins-subsection-store.js b/webui/components/settings/plugins/plugins-subsection-store.jsnew file mode 100644index 000000000..5d314a20e--- /dev/null+++ b/webui/components/settings/plugins/plugins-subsection-store.js@@ -0,0 +1,58 @@+import { createStore } from "/js/AlpineStore.js";+import * as api from "/js/api.js";+import { store as pluginListStore } from "/components/plugins/list/pluginListStore.js";++const model = {+ tab: "",+ plugins: [],+ loading: false,++ resolveTab(element) {+ const host =+ element?.closest("x-component")+ || element?.parentElement?.closest("x-component");+ return host?.getAttribute("data-tab") || "";+ },++ async init(element) {+ this.tab = this.resolveTab(element);+ await this.load();+ },++ cleanup() {+ this.tab = "";+ this.plugins = [];+ this.loading = false;+ },++ async load() {+ if (!this.tab) {+ this.plugins = [];+ return;+ }++ this.loading = true;+ try {+ const response = await api.callJsonApi("plugins_list", {+ filter: { custom: true, builtin: true },+ });+ const plugins = Array.isArray(response?.plugins) ? response.plugins : [];+ this.plugins = plugins.filter((plugin) => {+ const sections = Array.isArray(plugin?.settings_sections)+ ? plugin.settings_sections+ : [];+ return plugin?.has_config_screen && sections.includes(this.tab);+ });+ } catch {+ this.plugins = [];+ } finally {+ this.loading = false;+ }+ },++ async openPluginConfig(plugin) {+ await pluginListStore.openPluginConfig(plugin);+ },+};++export const store = createStore("pluginsSubsectionPrototype", model);diff --git a/webui/components/settings/plugins/plugins-subsection.html b/webui/components/settings/plugins/plugins-subsection.htmlindex e9c334737..392c7a223 100644--- a/webui/components/settings/plugins/plugins-subsection.html+++ b/webui/components/settings/plugins/plugins-subsection.html@@ -1,7 +1,7 @@<html><head><script type="module">- import { store } from "/components/plugins/plugin-settings-store.js";+ import { store } from "/components/settings/plugins/plugins-subsection-store.js";</script></head><body>@@ -11,80 +11,44 @@<x-component path="settings/plugins/plugins-subsection.html" data-tab="agent"></x-component>The tab value is read at init time from the x-component element's dataset.-->- <div x-data="{- tab: '',- plugins: [],- loading: false,- async init() {- // find closest x-component ancestor to read the data-tab attribute- const host = this.$el.closest('x-component') || this.$el.parentElement?.closest('x-component');- this.tab = host?.getAttribute('data-tab') || '';- await this.load();- },- async load() {- if (!this.tab) return;- this.loading = true;- try {- const r = await globalThis.fetchApi('/plugins_list', {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({- filter: { custom: true, builtin: true },- }),- });- const data = await r.json().catch(() => ({}));- const plugins = data.ok ? (data.plugins || []) : [];- this.plugins = plugins.filter((plugin) => {- const sections = Array.isArray(plugin.settings_sections)- ? plugin.settings_sections- : [];- return plugin.has_config_screen && sections.includes(this.tab);- });- } catch {- this.plugins = [];- } finally {- this.loading = false;- }- },- async openPluginConfig(plugin) {- if (!plugin?.name) return;- await Alpine.store('pluginSettings')?.open(plugin.name);- window.openModal?.('components/plugins/plugin-settings.html');- }- }" x-init="init()">-- <template x-if="loading || plugins.length > 0">- <div>- <div class="section-title">Plugins</div>- <div class="section-description">- Plugin-specific settings for this tab.- </div>+ <div x-data="(() => ({ context: $instantiate($store.pluginsSubsectionPrototype) }))()">+ <template x-if="context">+ <div x-create="context.init($el)"+ x-destroy="context.cleanup()">+ <template x-if="context.loading || context.plugins.length > 0">+ <div>+ <div class="section-title">Plugins</div>+ <div class="section-description">+ Plugin-specific settings for this tab.+ </div>- <div x-show="loading" class="loading">- <span>Loading plugins...</span>- </div>+ <div x-show="context.loading" class="loading">+ <span>Loading plugins...</span>+ </div>- <div class="plugins-list">- <template x-for="plugin in plugins" :key="plugin.path || plugin.name">- <div class="plugin-card">- <div class="plugin-header">- <div class="plugin-heading">- <div class="plugin-title" x-text="plugin.display_name || plugin.name || '(unnamed plugin)'"></div>- <code class="plugin-path" x-text="plugin.path"></code>- </div>- <div class="plugin-actions">- <button type="button"- class="button"- title="Config"- @click="openPluginConfig(plugin)">- <span class="icon material-symbols-outlined">settings</span> Config- </button>+ <div class="plugins-list">+ <template x-for="plugin in context.plugins" :key="plugin.path || plugin.name">+ <div class="plugin-card">+ <div class="plugin-header">+ <div class="plugin-heading">+ <div class="plugin-title" x-text="plugin.display_name || plugin.name || '(unnamed plugin)'"></div>+ <code class="plugin-path" x-text="plugin.path"></code>+ </div>+ <div class="plugin-actions">+ <button type="button"+ class="button"+ title="Config"+ @click="context.openPluginConfig(plugin)">+ <span class="icon material-symbols-outlined">settings</span> Config+ </button>+ </div>+ </div>+ <div class="plugin-description" x-text="plugin.description || 'No description provided.'"></div></div>- </div>- <div class="plugin-description" x-text="plugin.description || 'No description provided.'"></div>+ </template></div>- </template>- </div>+ </div>+ </template></div></template></div>