Skip to content

Agent Zero AI framework

feat: simplify install button + add tab state and management methods to store

TerminallyLazy1e536e9f8776
diff --git a/plugins/plugin_installer/extensions/webui/plugins-list-header-buttons/install-buttons.html b/plugins/plugin_installer/extensions/webui/plugins-list-header-buttons/install-buttons.html
index 4b04f9984..de021cacb 100644
--- a/plugins/plugin_installer/extensions/webui/plugins-list-header-buttons/install-buttons.html
+++ b/plugins/plugin_installer/extensions/webui/plugins-list-header-buttons/install-buttons.html
@@ -1,136 +1,11 @@
-<span x-data="{ open: false }">
+<span x-data>
<script type="module">
import { store } from "/plugins/plugin_installer/webui/pluginInstallStore.js";
</script>
- <div class="pi-install-wrapper" @click.outside="open = false">
- <button type="button"
- class="button"
- @click="open = !open">
- <span class="icon material-symbols-outlined">add</span> Install
- <span class="material-symbols-outlined pi-chevron"
- :class="{ 'pi-chevron-open': open }">expand_more</span>
- </button>
-
- <div class="pi-dropdown" x-show="open" x-cloak x-transition.opacity.duration.150ms>
- <button type="button" class="pi-dropdown-item"
- @click="open = false; openModal('../plugins/plugin_installer/webui/install-index.html')">
- <span class="material-symbols-outlined">store</span>
- <span class="pi-item-text">
- <span class="pi-item-title">Browse Plugins</span>
- <span class="pi-item-desc">Explore the community index</span>
- </span>
- </button>
- <div class="pi-dropdown-sep"></div>
- <button type="button" class="pi-dropdown-item"
- @click="open = false; openModal('../plugins/plugin_installer/webui/install-git.html')">
- <span class="material-symbols-outlined">terminal</span>
- <span class="pi-item-text">
- <span class="pi-item-title">Clone from Git</span>
- <span class="pi-item-desc">Install from a repository URL</span>
- </span>
- </button>
- <button type="button" class="pi-dropdown-item"
- @click="open = false; openModal('../plugins/plugin_installer/webui/install-zip.html')">
- <span class="material-symbols-outlined">upload_file</span>
- <span class="pi-item-text">
- <span class="pi-item-title">Upload ZIP</span>
- <span class="pi-item-desc">Install from a local archive</span>
- </span>
- </button>
- </div>
- </div>
-
- <style>
- .plugins-toolbar-actions {
- display: flex;
- align-items: center;
- gap: 0.4rem;
- }
-
- .pi-install-wrapper {
- position: relative;
- }
-
- .pi-install-wrapper > .button {
- gap: 0.25rem;
- }
-
- .pi-chevron {
- font-size: 1.1rem !important;
- transition: transform 0.2s ease;
- }
-
- .pi-chevron-open {
- transform: rotate(180deg);
- }
-
- .pi-dropdown {
- position: absolute;
- top: calc(100% + 0.35rem);
- right: 0;
- min-width: 230px;
- background: var(--color-panel);
- border: 1px solid var(--color-border);
- border-radius: 8px;
- box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
- z-index: 100;
- padding: 0.3rem;
- }
-
- .pi-dropdown-item {
- display: flex;
- align-items: center;
- gap: 0.6rem;
- width: 100%;
- padding: 0.5rem 0.6rem;
- background: none;
- border: none;
- border-radius: 5px;
- color: var(--color-text);
- cursor: pointer;
- text-align: left;
- font-family: inherit;
- font-size: 0.875rem;
- transition: background 0.12s ease;
- }
-
- .pi-dropdown-item:hover {
- background: var(--color-background);
- }
-
- .pi-dropdown-item .material-symbols-outlined {
- font-size: 1.25rem;
- color: var(--color-text-secondary);
- flex-shrink: 0;
- }
-
- .pi-dropdown-item:hover .material-symbols-outlined {
- color: var(--color-highlight);
- }
-
- .pi-item-text {
- display: flex;
- flex-direction: column;
- }
-
- .pi-item-title {
- font-weight: 500;
- line-height: 1.3;
- }
-
- .pi-item-desc {
- font-size: 0.75rem;
- color: var(--color-text-secondary);
- line-height: 1.3;
- }
-
- .pi-dropdown-sep {
- height: 1px;
- background: var(--color-border);
- margin: 0.2rem 0.5rem;
- }
-
- [x-cloak] { display: none !important; }
- </style>
+ <button type="button"
+ class="button"
+ @click="openModal('../plugins/plugin_installer/webui/main.html')">
+ <span class="icon material-symbols-outlined">add</span> Install
+ </button>
</span>
diff --git a/plugins/plugin_installer/webui/pluginInstallStore.js b/plugins/plugin_installer/webui/pluginInstallStore.js
index 8208b6aae..1a8ec5caa 100644
--- a/plugins/plugin_installer/webui/pluginInstallStore.js
+++ b/plugins/plugin_installer/webui/pluginInstallStore.js
@@ -44,6 +44,15 @@ const model = {
error: "",
result: null,
+ // Tab state
+ activeTab: "store",
+
+ setTab(tab) {
+ this.activeTab = tab;
+ this.error = "";
+ this.result = null;
+ },
+
// ── ZIP Install ──────────────────────────────
handleFileUpload(event) {
@@ -223,6 +232,10 @@ const model = {
this.selectedPlugin = plugin;
this.error = "";
this.result = null;
+ this.installedPluginInfo = null;
+ if (plugin.installed) {
+ this.fetchInstalledPluginInfo(plugin.key);
+ }
window.openModal?.("../plugins/plugin_installer/webui/install-detail.html");
},
@@ -272,6 +285,70 @@ const model = {
}
},
+ // ── Installed Plugin Info ─────────────────────
+
+ installedPluginInfo: null,
+ installedPluginInfoLoading: false,
+
+ async fetchInstalledPluginInfo(pluginKey) {
+ this.installedPluginInfo = null;
+ this.installedPluginInfoLoading = true;
+ try {
+ const response = await api.callJsonApi("plugins_list", {
+ filter: { custom: true, builtin: true, search: "" },
+ });
+ const plugins = Array.isArray(response.plugins) ? response.plugins : [];
+ this.installedPluginInfo = plugins.find(
+ (p) => p.name === pluginKey
+ ) || null;
+ } catch (e) {
+ this.installedPluginInfo = null;
+ } finally {
+ this.installedPluginInfoLoading = false;
+ }
+ },
+
+ manageOpenPlugin() {
+ const info = this.installedPluginInfo;
+ if (!info?.name || !info?.has_main_screen) return;
+ window.openModal?.(`/plugins/${info.name}/webui/main.html`);
+ },
+
+ async manageOpenConfig() {
+ const pls = Alpine.store("pluginListStore");
+ if (pls?.openPluginConfig && this.installedPluginInfo) {
+ await pls.openPluginConfig(this.installedPluginInfo);
+ }
+ },
+
+ async manageOpenDoc(doc) {
+ const pls = Alpine.store("pluginListStore");
+ if (pls?.openPluginDoc && this.installedPluginInfo) {
+ await pls.openPluginDoc(this.installedPluginInfo, doc);
+ }
+ },
+
+ manageOpenInfo() {
+ const pls = Alpine.store("pluginListStore");
+ if (pls?.openPluginInfo && this.installedPluginInfo) {
+ pls.openPluginInfo(this.installedPluginInfo);
+ }
+ },
+
+ async manageDeletePlugin() {
+ const pls = Alpine.store("pluginListStore");
+ if (pls?.deletePlugin && this.installedPluginInfo) {
+ await pls.deletePlugin(this.installedPluginInfo);
+ // Mark as no longer installed in the index view
+ if (this.selectedPlugin) {
+ this.selectedPlugin.installed = false;
+ const idx = this.installedPlugins.indexOf(this.selectedPlugin.key);
+ if (idx !== -1) this.installedPlugins.splice(idx, 1);
+ }
+ this.installedPluginInfo = null;
+ }
+ },
+
// ── Shared ───────────────────────────────────
resetZip() {