Skip to content

Commit e63d7c6

Browse files
committed
Pop out console when plugin install error happens
1 parent 208f1d8 commit e63d7c6

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
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: 11 additions & 6 deletions
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

@@ -134,7 +135,7 @@ export default function PluginCard({
134135
{/* {JSON.stringify(plugin)} */}
135136
<Typography
136137
level="title-lg"
137-
// startDecorator={getIcon(type)}
138+
// startDecorator={getIcon(type)}
138139
>
139140
<b>
140141
{plugin.name}&nbsp;
@@ -239,18 +240,22 @@ export default function PluginCard({
239240
experimentInfo?.id,
240241
plugin.uniqueId,
241242
),
242-
).then(async response => {
243+
).then(async (response) => {
243244
if (response.ok) {
244245
const responseBody = await response.json();
245246
console.log('Response Body:', responseBody);
246247
if (responseBody?.status == 'error') {
247-
/*if (setLogsDrawerOpen) {
248+
alert(
249+
`Failed to install plugin:\n${responseBody?.message}`,
250+
);
251+
if (setLogsDrawerOpen) {
248252
setLogsDrawerOpen(true);
249-
}*/
250-
alert(`Failed to install plugin:\n${responseBody?.message}`);
253+
}
251254
}
252255
} else {
253-
alert("Error: The API did not return a response. Plugin installation failed.");
256+
alert(
257+
'Error: The API did not return a response. Plugin installation failed.',
258+
);
254259
}
255260
});
256261
setInstalling(null);

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)