Skip to content

Commit ee3da7c

Browse files
authored
Merge pull request #430 from transformerlab/fix/show_plugin_install_error
If Plugin install fails, show a message
2 parents cd4cdb7 + e63d7c6 commit ee3da7c

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

src/renderer/components/MainAppPanel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,12 @@ export default function MainAppPanel({
472472
/>
473473
<Route
474474
path="/plugins"
475-
element={<Plugins experimentInfo={experimentInfo} />}
475+
element={
476+
<Plugins
477+
experimentInfo={experimentInfo}
478+
setLogsDrawerOpen={setLogsDrawerOpen}
479+
/>
480+
}
476481
/>
477482
<Route
478483
path="/plugins/:pluginName"

src/renderer/components/Plugins/LocalPlugins.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import NewPluginModal from './NewPluginModal';
1818

1919
const fetcher = (url) => fetch(url).then((res) => res.json());
2020

21-
export default function LocalPlugins({ experimentInfo }) {
21+
export default function LocalPlugins({
22+
experimentInfo,
23+
setLogsDrawerOpen = null,
24+
}) {
2225
const [newPluginModalOpen, setNewPluginModalOpen] = useState(false);
2326

2427
const { data, error, isLoading, mutate } = useSWR(
@@ -77,6 +80,7 @@ export default function LocalPlugins({ experimentInfo }) {
7780
download={undefined}
7881
experimentInfo={experimentInfo}
7982
machineType={device}
83+
setLogsDrawerOpen={setLogsDrawerOpen}
8084
/>
8185
</Grid>
8286
))}

src/renderer/components/Plugins/PluginCard.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export default function PluginCard({
8383
parentMutate,
8484
experimentInfo = {},
8585
machineType,
86+
setLogsDrawerOpen = null,
8687
}) {
8788
const [installing, setInstalling] = useState(null);
8889

@@ -239,7 +240,24 @@ export default function PluginCard({
239240
experimentInfo?.id,
240241
plugin.uniqueId,
241242
),
242-
);
243+
).then(async (response) => {
244+
if (response.ok) {
245+
const responseBody = await response.json();
246+
console.log('Response Body:', responseBody);
247+
if (responseBody?.status == 'error') {
248+
alert(
249+
`Failed to install plugin:\n${responseBody?.message}`,
250+
);
251+
if (setLogsDrawerOpen) {
252+
setLogsDrawerOpen(true);
253+
}
254+
}
255+
} else {
256+
alert(
257+
'Error: The API did not return a response. Plugin installation failed.',
258+
);
259+
}
260+
});
243261
setInstalling(null);
244262
parentMutate();
245263
}}

src/renderer/components/Plugins/PluginGallery.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import PluginCard from './PluginCard';
2222

2323
const fetcher = (url) => fetch(url).then((res) => res.json());
2424

25-
export default function PluginGallery({ experimentInfo }) {
25+
export default function PluginGallery({
26+
experimentInfo,
27+
setLogsDrawerOpen = null,
28+
}) {
2629
const { data, error, isLoading, mutate } = useSWR(
2730
chatAPI.Endpoints.Plugins.Gallery(),
2831
fetcher,
@@ -187,6 +190,7 @@ export default function PluginGallery({ experimentInfo }) {
187190
experimentInfo={experimentInfo}
188191
parentMutate={mutate}
189192
machineType={device}
193+
setLogsDrawerOpen={setLogsDrawerOpen}
190194
/>
191195
</Grid>
192196
))}
@@ -220,6 +224,7 @@ export default function PluginGallery({ experimentInfo }) {
220224
experimentInfo={experimentInfo}
221225
parentMutate={mutate}
222226
machineType={device}
227+
setLogsDrawerOpen={setLogsDrawerOpen}
223228
/>
224229
</Box>
225230
</Grid>

src/renderer/components/Plugins/Plugins.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import PluginGallery from './PluginGallery';
1818
import LocalPlugins from './LocalPlugins';
1919
import OneTimePopup from '../Shared/OneTimePopup';
2020

21-
export default function Plugins({ experimentInfo }) {
21+
export default function Plugins({ experimentInfo, setLogsDrawerOpen = null }) {
2222
const { data: outdatedPlugins, mutate: outdatePluginsMutate } =
2323
usePluginStatus(experimentInfo);
2424
const [installing, setInstalling] = useState(null);
@@ -114,7 +114,10 @@ export default function Plugins({ experimentInfo }) {
114114
<Sheet
115115
sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}
116116
>
117-
<LocalPlugins experimentInfo={experimentInfo} />
117+
<LocalPlugins
118+
experimentInfo={experimentInfo}
119+
setLogsDrawerOpen={setLogsDrawerOpen}
120+
/>
118121
</Sheet>
119122
</TabPanel>
120123
<TabPanel
@@ -128,7 +131,10 @@ export default function Plugins({ experimentInfo }) {
128131
<Sheet
129132
sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}
130133
>
131-
<PluginGallery experimentInfo={experimentInfo} />
134+
<PluginGallery
135+
experimentInfo={experimentInfo}
136+
setLogsDrawerOpen={setLogsDrawerOpen}
137+
/>
132138
</Sheet>
133139
</TabPanel>
134140
</Tabs>

0 commit comments

Comments
 (0)