Skip to content
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
13 changes: 13 additions & 0 deletions apps/yaak-client/lib/initGlobalListeners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ export function initGlobalListeners() {
color: "danger",
timeout: null,
message: `Failed to load plugin "${name}": ${err}`,
action: ({ hide }) => (
<Button
size="xs"
color="danger"
variant="border"
onClick={() => {
hide();
openSettings.mutate("plugins:installed");
}}
>
Manage Plugins
</Button>
),
});
}
});
Expand Down
33 changes: 29 additions & 4 deletions crates-tauri/yaak-app-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use yaak_plugins::events::{
InternalEventPayload, JsonPrimitive, PluginContext, RenderPurpose, ShowToastRequest,
};
use yaak_plugins::manager::PluginManager;
use yaak_plugins::plugin_meta::PluginMetadata;
use yaak_plugins::plugin_meta::{PluginMetadata, get_plugin_meta};
use yaak_plugins::template_callback::PluginTemplateCallback;
use yaak_sse::sse::ServerSentEvent;
use yaak_tauri_utils::window::WorkspaceWindowTrait;
Expand Down Expand Up @@ -1512,11 +1512,36 @@ async fn cmd_plugin_info<R: Runtime>(
plugin_manager: State<'_, PluginManager>,
) -> YaakResult<PluginMetadata> {
let plugin = app_handle.db().get_plugin(id)?;
Ok(plugin_manager
if let Some(plugin_handle) = plugin_manager
.get_plugin_by_dir(plugin.directory.as_str())
.await
.ok_or(GenericError("Failed to find plugin for info".to_string()))?
.info())
{
return Ok(plugin_handle.info());
}

if let Ok(metadata) = get_plugin_meta(&PathBuf::from(&plugin.directory)) {
return Ok(metadata);
}

Ok(fallback_plugin_metadata(&plugin.directory))
}

fn fallback_plugin_metadata(directory: &str) -> PluginMetadata {
let display_name = PathBuf::from(directory)
.file_name()
.and_then(|name| name.to_str())
.filter(|name| !name.is_empty())
.unwrap_or(directory)
.to_string();

PluginMetadata {
version: "Unavailable".to_string(),
name: directory.to_string(),
display_name,
description: Some(format!("Plugin metadata could not be loaded from {directory}")),
homepage_url: None,
repository_url: None,
}
}

#[tauri::command]
Expand Down
11 changes: 9 additions & 2 deletions crates/yaak-plugins/src/install.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::api::{PluginVersion, download_plugin_archive, get_plugin};
use crate::checksum::compute_checksum;
use crate::error::Error::PluginErr;
use crate::error::Error::{PluginErr, PluginNotFoundErr};
use crate::error::Result;
use crate::events::PluginContext;
use crate::manager::PluginManager;
Expand Down Expand Up @@ -29,7 +29,14 @@ pub async fn delete_and_uninstall(
let db = query_manager.connect();
db.delete_plugin_by_id(plugin_id, &update_source)?
};
plugin_manager.uninstall(plugin_context, plugin.directory.as_str()).await?;
if let Err(err) = plugin_manager
.uninstall(plugin_context, plugin.directory.as_str())
.await
{
if !matches!(err, PluginNotFoundErr(_)) {
return Err(err);
}
}
Ok(plugin)
}

Expand Down