mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 07:29:40 +02:00
Optimize sidebar collapsing
This commit is contained in:
@@ -44,11 +44,7 @@ use crate::render::{render_grpc_request, render_http_request, render_json_value,
|
||||
use crate::template_callback::PluginTemplateCallback;
|
||||
use crate::updates::{UpdateMode, YaakUpdater};
|
||||
use crate::window_menu::app_menu;
|
||||
use yaak_models::models::{
|
||||
CookieJar, Environment, EnvironmentVariable, Folder, GrpcConnection, GrpcConnectionState,
|
||||
GrpcEvent, GrpcEventType, GrpcRequest, HttpRequest, HttpResponse, HttpResponseState, KeyValue,
|
||||
ModelType, Plugin, Settings, Workspace,
|
||||
};
|
||||
use yaak_models::models::{CookieJar, Environment, EnvironmentVariable, Folder, GrpcConnection, GrpcConnectionState, GrpcEvent, GrpcEventType, GrpcRequest, HttpRequest, HttpResponse, HttpResponseState, KeyValue, KeyValueIden, ModelType, Plugin, Settings, Workspace};
|
||||
use yaak_models::queries::{
|
||||
cancel_pending_grpc_connections, cancel_pending_responses, create_default_http_response,
|
||||
delete_all_grpc_connections, delete_all_grpc_connections_for_workspace,
|
||||
@@ -61,10 +57,10 @@ use yaak_models::queries::{
|
||||
get_key_value_raw, get_or_create_settings, get_plugin, get_workspace, list_cookie_jars,
|
||||
list_environments, list_folders, list_grpc_connections_for_workspace, list_grpc_events,
|
||||
list_grpc_requests, list_http_requests, list_http_responses_for_request,
|
||||
list_http_responses_for_workspace, list_plugins, list_workspaces, set_key_value_raw,
|
||||
update_response_if_id, update_settings, upsert_cookie_jar, upsert_environment, upsert_folder,
|
||||
upsert_grpc_connection, upsert_grpc_event, upsert_grpc_request, upsert_http_request,
|
||||
upsert_plugin, upsert_workspace,
|
||||
list_http_responses_for_workspace, list_key_values_raw, list_plugins, list_workspaces,
|
||||
set_key_value_raw, update_response_if_id, update_settings, upsert_cookie_jar,
|
||||
upsert_environment, upsert_folder, upsert_grpc_connection, upsert_grpc_event,
|
||||
upsert_grpc_request, upsert_http_request, upsert_plugin, upsert_workspace,
|
||||
};
|
||||
use yaak_plugin_runtime::events::{
|
||||
BootResponse, CallHttpRequestActionRequest, FilterResponse, FindHttpResponsesResponse,
|
||||
@@ -1513,6 +1509,11 @@ async fn cmd_list_cookie_jars(
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn cmd_list_key_values(w: WebviewWindow) -> Result<Vec<KeyValue>, String> {
|
||||
list_key_values_raw(&w).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn cmd_get_environment(id: &str, w: WebviewWindow) -> Result<Environment, String> {
|
||||
get_environment(&w, id).await.map_err(|e| e.to_string())
|
||||
@@ -1797,6 +1798,7 @@ pub fn run() {
|
||||
cmd_list_grpc_connections,
|
||||
cmd_list_grpc_events,
|
||||
cmd_list_grpc_requests,
|
||||
cmd_list_key_values,
|
||||
cmd_list_http_requests,
|
||||
cmd_list_http_responses,
|
||||
cmd_list_plugins,
|
||||
|
||||
@@ -126,6 +126,18 @@ pub async fn set_key_value_raw<R: Runtime>(
|
||||
(emit_upserted_model(w, kv), existing.is_none())
|
||||
}
|
||||
|
||||
pub async fn list_key_values_raw<R: Runtime>(mgr: &impl Manager<R>) -> Result<Vec<KeyValue>> {
|
||||
let dbm = &*mgr.state::<SqliteConnection>();
|
||||
let db = dbm.0.lock().await.get().unwrap();
|
||||
let (sql, params) = Query::select()
|
||||
.from(KeyValueIden::Table)
|
||||
.column(Asterisk)
|
||||
.build_rusqlite(SqliteQueryBuilder);
|
||||
let mut stmt = db.prepare(sql.as_str())?;
|
||||
let items = stmt.query_map(&*params.as_params(), |row| row.try_into())?;
|
||||
Ok(items.map(|v| v.unwrap()).collect())
|
||||
}
|
||||
|
||||
pub async fn get_key_value_raw<R: Runtime>(
|
||||
mgr: &impl Manager<R>,
|
||||
namespace: &str,
|
||||
@@ -767,7 +779,7 @@ pub async fn list_environments<R: Runtime>(
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
environments.push(base_environment);
|
||||
}
|
||||
|
||||
@@ -857,7 +869,7 @@ pub async fn update_settings<R: Runtime>(
|
||||
None => None,
|
||||
Some(p) => Some(serde_json::to_string(&p)?),
|
||||
})
|
||||
.into(),
|
||||
.into(),
|
||||
),
|
||||
])
|
||||
.returning_all()
|
||||
@@ -1182,7 +1194,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
||||
..src_folder.clone()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
|
||||
for m in http_requests {
|
||||
upsert_http_request(
|
||||
@@ -1194,7 +1206,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
||||
..m
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
}
|
||||
for m in grpc_requests {
|
||||
upsert_grpc_request(
|
||||
@@ -1206,7 +1218,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
||||
..m
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
}
|
||||
for m in folders {
|
||||
// Recurse down
|
||||
@@ -1217,7 +1229,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
||||
..m
|
||||
},
|
||||
))
|
||||
.await?;
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1376,7 +1388,7 @@ pub async fn create_default_http_response<R: Runtime>(
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.await
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
||||
Reference in New Issue
Block a user