Skip to content

If Plugin install fails, show a message #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/renderer/components/MainAppPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,12 @@ export default function MainAppPanel({
/>
<Route
path="/plugins"
element={<Plugins experimentInfo={experimentInfo} />}
element={
<Plugins
experimentInfo={experimentInfo}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
}
/>
<Route
path="/plugins/:pluginName"
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/components/Plugins/LocalPlugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import NewPluginModal from './NewPluginModal';

const fetcher = (url) => 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(
Expand Down Expand Up @@ -77,6 +80,7 @@ export default function LocalPlugins({ experimentInfo }) {
download={undefined}
experimentInfo={experimentInfo}
machineType={device}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
</Grid>
))}
Expand Down
20 changes: 19 additions & 1 deletion src/renderer/components/Plugins/PluginCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function PluginCard({
parentMutate,
experimentInfo = {},
machineType,
setLogsDrawerOpen = null,
}) {
const [installing, setInstalling] = useState(null);

Expand Down Expand Up @@ -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();
}}
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/components/Plugins/PluginGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -187,6 +190,7 @@ export default function PluginGallery({ experimentInfo }) {
experimentInfo={experimentInfo}
parentMutate={mutate}
machineType={device}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
</Grid>
))}
Expand Down Expand Up @@ -220,6 +224,7 @@ export default function PluginGallery({ experimentInfo }) {
experimentInfo={experimentInfo}
parentMutate={mutate}
machineType={device}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
</Box>
</Grid>
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/components/Plugins/Plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -114,7 +114,10 @@ export default function Plugins({ experimentInfo }) {
<Sheet
sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}
>
<LocalPlugins experimentInfo={experimentInfo} />
<LocalPlugins
experimentInfo={experimentInfo}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
</Sheet>
</TabPanel>
<TabPanel
Expand All @@ -128,7 +131,10 @@ export default function Plugins({ experimentInfo }) {
<Sheet
sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}
>
<PluginGallery experimentInfo={experimentInfo} />
<PluginGallery
experimentInfo={experimentInfo}
setLogsDrawerOpen={setLogsDrawerOpen}
/>
</Sheet>
</TabPanel>
</Tabs>
Expand Down