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

@@ -35,13 +35,7 @@ use yaak_models::models::{
};
use yaak_models::query_manager::QueryManagerExt;
use yaak_models::util::{BatchUpsertResult, UpdateSource, get_workspace_export_resources};
use yaak_plugins::events::{
CallGrpcRequestActionArgs, CallGrpcRequestActionRequest, CallHttpRequestActionArgs,
CallHttpRequestActionRequest, FilterResponse, GetGrpcRequestActionsResponse,
GetHttpAuthenticationConfigResponse, GetHttpAuthenticationSummaryResponse,
GetHttpRequestActionsResponse, GetTemplateFunctionsResponse, InternalEvent,
InternalEventPayload, JsonPrimitive, PluginWindowContext, RenderPurpose,
};
use yaak_plugins::events::{CallGrpcRequestActionArgs, CallGrpcRequestActionRequest, CallHttpRequestActionArgs, CallHttpRequestActionRequest, Color, FilterResponse, GetGrpcRequestActionsResponse, GetHttpAuthenticationConfigResponse, GetHttpAuthenticationSummaryResponse, GetHttpRequestActionsResponse, GetTemplateFunctionsResponse, InternalEvent, InternalEventPayload, JsonPrimitive, PluginWindowContext, RenderPurpose, ShowToastRequest};
use yaak_plugins::manager::PluginManager;
use yaak_plugins::plugin_meta::PluginMetadata;
use yaak_plugins::template_callback::PluginTemplateCallback;
@@ -1053,21 +1047,6 @@ async fn cmd_install_plugin<R: Runtime>(
)?)
}
#[tauri::command]
async fn cmd_uninstall_plugin<R: Runtime>(
plugin_id: &str,
plugin_manager: State<'_, PluginManager>,
window: WebviewWindow<R>,
app_handle: AppHandle<R>,
) -> YaakResult<Plugin> {
let plugin =
app_handle.db().delete_plugin_by_id(plugin_id, &UpdateSource::from_window(&window))?;
plugin_manager.uninstall(&PluginWindowContext::new(&window), plugin.directory.as_str()).await?;
Ok(plugin)
}
#[tauri::command]
async fn cmd_create_grpc_request<R: Runtime>(
workspace_id: &str,
@@ -1256,6 +1235,14 @@ pub fn run() {
for url in event.urls() {
if let Err(e) = handle_deep_link(&app_handle, &url).await {
warn!("Failed to handle deep link {}: {e:?}", url.to_string());
let _ = app_handle.emit(
"show_toast",
ShowToastRequest {
message: format!("Error handling deep link: {}", e.to_string()),
color: Some(Color::Danger),
icon: None,
},
);
};
}
});
@@ -1316,7 +1303,6 @@ pub fn run() {
cmd_send_http_request,
cmd_template_functions,
cmd_template_tokens_to_string,
cmd_uninstall_plugin,
//
//
// Migrated commands

View File

@@ -2,8 +2,11 @@ use crate::error::Result;
use crate::import::import_data;
use log::{info, warn};
use std::collections::HashMap;
use std::fs;
use tauri::{AppHandle, Emitter, Manager, Runtime, Url};
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
use yaak_common::api_client::yaak_api_client;
use yaak_models::util::generate_id;
use yaak_plugins::events::{Color, ShowToastRequest};
use yaak_plugins::install::download_and_install;
@@ -25,9 +28,12 @@ pub(crate) async fn handle_deep_link<R: Runtime>(
_ = window.set_focus();
let confirmed_install = app_handle
.dialog()
.message(format!("Install plugin {name} {version:?}?",))
.message(format!("Install plugin {name} {version:?}?"))
.kind(MessageDialogKind::Info)
.buttons(MessageDialogButtons::OkCustom("Install".to_string()))
.buttons(MessageDialogButtons::OkCancelCustom(
"Install".to_string(),
"Cancel".to_string(),
))
.blocking_show();
if !confirmed_install {
// Cancelled installation
@@ -45,8 +51,51 @@ pub(crate) async fn handle_deep_link<R: Runtime>(
)?;
}
"import-data" => {
let file_path = query_map.get("path").unwrap();
let results = import_data(window, file_path).await?;
let mut file_path = query_map.get("path").map(|s| s.to_owned());
let name = query_map.get("name").map(|s| s.to_owned()).unwrap_or("data".to_string());
if let Some(file_url) = query_map.get("url") {
let confirmed_import = app_handle
.dialog()
.message(format!("Import {name} from {file_url}?"))
.kind(MessageDialogKind::Info)
.buttons(MessageDialogButtons::OkCancelCustom(
"Import".to_string(),
"Cancel".to_string(),
))
.blocking_show();
if !confirmed_import {
return Ok(());
}
let resp = yaak_api_client(app_handle)?.get(file_url).send().await?;
let json = resp.bytes().await?;
let p = app_handle
.path()
.temp_dir()?
.join(format!("import-{}", generate_id()))
.to_string_lossy()
.to_string();
fs::write(&p, json)?;
file_path = Some(p);
}
let file_path = match file_path {
Some(p) => p,
None => {
app_handle.emit(
"show_toast",
ShowToastRequest {
message: "Failed to import data".to_string(),
color: Some(Color::Danger),
icon: None,
},
)?;
return Ok(());
}
};
let results = import_data(window, &file_path).await?;
_ = window.set_focus();
window.emit(
"show_toast",