diff --git a/packages/web_ui/src/components/ModsPage.tsx b/packages/web_ui/src/components/ModsPage.tsx index 868d8251..ab229010 100644 --- a/packages/web_ui/src/components/ModsPage.tsx +++ b/packages/web_ui/src/components/ModsPage.tsx @@ -176,6 +176,33 @@ function SearchModsButton() { const [sort, setSort] = useState("name"); const [sortOrder, setSortOrder] = useState<"asc" | "desc">("asc"); + // Function to handle download from Mod Portal to Controller + const handleControllerDownload = ( + modName: string, + modTitle: string | undefined, + modVersion: string | undefined, + portalFactorioVersion: FactorioVersion, + ) => { + if (modVersion) { + control.send( + new lib.ModPortalDownloadRequest( + modName, + modVersion, + portalFactorioVersion + ) + ).then(() => { + notification.success({ + message: "Download started", + description: `${modTitle || modName} v${ + modVersion + } is being downloaded to the controller.`, + }); + }).catch( + notifyErrorHandler("Error starting mod download") + ); + } + }; + // Fetch all mods from backend when modal opens or version changes useEffect(() => { if (!open || !factorioVersion) { @@ -408,22 +435,12 @@ function SearchModsButton() { {account.hasPermission("core.mod.download") && record.latest_release && (