Tweak workspace settings and a bunch of small things

This commit is contained in:
Gregory Schier
2025-07-18 08:47:14 -07:00
parent 4c375ed3e9
commit bcde4de4a7
28 changed files with 450 additions and 271 deletions

View File

@@ -1,9 +1,10 @@
use crate::api::{
PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates, search_plugins,
check_plugin_updates, search_plugins, PluginSearchResponse, PluginUpdatesResponse,
};
use crate::error::Result;
use crate::install::download_and_install;
use tauri::{AppHandle, Runtime, WebviewWindow, command};
use crate::install::{delete_and_uninstall, download_and_install};
use tauri::{command, AppHandle, Runtime, WebviewWindow};
use yaak_models::models::Plugin;
#[command]
pub(crate) async fn search<R: Runtime>(
@@ -23,6 +24,14 @@ pub(crate) async fn install<R: Runtime>(
Ok(())
}
#[command]
pub(crate) async fn uninstall<R: Runtime>(
plugin_id: &str,
window: WebviewWindow<R>,
) -> Result<Plugin> {
delete_and_uninstall(&window, plugin_id).await
}
#[command]
pub(crate) async fn updates<R: Runtime>(app_handle: AppHandle<R>) -> Result<PluginUpdatesResponse> {
check_plugin_updates(&app_handle).await

View File

@@ -13,6 +13,13 @@ use yaak_models::models::Plugin;
use yaak_models::query_manager::QueryManagerExt;
use yaak_models::util::UpdateSource;
pub async fn delete_and_uninstall<R: Runtime>(window: &WebviewWindow<R>, plugin_id: &str) -> Result<Plugin> {
let plugin_manager = window.state::<PluginManager>();
let plugin = window.db().delete_plugin_by_id(plugin_id, &UpdateSource::from_window(&window))?;
plugin_manager.uninstall(&PluginWindowContext::new(&window), plugin.directory.as_str()).await?;
Ok(plugin)
}
pub async fn download_and_install<R: Runtime>(
window: &WebviewWindow<R>,
name: &str,

View File

@@ -1,9 +1,9 @@
use crate::commands::{install, search, updates};
use crate::commands::{install, search, uninstall, updates};
use crate::manager::PluginManager;
use log::info;
use std::process::exit;
use tauri::plugin::{Builder, TauriPlugin};
use tauri::{Manager, RunEvent, Runtime, State, generate_handler};
use tauri::{generate_handler, Manager, RunEvent, Runtime, State};
mod commands;
pub mod error;
@@ -22,7 +22,7 @@ pub mod plugin_meta;
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("yaak-plugins")
.invoke_handler(generate_handler![search, install, updates])
.invoke_handler(generate_handler![search, install, uninstall, updates])
.setup(|app_handle, _| {
let manager = PluginManager::new(app_handle.clone());
app_handle.manage(manager.clone());