diff --git a/src/renderer/components/MainAppPanel.tsx b/src/renderer/components/MainAppPanel.tsx index 93710997..d342f5a9 100644 --- a/src/renderer/components/MainAppPanel.tsx +++ b/src/renderer/components/MainAppPanel.tsx @@ -472,7 +472,12 @@ export default function MainAppPanel({ /> } + element={ + + } /> fetch(url).then((res) => res.json()); -export default function LocalPlugins({ experimentInfo }) { +export default function LocalPlugins({ + experimentInfo, + setLogsDrawerOpen = null, +}) { const [newPluginModalOpen, setNewPluginModalOpen] = useState(false); const { data, error, isLoading, mutate } = useSWR( @@ -77,6 +80,7 @@ export default function LocalPlugins({ experimentInfo }) { download={undefined} experimentInfo={experimentInfo} machineType={device} + setLogsDrawerOpen={setLogsDrawerOpen} /> ))} diff --git a/src/renderer/components/Plugins/PluginCard.tsx b/src/renderer/components/Plugins/PluginCard.tsx index c81a710f..4b373221 100644 --- a/src/renderer/components/Plugins/PluginCard.tsx +++ b/src/renderer/components/Plugins/PluginCard.tsx @@ -83,6 +83,7 @@ export default function PluginCard({ parentMutate, experimentInfo = {}, machineType, + setLogsDrawerOpen = null, }) { const [installing, setInstalling] = useState(null); @@ -239,7 +240,24 @@ export default function PluginCard({ experimentInfo?.id, plugin.uniqueId, ), - ); + ).then(async (response) => { + if (response.ok) { + const responseBody = await response.json(); + console.log('Response Body:', responseBody); + if (responseBody?.status == 'error') { + alert( + `Failed to install plugin:\n${responseBody?.message}`, + ); + if (setLogsDrawerOpen) { + setLogsDrawerOpen(true); + } + } + } else { + alert( + 'Error: The API did not return a response. Plugin installation failed.', + ); + } + }); setInstalling(null); parentMutate(); }} diff --git a/src/renderer/components/Plugins/PluginGallery.tsx b/src/renderer/components/Plugins/PluginGallery.tsx index fb5639fe..020213e8 100644 --- a/src/renderer/components/Plugins/PluginGallery.tsx +++ b/src/renderer/components/Plugins/PluginGallery.tsx @@ -22,7 +22,10 @@ import PluginCard from './PluginCard'; const fetcher = (url) => fetch(url).then((res) => res.json()); -export default function PluginGallery({ experimentInfo }) { +export default function PluginGallery({ + experimentInfo, + setLogsDrawerOpen = null, +}) { const { data, error, isLoading, mutate } = useSWR( chatAPI.Endpoints.Plugins.Gallery(), fetcher, @@ -187,6 +190,7 @@ export default function PluginGallery({ experimentInfo }) { experimentInfo={experimentInfo} parentMutate={mutate} machineType={device} + setLogsDrawerOpen={setLogsDrawerOpen} /> ))} @@ -220,6 +224,7 @@ export default function PluginGallery({ experimentInfo }) { experimentInfo={experimentInfo} parentMutate={mutate} machineType={device} + setLogsDrawerOpen={setLogsDrawerOpen} /> diff --git a/src/renderer/components/Plugins/Plugins.tsx b/src/renderer/components/Plugins/Plugins.tsx index 67e84502..f31118f6 100644 --- a/src/renderer/components/Plugins/Plugins.tsx +++ b/src/renderer/components/Plugins/Plugins.tsx @@ -18,7 +18,7 @@ import PluginGallery from './PluginGallery'; import LocalPlugins from './LocalPlugins'; import OneTimePopup from '../Shared/OneTimePopup'; -export default function Plugins({ experimentInfo }) { +export default function Plugins({ experimentInfo, setLogsDrawerOpen = null }) { const { data: outdatedPlugins, mutate: outdatePluginsMutate } = usePluginStatus(experimentInfo); const [installing, setInstalling] = useState(null); @@ -114,7 +114,10 @@ export default function Plugins({ experimentInfo }) { - + - +