feat: Implement backend commands for plugin data management and enhance frontend synchronization with updated plugin interfaces

This commit is contained in:
Rbanh committed 2025-03-30 19:31:00 -04:00
1 parent 78f22f65f4
commit 83be780243
35 files changed
+5261 -2208

No files matched your search

+116
View File
@@ -514,3 +514,119 @@ button {
font-size: 0.9rem;
border: 1px solid var(--border-color);
}
.plugin-changelog {
margin-top: 1rem;
margin-bottom: 1rem;
background-color: rgba(255, 255, 255, 0.05);
padding: 1rem;
border-radius: 4px;
max-height: 200px;
overflow-y: auto;
}
.changelog-content {
white-space: pre-line;
font-size: 0.9rem;
line-height: 1.4;
}
.update-actions {
margin-top: 1.5rem;
display: flex;
justify-content: center;
}
.detail-update-button {
padding: 0.75rem 1.5rem;
background-color: var(--secondary-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s;
}
.detail-update-button:hover {
background-color: #43a047;
}
.detail-update-button:disabled {
background-color: #666;
cursor: not-allowed;
}
.update-available-badge {
background-color: var(--secondary-color);
color: white;
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.8rem;
margin-left: 0.5rem;
}
.bulk-update-progress {
margin-top: 0.5rem;
font-size: 0.9rem;
color: var(--text-secondary-color);
}
.bulk-update-progress progress {
width: 100%;
height: 8px;
border-radius: 4px;
margin-top: 0.25rem;
}
/* Warning Modal Styles */
.warning-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 2000; /* Higher than other modals */
}
.warning-content {
background-color: var(--background-color);
border: 2px solid var(--warning-color);
border-radius: 8px;
padding: 2rem;
width: 90%;
max-width: 500px;
text-align: center;
position: relative;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.warning-content h3 {
color: var(--warning-color);
margin-bottom: 1rem;
font-size: 1.5rem;
}
.warning-content p {
margin-bottom: 1.5rem;
line-height: 1.6;
}
.warning-content .close-button {
padding: 0.75rem 1.5rem;
background-color: var(--warning-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s;
}
.warning-content .close-button:hover {
background-color: #e69500;
}
+599 -62
View File
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
import { appDataDir } from '@tauri-apps/api/path'; // Import for data directory (if needed frontend side)
import "./App.css";
type ServerType =
@@ -39,6 +40,11 @@ interface Plugin {
permissions?: any;
file_path: string;
file_hash: string;
website?: string;
changelog?: string;
repository_source?: string; // Add repository source (string for simplicity)
repository_id?: string; // Add repository ID
repository_url?: string; // URL to the plugin's repository page
}
interface ScanResult {
@@ -52,6 +58,33 @@ interface ScanProgress {
current_file: string;
}
// --- New Interfaces for Update Events ---
interface BulkUpdateProgressPayload {
processed: number;
total: number;
current_plugin_name: string;
}
interface SingleUpdateResultPayload {
original_file_path: string;
plugin: Plugin | null; // Updated plugin state or null if check failed but wasn't a panic
error: string | null; // Error message if any
}
// Interface for potential plugin matches for ambiguous plugins
interface PotentialPluginMatch {
name: string;
version: string;
repository: string;
repository_id: string;
page_url: string;
description?: string;
minecraft_versions: string[];
download_count?: number;
}
// --- End New Interfaces ---
interface PluginDetailsProps {
plugin: Plugin;
onClose: () => void;
@@ -94,12 +127,21 @@ function PluginDetails({ plugin, onClose }: PluginDetailsProps) {
<div className="plugin-details-content">
<button className="close-button" onClick={onClose}>&times;</button>
<h2>{plugin.name}</h2>
<div className="plugin-version-display">Version: {plugin.version}</div>
<div className="plugin-version-display">Version: {plugin.version} {plugin.latest_version && plugin.has_update && <span className="update-available-badge">(Update available: {plugin.latest_version})</span>}</div>
{plugin.description && (
<div className="plugin-description">{plugin.description}</div>
)}
{plugin.website && (
<div className="plugin-website">
<div className="section-label">Website:</div>
<a href={plugin.website} target="_blank" rel="noopener noreferrer">
{plugin.website}
</a>
</div>
)}
{plugin.authors && plugin.authors.length > 0 && (
<div className="plugin-authors">
<div className="section-label">Authors:</div>
@@ -121,6 +163,13 @@ function PluginDetails({ plugin, onClose }: PluginDetailsProps) {
</div>
)}
{plugin.changelog && plugin.has_update && (
<div className="plugin-changelog">
<div className="section-label">Changelog:</div>
<div className="changelog-content">{plugin.changelog}</div>
</div>
)}
<div className="plugin-file-info">
<div className="section-label">File Path:</div>
<div className="file-path">{plugin.file_path}</div>
@@ -128,6 +177,17 @@ function PluginDetails({ plugin, onClose }: PluginDetailsProps) {
<div className="section-label">File Hash (SHA-256):</div>
<div className="file-hash">{plugin.file_hash}</div>
</div>
{plugin.has_update && plugin.latest_version && (
<div className="update-actions">
<button
className="update-button detail-update-button"
onClick={() => window.dispatchEvent(new CustomEvent('update-plugin', { detail: plugin }))}
>
Update to version {plugin.latest_version}
</button>
</div>
)}
</div>
</div>
);
@@ -159,6 +219,75 @@ function ServerInfoDisplay({ serverInfo }: { serverInfo: ServerInfo | null }) {
);
}
// Add this new component after PluginDetails
function WarningModal({ message, onClose }: { message: string, onClose: () => void }) {
return (
<div className="modal-backdrop">
<div className="warning-modal">
<h3>⚠️ Warning</h3>
<p>{message}</p>
<button onClick={onClose}>Close</button>
</div>
</div>
);
}
// Component for selecting the correct plugin from potential matches
function PluginMatchSelector({
plugin,
potentialMatches,
onSelect,
onCancel
}: {
plugin: Plugin,
potentialMatches: PotentialPluginMatch[],
onSelect: (match: PotentialPluginMatch) => void,
onCancel: () => void
}) {
return (
<div className="modal-backdrop">
<div className="plugin-match-modal">
<h3>Multiple Matches Found</h3>
<p>We found several potential matches for <strong>{plugin.name}</strong>. Please select the correct one:</p>
<div className="matches-list">
{potentialMatches.map((match, index) => (
<div key={`${match.repository}-${match.repository_id}`} className="match-item">
<div className="match-details">
<h4>{match.name}</h4>
<p className="match-version">Version: {match.version}</p>
{match.description && <p className="match-description">{match.description}</p>}
<div className="match-meta">
<span className="match-repo">Source: {match.repository}</span>
{match.download_count && <span className="match-downloads">Downloads: {match.download_count.toLocaleString()}</span>}
<span className="match-mc-version">MC: {match.minecraft_versions.join(', ')}</span>
</div>
</div>
<div className="match-actions">
<button className="select-match-button" onClick={() => onSelect(match)}>
Select This Match
</button>
<a
href={match.page_url}
target="_blank"
rel="noopener noreferrer"
className="view-page-link"
>
View Page
</a>
</div>
</div>
))}
</div>
<div className="match-selector-footer">
<button className="cancel-button" onClick={onCancel}>Cancel</button>
</div>
</div>
</div>
);
}
function App() {
const [serverPath, setServerPath] = useState("");
const [serverInfo, setServerInfo] = useState<ServerInfo | null>(null);
@@ -168,42 +297,153 @@ function App() {
const [error, setError] = useState<string | null>(null);
const [selectedPlugin, setSelectedPlugin] = useState<Plugin | null>(null);
const [scanProgress, setScanProgress] = useState<ScanProgress | null>(null);
const [isCheckingUpdates, setIsCheckingUpdates] = useState(false);
const [updateError, setUpdateError] = useState<string | null>(null);
// --- New State Variables ---
const [pluginLoadingStates, setPluginLoadingStates] = useState<Record<string, boolean>>({});
const [bulkUpdateProgress, setBulkUpdateProgress] = useState<BulkUpdateProgressPayload | null>(null);
const [warningMessage, setWarningMessage] = useState<string | null>(null);
const [potentialMatches, setPotentialMatches] = useState<PotentialPluginMatch[]>([]);
// --- New state for match selector ---
const [showMatchSelector, setShowMatchSelector] = useState(false);
const [pluginToDisambiguate, setPluginToDisambiguate] = useState<Plugin | null>(null);
// --- End New state for match selector ---
// --- End New State Variables ---
const [serverType, setServerType] = useState<ServerType>('Unknown');
useEffect(() => {
let unlistenProgress: UnlistenFn | undefined;
let unlistenComplete: UnlistenFn | undefined;
let unlistenError: UnlistenFn | undefined;
let unlistenScanStarted: UnlistenFn | undefined;
let unlistenScanProgress: UnlistenFn | undefined;
let unlistenScanCompleted: UnlistenFn | undefined;
let unlistenScanError: UnlistenFn | undefined;
let unlistenBulkUpdateStart: UnlistenFn | undefined;
let unlistenUpdateCheckProgress: UnlistenFn | undefined;
let unlistenSingleUpdateCheckStarted: UnlistenFn | undefined;
let unlistenSingleUpdateCheckCompleted: UnlistenFn | undefined;
const setupListeners = async () => {
unlistenProgress = await listen<ScanProgress>("scan_progress", (event) => {
unlistenScanStarted = await listen("scan_started", () => {
console.log("Scan started event received");
setIsScanning(true);
setScanProgress(null);
setError(null);
});
unlistenScanProgress = await listen<ScanProgress>("scan_progress", (event) => {
console.log("Scan progress event received:", event.payload);
setScanProgress(event.payload);
setError(null);
});
unlistenComplete = await listen<ScanResult>("scan_complete", (event) => {
setServerInfo(event.payload.server_info);
setPlugins(event.payload.plugins);
unlistenScanCompleted = await listen<ScanResult>("scan_completed", (event) => {
console.log("Scan completed event received with payload:", event.payload);
try {
console.log("Server info:", event.payload.server_info);
console.log("Plugins count:", event.payload.plugins.length);
// Update state in a specific order to ensure UI updates properly
setIsScanning(false);
setScanComplete(true);
setServerInfo(event.payload.server_info);
setPlugins(event.payload.plugins);
setServerType(event.payload.server_info.server_type);
// Add a slight delay and verify the state was updated
setTimeout(() => {
console.log("Verifying state updates after scan:");
console.log("- scanComplete:", scanComplete);
console.log("- serverInfo:", serverInfo);
console.log("- plugins count:", plugins.length);
// Force a state update if plugins length is still 0 but we got plugins
if (plugins.length === 0 && event.payload.plugins.length > 0) {
console.log("Forcing state update because plugins array is empty");
setPlugins([...event.payload.plugins]);
}
}, 100);
console.log("State updated after scan completion");
} catch (err) {
console.error("Error handling scan completion:", err);
setError(`Error handling scan completion: ${err}`);
setIsScanning(false);
}
});
unlistenScanError = await listen<string>("scan_error", (event) => {
console.log("Scan error event received:", event.payload);
setIsScanning(false);
setScanComplete(true);
setScanProgress(null);
setError(null);
});
unlistenError = await listen<string>("scan_error", (event) => {
console.error("Scan Error:", event.payload);
setError(event.payload);
setIsScanning(false);
setScanProgress(null);
setScanComplete(false);
});
unlistenBulkUpdateStart = await listen<number>("bulk_update_start", (event) => {
console.log("Bulk update start event received, total plugins:", event.payload);
setIsCheckingUpdates(true);
setUpdateError(null);
setBulkUpdateProgress({
processed: 0,
total: event.payload,
current_plugin_name: "Starting update check..."
});
});
unlistenUpdateCheckProgress = await listen<BulkUpdateProgressPayload>("update_check_progress", (event) => {
console.log("Update check progress event received:", event.payload);
setBulkUpdateProgress(event.payload);
});
unlistenSingleUpdateCheckStarted = await listen<string>("single_update_check_started", (event) => {
console.log("Single update check started for:", event.payload);
});
unlistenSingleUpdateCheckCompleted = await listen<SingleUpdateResultPayload>("single_update_check_completed", (event) => {
console.log("Single update check completed, result:", event.payload);
const { original_file_path, plugin, error } = event.payload;
setPluginLoadingStates(prev => ({ ...prev, [original_file_path]: false }));
if (error) {
setUpdateError(`Error checking for updates: ${error}`);
return;
}
if (plugin) {
setPlugins(prevPlugins => prevPlugins.map(p => {
if (p.file_path === original_file_path) {
return plugin;
}
return p;
}));
if (serverPath) {
invoke("save_plugin_data", {
plugins: plugins.map(p => p.file_path === original_file_path ? plugin : p),
serverPath
}).catch(err => {
console.error("Error saving plugin data after single update:", err);
});
}
}
});
window.addEventListener('update-plugin', ((e: CustomEvent<Plugin>) => {
if (e.detail) {
updatePlugin(e.detail);
}
}) as EventListener);
};
setupListeners();
return () => {
unlistenProgress?.();
unlistenComplete?.();
unlistenError?.();
unlistenScanStarted?.();
unlistenScanProgress?.();
unlistenScanCompleted?.();
unlistenScanError?.();
unlistenBulkUpdateStart?.();
unlistenUpdateCheckProgress?.();
unlistenSingleUpdateCheckStarted?.();
unlistenSingleUpdateCheckCompleted?.();
window.removeEventListener('update-plugin', (() => {}) as EventListener);
};
}, []);
@@ -212,24 +452,44 @@ function App() {
const selected = await open({
directory: true,
multiple: false,
title: 'Select Minecraft Server Directory'
title: "Select Minecraft Server Folder",
});
if (selected !== null) {
if (typeof selected === 'string') {
setServerPath(selected);
setError(null);
} else if (Array.isArray(selected)) {
const selectedArr = selected as string[];
if (selectedArr.length > 0) {
setServerPath(selectedArr[0]);
if (selected && typeof selected === "string") {
console.log(`Directory selected: ${selected}`);
setServerPath(selected);
setServerInfo(null);
setPlugins([]);
setIsScanning(false);
setScanComplete(false);
setError(null);
setScanProgress(null);
setIsCheckingUpdates(false);
setUpdateError(null);
setPluginLoadingStates({});
setBulkUpdateProgress(null);
try {
console.log(`Attempting to load persisted data for: ${selected}`);
const loadedPlugins: Plugin[] = await invoke("load_plugin_data", { serverPath: selected });
if (loadedPlugins && loadedPlugins.length > 0) {
console.log(`Loaded ${loadedPlugins.length} plugins from persistence.`);
setPlugins(loadedPlugins);
setScanComplete(true);
setError(null);
} else {
console.log("No persisted plugin data found for this server.");
}
} catch (loadError) {
console.error("Error loading persisted plugin data:", loadError);
setError(`Failed to load previous plugin data: ${loadError}`);
}
} else {
console.log("Directory selection cancelled.");
}
} catch (err) {
console.error('Failed to open directory:', err);
setError("Failed to open directory selector. Please enter path manually.");
console.error("Error selecting directory:", err);
setError(`Error selecting directory: ${err}`);
}
}
@@ -237,6 +497,7 @@ function App() {
if (!serverPath || isScanning) return;
try {
console.log("Starting scan for plugins in:", serverPath);
setIsScanning(true);
setScanComplete(false);
setPlugins([]);
@@ -244,7 +505,8 @@ function App() {
setScanProgress(null);
setError(null);
await invoke("scan_server_directory", { path: serverPath });
await invoke("scan_server_dir", { path: serverPath });
console.log("Scan server dir command invoked successfully");
} catch (err) {
console.error("Error invoking scan command:", err);
@@ -253,6 +515,179 @@ function App() {
}
}
async function checkForUpdates() {
if (!plugins.length || isCheckingUpdates) return;
setIsCheckingUpdates(true);
setUpdateError(null);
setBulkUpdateProgress(null);
console.log("Invoking bulk check_plugin_updates...");
try {
const repositoriesToCheck = ['SpigotMC', 'Modrinth', 'GitHub'];
const pluginsToSend = plugins.map(p => ({
name: p.name,
version: p.version,
authors: p.authors || [],
file_path: p.file_path,
file_hash: p.file_hash,
website: p.website,
description: p.description,
api_version: p.api_version,
main_class: p.main_class,
depend: p.depend,
soft_depend: p.soft_depend,
load_before: p.load_before,
commands: p.commands,
permissions: p.permissions,
has_update: p.has_update || false,
repository_source: p.repository_source,
repository_id: p.repository_id,
repository_url: p.repository_url,
}));
console.log("Sending plugin data to backend, count:", pluginsToSend.length);
const updatedPlugins = await invoke<Plugin[]>("check_plugin_updates", {
plugins: pluginsToSend,
repositories: repositoriesToCheck,
});
console.log("Bulk update check completed successfully, updating state.");
setPlugins(updatedPlugins);
if (serverPath) {
try {
console.log("[checkForUpdates] Saving plugin data...");
await invoke("save_plugin_data", { plugins: updatedPlugins, serverPath });
console.log("[checkForUpdates] Plugin data saved successfully.");
} catch (saveError) {
console.error("Error saving plugin data after bulk update:", saveError);
setUpdateError(`Update check complete, but failed to save plugin data: ${saveError}`);
}
}
} catch (err) {
const errorMessage = `Error during bulk update check: ${err instanceof Error ? err.message : String(err)}`;
console.error(errorMessage);
setUpdateError(errorMessage);
} finally {
setIsCheckingUpdates(false);
setBulkUpdateProgress(null);
}
}
async function checkSinglePlugin(plugin: Plugin) {
if (isScanning || isCheckingUpdates || pluginLoadingStates[plugin.file_path]) return;
console.log(`Invoking single check for: ${plugin.name} (${plugin.file_path})`);
setPluginLoadingStates(prev => ({ ...prev, [plugin.file_path]: true }));
setUpdateError(null);
try {
const repositoriesToCheck = ['SpigotMC', 'Modrinth', 'GitHub'];
const pluginToSend = {
name: plugin.name,
version: plugin.version,
authors: plugin.authors || [],
file_path: plugin.file_path,
file_hash: plugin.file_hash,
website: plugin.website,
description: plugin.description,
api_version: plugin.api_version,
main_class: plugin.main_class,
depend: plugin.depend,
soft_depend: plugin.soft_depend,
load_before: plugin.load_before,
commands: plugin.commands,
permissions: plugin.permissions,
has_update: plugin.has_update,
};
await invoke("check_single_plugin_update_command", {
pluginToCheck: pluginToSend,
repositoriesToCheck,
});
} catch (err) {
const errorMessage = `Error invoking single update command for ${plugin.name}: ${err instanceof Error ? err.message : String(err)}`;
console.error(errorMessage);
setUpdateError(errorMessage);
setPluginLoadingStates(prev => ({ ...prev, [plugin.file_path]: false }));
}
}
async function updatePlugin(plugin: Plugin) {
if (!plugin.has_update || !plugin.latest_version || !plugin.repository_source || !plugin.repository_id) {
setUpdateError(`Cannot update ${plugin.name}: Missing required update information`);
return;
}
setPluginLoadingStates(prev => ({ ...prev, [plugin.file_path]: true }));
setUpdateError(null);
try {
console.log(`Updating plugin: ${plugin.name} to version ${plugin.latest_version}`);
const newFilePath = await invoke<string>("replace_plugin", {
pluginId: plugin.repository_id,
version: plugin.latest_version,
repository: plugin.repository_source,
currentFilePath: plugin.file_path,
serverInfo: serverInfo
});
console.log(`Update successful for ${plugin.name}, new file path: ${newFilePath}`);
setPlugins(currentPlugins => currentPlugins.map(p => {
if (p.file_path === plugin.file_path) {
return {
...p,
version: p.latest_version || p.version,
has_update: false,
latest_version: p.latest_version,
file_path: newFilePath
};
}
return p;
}));
if (serverPath) {
await invoke("save_plugin_data", {
plugins: plugins.map(p => {
if (p.file_path === plugin.file_path) {
return {
...p,
version: p.latest_version || p.version,
has_update: false,
file_path: newFilePath
};
}
return p;
}),
serverPath
});
}
} catch (err) {
const errorMessage = err instanceof Error ? err.message : String(err);
console.error(`Error updating ${plugin.name}:`, errorMessage);
if (errorMessage.includes("in use") ||
errorMessage.includes("server running") ||
errorMessage.includes("being used by another process")) {
setWarningMessage(`Cannot update ${plugin.name}: The Minecraft server appears to be running. Please stop your server before updating plugins.`);
} else if (errorMessage.includes("download failed")) {
setUpdateError(`Failed to download update for ${plugin.name}. Please check your internet connection and try again.`);
} else if (errorMessage.includes("Critical error")) {
setWarningMessage(`${errorMessage} A backup of your original plugin is available in the backups folder.`);
} else {
setUpdateError(`Error updating ${plugin.name}: ${errorMessage}`);
}
} finally {
setPluginLoadingStates(prev => ({ ...prev, [plugin.file_path]: false }));
}
}
const showPluginDetails = (plugin: Plugin) => {
setSelectedPlugin(plugin);
};
@@ -261,6 +696,48 @@ function App() {
setSelectedPlugin(null);
};
const handleSelectMatch = async (selectedMatch: PotentialPluginMatch) => {
if (!pluginToDisambiguate || !serverPath) return;
console.log(`User selected match: ${selectedMatch.name} from ${selectedMatch.repository}`);
setShowMatchSelector(false);
setPluginLoadingStates(prev => ({ ...prev, [pluginToDisambiguate.file_path]: true }));
try {
const updatedPlugin: Plugin = await invoke("set_plugin_repository", {
pluginFilePath: pluginToDisambiguate.file_path,
repository: selectedMatch.repository,
repositoryId: selectedMatch.repository_id,
pageUrl: selectedMatch.page_url,
serverPath: serverPath,
});
setPlugins(currentPlugins =>
currentPlugins.map(p =>
p.file_path === updatedPlugin.file_path ? updatedPlugin : p
)
);
console.log(`Successfully set repository source for ${updatedPlugin.name}`);
} catch (err) {
console.error("Error setting plugin repository source:", err);
setUpdateError(`Failed to set repository source for ${pluginToDisambiguate.name}: ${err}`);
} finally {
setPluginLoadingStates(prev => ({ ...prev, [pluginToDisambiguate.file_path]: false }));
setPluginToDisambiguate(null);
setPotentialMatches([]);
}
};
const handleCancelMatchSelection = () => {
setShowMatchSelector(false);
setPluginToDisambiguate(null);
setPotentialMatches([]);
if (pluginToDisambiguate) {
setPluginLoadingStates(prev => ({ ...prev, [pluginToDisambiguate.file_path]: false }));
}
};
return (
<div className="app-container">
<header className="app-header">
@@ -303,44 +780,104 @@ function App() {
)}
</section>
{scanComplete && serverInfo && (
{serverInfo && (
<ServerInfoDisplay serverInfo={serverInfo} />
)}
{scanComplete && (
<section className="plugins-list">
<h2>Installed Plugins ({plugins.length})</h2>
{plugins.length > 0 ? (
<>
<div className="plugins-header">
<span>Name</span>
<span>Current Version</span>
<span>Latest Version</span>
<span>Actions</span>
</div>
{plugins.map((plugin, index) => (
<div key={index} className={`plugin-item ${plugin.has_update ? 'has-update' : ''}`}>
<div className="plugin-name">{plugin.name}</div>
<div className="plugin-version">{plugin.version}</div>
<div className="plugin-latest-version">{plugin.latest_version || 'Unknown'}</div>
<div className="plugin-actions">
{plugin.has_update && (
<button className="update-button">Update</button>
)}
<button className="info-button" onClick={() => showPluginDetails(plugin)}>Info</button>
</div>
{serverInfo && plugins.length > 0 && (
<div className="update-controls">
<button
onClick={checkForUpdates}
disabled={isScanning || isCheckingUpdates || Object.values(pluginLoadingStates).some(isLoading => isLoading) || plugins.length === 0}
className="action-button update-check-button"
>
{isCheckingUpdates ? 'Checking All...' : 'Check All for Updates'}
</button>
{isCheckingUpdates && bulkUpdateProgress && (
<div className="bulk-update-progress">
Checking {bulkUpdateProgress.processed}/{bulkUpdateProgress.total}: {bulkUpdateProgress.current_plugin_name}
<progress value={bulkUpdateProgress.processed} max={bulkUpdateProgress.total}></progress>
</div>
))}
</>
) : (
<p>No plugins found in this directory.</p>
)}
)}
{updateError && (
<div className="error-message update-error">{updateError}</div>
)}
</div>
)}
{plugins.length > 0 && (
<section className="plugins-list">
<h2>Installed Plugins ({plugins.length})</h2>
<div className="plugins-header">
<span>Name</span>
<span>Current Version</span>
<span>Latest Version</span>
<span>Actions</span>
</div>
{plugins.map((plugin) => (
<div key={plugin.file_path} className={`plugin-item ${plugin.has_update ? 'has-update' : ''}`}>
<div className="plugin-name">{plugin.name}</div>
<div className="plugin-version">{plugin.version}</div>
<div className="plugin-latest-version">
{plugin.repository_url && plugin.latest_version ? (
<a href={plugin.repository_url} target="_blank" rel="noopener noreferrer" className="version-link">
{plugin.latest_version}
</a>
) : (
plugin.latest_version || 'N/A'
)}
</div>
<div className="plugin-actions">
<button
className="action-button check-single-button"
onClick={() => checkSinglePlugin(plugin)}
disabled={isScanning || isCheckingUpdates || pluginLoadingStates[plugin.file_path]}
>
{pluginLoadingStates[plugin.file_path] ? 'Checking...' : 'Check'}
</button>
{plugin.has_update && (
<button
className="update-button"
onClick={() => updatePlugin(plugin)}
disabled={isScanning || isCheckingUpdates || pluginLoadingStates[plugin.file_path]}
>
{pluginLoadingStates[plugin.file_path] ? 'Updating...' : 'Update'}
</button>
)}
<button className="info-button" onClick={() => showPluginDetails(plugin)}>Info</button>
</div>
</div>
))}
</section>
)}
{scanComplete && plugins.length === 0 && (
<section className="plugins-list">
<h2>Installed Plugins (0)</h2>
<p>No plugins found in this directory.</p>
</section>
)}
{selectedPlugin && (
<PluginDetails plugin={selectedPlugin} onClose={closePluginDetails} />
)}
{warningMessage && (
<WarningModal
message={warningMessage}
onClose={() => setWarningMessage(null)}
/>
)}
{showMatchSelector && pluginToDisambiguate && (
<PluginMatchSelector
plugin={pluginToDisambiguate}
potentialMatches={potentialMatches}
onSelect={handleSelectMatch}
onCancel={handleCancelMatchSelection}
/>
)}
</main>
<footer className="app-footer">