fix(web): wire up "Check & Update All" plugins button (#249)

window.updateAllPlugins was never assigned, so the button always showed
"Bulk update handler unavailable." Wire it to PluginInstallManager.updateAll(),
add per-plugin progress feedback in the button text, show a summary
notification on completion, and skip redundant plugin list reloads.

Co-authored-by: Chuck <chuck@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-02-15 13:06:18 -05:00
committed by GitHub
parent bc8568604a
commit 5b0ad5ab71
2 changed files with 44 additions and 9 deletions

View File

@@ -80,26 +80,34 @@ const PluginInstallManager = {
/** /**
* Update all plugins. * Update all plugins.
* *
* @param {Function} onProgress - Optional callback(index, total, pluginId) for progress updates
* @returns {Promise<Array>} Update results * @returns {Promise<Array>} Update results
*/ */
async updateAll() { async updateAll(onProgress) {
if (!window.PluginStateManager || !window.PluginStateManager.installedPlugins) { if (!window.PluginStateManager || !window.PluginStateManager.installedPlugins) {
throw new Error('Installed plugins not loaded'); throw new Error('Installed plugins not loaded');
} }
const plugins = window.PluginStateManager.installedPlugins; const plugins = window.PluginStateManager.installedPlugins;
const results = []; const results = [];
for (const plugin of plugins) { for (let i = 0; i < plugins.length; i++) {
const plugin = plugins[i];
if (onProgress) onProgress(i + 1, plugins.length, plugin.id);
try { try {
const result = await this.update(plugin.id); const result = await window.PluginAPI.updatePlugin(plugin.id);
results.push({ pluginId: plugin.id, success: true, result }); results.push({ pluginId: plugin.id, success: true, result });
} catch (error) { } catch (error) {
results.push({ pluginId: plugin.id, success: false, error }); results.push({ pluginId: plugin.id, success: false, error });
} }
} }
// Reload plugin list once at the end
if (window.PluginStateManager) {
await window.PluginStateManager.loadInstalledPlugins();
}
return results; return results;
} }
}; };
@@ -109,5 +117,6 @@ if (typeof module !== 'undefined' && module.exports) {
module.exports = PluginInstallManager; module.exports = PluginInstallManager;
} else { } else {
window.PluginInstallManager = PluginInstallManager; window.PluginInstallManager = PluginInstallManager;
window.updateAllPlugins = (onProgress) => PluginInstallManager.updateAll(onProgress);
} }

View File

@@ -1712,9 +1712,35 @@ function runUpdateAllPlugins() {
button.dataset.running = 'true'; button.dataset.running = 'true';
button.disabled = true; button.disabled = true;
button.classList.add('opacity-60', 'cursor-wait'); button.classList.add('opacity-60', 'cursor-wait');
button.innerHTML = '<i class="fas fa-sync fa-spin mr-2"></i>Updating...'; button.innerHTML = '<i class="fas fa-sync fa-spin mr-2"></i>Checking...';
Promise.resolve(window.updateAllPlugins()) const onProgress = (current, total, pluginId) => {
button.innerHTML = `<i class="fas fa-sync fa-spin mr-2"></i>Updating ${current}/${total}...`;
};
Promise.resolve(window.updateAllPlugins(onProgress))
.then(results => {
if (!results || !results.length) {
showNotification('No plugins to update.', 'info');
return;
}
let updated = 0, upToDate = 0, failed = 0;
for (const r of results) {
if (!r.success) {
failed++;
} else if (r.result && r.result.message && r.result.message.includes('already up to date')) {
upToDate++;
} else {
updated++;
}
}
const parts = [];
if (updated > 0) parts.push(`${updated} updated`);
if (upToDate > 0) parts.push(`${upToDate} already up to date`);
if (failed > 0) parts.push(`${failed} failed`);
const type = failed > 0 ? (updated > 0 ? 'warning' : 'error') : 'success';
showNotification(parts.join(', '), type);
})
.catch(error => { .catch(error => {
console.error('Error updating all plugins:', error); console.error('Error updating all plugins:', error);
if (typeof showNotification === 'function') { if (typeof showNotification === 'function') {