mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-02 03:17:40 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae7b3ef0f4 | ||
|
|
b6ad51c838 |
@@ -1,2 +1 @@
|
||||
- Tag safety: app releases use `v*` tags and CLI releases use `yaak-cli-*` tags; always confirm which one is requested before retagging.
|
||||
- Do not commit, push, or tag without explicit approval
|
||||
|
||||
@@ -37,8 +37,8 @@ use yaak_grpc::{Code, ServiceDefinition, serialize_message};
|
||||
use yaak_mac_window::AppHandleMacWindowExt;
|
||||
use yaak_models::models::{
|
||||
AnyModel, CookieJar, Environment, GrpcConnection, GrpcConnectionState, GrpcEvent,
|
||||
GrpcEventType, HttpRequest, HttpResponse, HttpResponseEvent, HttpResponseState, Workspace,
|
||||
WorkspaceMeta,
|
||||
GrpcEventType, HttpRequest, HttpResponse, HttpResponseEvent, HttpResponseState, Plugin,
|
||||
Workspace, WorkspaceMeta,
|
||||
};
|
||||
use yaak_models::util::{BatchUpsertResult, UpdateSource, get_workspace_export_resources};
|
||||
use yaak_plugins::events::{
|
||||
@@ -1345,6 +1345,29 @@ async fn cmd_send_http_request<R: Runtime>(
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn cmd_install_plugin<R: Runtime>(
|
||||
directory: &str,
|
||||
url: Option<String>,
|
||||
plugin_manager: State<'_, PluginManager>,
|
||||
app_handle: AppHandle<R>,
|
||||
window: WebviewWindow<R>,
|
||||
) -> YaakResult<Plugin> {
|
||||
let plugin = app_handle.db().upsert_plugin(
|
||||
&Plugin { directory: directory.into(), url, enabled: true, ..Default::default() },
|
||||
&UpdateSource::from_window_label(window.label()),
|
||||
)?;
|
||||
|
||||
plugin_manager
|
||||
.add_plugin(
|
||||
&PluginContext::new(Some(window.label().to_string()), window.workspace_id()),
|
||||
&plugin,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(plugin)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn cmd_reload_plugins<R: Runtime>(
|
||||
app_handle: AppHandle<R>,
|
||||
@@ -1629,6 +1652,7 @@ pub fn run() {
|
||||
cmd_workspace_actions,
|
||||
cmd_folder_actions,
|
||||
cmd_import_data,
|
||||
cmd_install_plugin,
|
||||
cmd_metadata,
|
||||
cmd_new_child_window,
|
||||
cmd_new_main_window,
|
||||
@@ -1697,7 +1721,6 @@ pub fn run() {
|
||||
git_ext::cmd_git_rm_remote,
|
||||
//
|
||||
// Plugin commands
|
||||
plugins_ext::cmd_plugins_install_from_directory,
|
||||
plugins_ext::cmd_plugins_search,
|
||||
plugins_ext::cmd_plugins_install,
|
||||
plugins_ext::cmd_plugins_uninstall,
|
||||
|
||||
@@ -15,7 +15,6 @@ use yaak_models::error::Result;
|
||||
use yaak_models::models::{AnyModel, GraphQlIntrospection, GrpcEvent, Settings, WebsocketEvent};
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::UpdateSource;
|
||||
use yaak_plugins::manager::PluginManager;
|
||||
|
||||
const MODEL_CHANGES_RETENTION_HOURS: i64 = 1;
|
||||
const MODEL_CHANGES_POLL_INTERVAL_MS: u64 = 1000;
|
||||
@@ -256,32 +255,23 @@ pub(crate) fn models_upsert_graphql_introspection<R: Runtime>(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) async fn models_workspace_models<R: Runtime>(
|
||||
pub(crate) fn models_workspace_models<R: Runtime>(
|
||||
window: WebviewWindow<R>,
|
||||
workspace_id: Option<&str>,
|
||||
plugin_manager: State<'_, PluginManager>,
|
||||
) -> Result<String> {
|
||||
let db = window.db();
|
||||
let mut l: Vec<AnyModel> = Vec::new();
|
||||
|
||||
// Add the global models
|
||||
{
|
||||
let db = window.db();
|
||||
l.push(db.get_settings().into());
|
||||
l.append(&mut db.list_workspaces()?.into_iter().map(Into::into).collect());
|
||||
l.append(&mut db.list_key_values()?.into_iter().map(Into::into).collect());
|
||||
}
|
||||
// Add the settings
|
||||
l.push(db.get_settings().into());
|
||||
|
||||
let plugins = {
|
||||
let db = window.db();
|
||||
db.list_plugins()?
|
||||
};
|
||||
|
||||
let plugins = plugin_manager.resolve_plugins_for_runtime_from_db(plugins).await;
|
||||
l.append(&mut plugins.into_iter().map(Into::into).collect());
|
||||
// Add global models
|
||||
l.append(&mut db.list_workspaces()?.into_iter().map(Into::into).collect());
|
||||
l.append(&mut db.list_key_values()?.into_iter().map(Into::into).collect());
|
||||
l.append(&mut db.list_plugins()?.into_iter().map(Into::into).collect());
|
||||
|
||||
// Add the workspace children
|
||||
if let Some(wid) = workspace_id {
|
||||
let db = window.db();
|
||||
l.append(&mut db.list_cookie_jars(wid)?.into_iter().map(Into::into).collect());
|
||||
l.append(&mut db.list_environments_ensure_base(wid)?.into_iter().map(Into::into).collect());
|
||||
l.append(&mut db.list_folders(wid)?.into_iter().map(Into::into).collect());
|
||||
|
||||
@@ -19,13 +19,13 @@ use yaak::plugin_events::{
|
||||
GroupedPluginEvent, HostRequest, SharedPluginEventContext, handle_shared_plugin_event,
|
||||
};
|
||||
use yaak_crypto::manager::EncryptionManager;
|
||||
use yaak_models::models::{HttpResponse, Plugin};
|
||||
use yaak_models::models::{AnyModel, HttpResponse, Plugin};
|
||||
use yaak_models::queries::any_request::AnyRequest;
|
||||
use yaak_models::util::UpdateSource;
|
||||
use yaak_plugins::error::Error::PluginErr;
|
||||
use yaak_plugins::events::{
|
||||
Color, EmptyPayload, ErrorResponse, GetCookieValueResponse, Icon, InternalEvent,
|
||||
InternalEventPayload, ListCookieNamesResponse, ListOpenWorkspacesResponse,
|
||||
Color, EmptyPayload, ErrorResponse, FindHttpResponsesResponse, GetCookieValueResponse, Icon,
|
||||
InternalEvent, InternalEventPayload, ListCookieNamesResponse, ListOpenWorkspacesResponse,
|
||||
RenderGrpcRequestResponse, RenderHttpRequestResponse, SendHttpRequestResponse,
|
||||
ShowToastRequest, TemplateRenderResponse, WindowInfoResponse, WindowNavigateEvent,
|
||||
WorkspaceInfo,
|
||||
@@ -190,6 +190,71 @@ async fn handle_host_plugin_request<R: Runtime>(
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
HostRequest::FindHttpResponses(req) => {
|
||||
let http_responses = app_handle
|
||||
.db()
|
||||
.list_http_responses_for_request(&req.request_id, req.limit.map(|l| l as u64))
|
||||
.unwrap_or_default();
|
||||
Ok(Some(InternalEventPayload::FindHttpResponsesResponse(FindHttpResponsesResponse {
|
||||
http_responses,
|
||||
})))
|
||||
}
|
||||
HostRequest::UpsertModel(req) => {
|
||||
use AnyModel::*;
|
||||
let model = match &req.model {
|
||||
HttpRequest(m) => {
|
||||
HttpRequest(app_handle.db().upsert_http_request(m, &UpdateSource::Plugin)?)
|
||||
}
|
||||
GrpcRequest(m) => {
|
||||
GrpcRequest(app_handle.db().upsert_grpc_request(m, &UpdateSource::Plugin)?)
|
||||
}
|
||||
WebsocketRequest(m) => WebsocketRequest(
|
||||
app_handle.db().upsert_websocket_request(m, &UpdateSource::Plugin)?,
|
||||
),
|
||||
Folder(m) => Folder(app_handle.db().upsert_folder(m, &UpdateSource::Plugin)?),
|
||||
Environment(m) => {
|
||||
Environment(app_handle.db().upsert_environment(m, &UpdateSource::Plugin)?)
|
||||
}
|
||||
Workspace(m) => {
|
||||
Workspace(app_handle.db().upsert_workspace(m, &UpdateSource::Plugin)?)
|
||||
}
|
||||
_ => {
|
||||
return Err(PluginErr("Upsert not supported for this model type".into()).into());
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Some(InternalEventPayload::UpsertModelResponse(
|
||||
yaak_plugins::events::UpsertModelResponse { model },
|
||||
)))
|
||||
}
|
||||
HostRequest::DeleteModel(req) => {
|
||||
let model = match req.model.as_str() {
|
||||
"http_request" => AnyModel::HttpRequest(
|
||||
app_handle.db().delete_http_request_by_id(&req.id, &UpdateSource::Plugin)?,
|
||||
),
|
||||
"grpc_request" => AnyModel::GrpcRequest(
|
||||
app_handle.db().delete_grpc_request_by_id(&req.id, &UpdateSource::Plugin)?,
|
||||
),
|
||||
"websocket_request" => AnyModel::WebsocketRequest(
|
||||
app_handle
|
||||
.db()
|
||||
.delete_websocket_request_by_id(&req.id, &UpdateSource::Plugin)?,
|
||||
),
|
||||
"folder" => AnyModel::Folder(
|
||||
app_handle.db().delete_folder_by_id(&req.id, &UpdateSource::Plugin)?,
|
||||
),
|
||||
"environment" => AnyModel::Environment(
|
||||
app_handle.db().delete_environment_by_id(&req.id, &UpdateSource::Plugin)?,
|
||||
),
|
||||
_ => {
|
||||
return Err(PluginErr("Delete not supported for this model type".into()).into());
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Some(InternalEventPayload::DeleteModelResponse(
|
||||
yaak_plugins::events::DeleteModelResponse { model },
|
||||
)))
|
||||
}
|
||||
HostRequest::RenderGrpcRequest(req) => {
|
||||
let window = get_window_from_plugin_context(app_handle, plugin_context)?;
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ use tauri::{
|
||||
use tokio::sync::Mutex;
|
||||
use ts_rs::TS;
|
||||
use yaak_api::yaak_api_client;
|
||||
use yaak_models::models::{Plugin, PluginSource};
|
||||
use yaak_models::util::UpdateSource;
|
||||
use yaak_models::models::Plugin;
|
||||
use yaak_plugins::api::{
|
||||
PluginNameVersion, PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates,
|
||||
search_plugins,
|
||||
@@ -165,28 +164,6 @@ pub async fn cmd_plugins_install<R: Runtime>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub async fn cmd_plugins_install_from_directory<R: Runtime>(
|
||||
window: WebviewWindow<R>,
|
||||
directory: &str,
|
||||
) -> Result<Plugin> {
|
||||
let plugin = window.db().upsert_plugin(
|
||||
&Plugin {
|
||||
directory: directory.into(),
|
||||
url: None,
|
||||
enabled: true,
|
||||
source: PluginSource::Filesystem,
|
||||
..Default::default()
|
||||
},
|
||||
&UpdateSource::from_window_label(window.label()),
|
||||
)?;
|
||||
|
||||
let plugin_manager = Arc::new((*window.state::<PluginManager>()).clone());
|
||||
plugin_manager.add_plugin(&window.plugin_context(), &plugin).await?;
|
||||
|
||||
Ok(plugin)
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub async fn cmd_plugins_uninstall<R: Runtime>(
|
||||
plugin_id: &str,
|
||||
|
||||
4
crates/yaak-models/bindings/gen_models.ts
generated
4
crates/yaak-models/bindings/gen_models.ts
generated
@@ -67,9 +67,7 @@ export type ParentAuthentication = { authentication: Record<string, any>, authen
|
||||
|
||||
export type ParentHeaders = { headers: Array<HttpRequestHeader>, };
|
||||
|
||||
export type Plugin = { model: "plugin", id: string, createdAt: string, updatedAt: string, checkedAt: string | null, directory: string, enabled: boolean, url: string | null, source: PluginSource, };
|
||||
|
||||
export type PluginSource = "bundled" | "filesystem" | "registry";
|
||||
export type Plugin = { model: "plugin", id: string, createdAt: string, updatedAt: string, checkedAt: string | null, directory: string, enabled: boolean, url: string | null, };
|
||||
|
||||
export type PluginKeyValue = { model: "plugin_key_value", createdAt: string, updatedAt: string, pluginName: string, key: string, value: string, };
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
ALTER TABLE plugins
|
||||
ADD COLUMN source TEXT DEFAULT 'filesystem' NOT NULL;
|
||||
|
||||
-- Existing registry installs have a URL; classify them first.
|
||||
UPDATE plugins
|
||||
SET source = 'registry'
|
||||
WHERE url IS NOT NULL;
|
||||
|
||||
-- Best-effort bundled backfill for legacy rows.
|
||||
UPDATE plugins
|
||||
SET source = 'bundled'
|
||||
WHERE source = 'filesystem'
|
||||
AND (
|
||||
-- Normalize separators so this also works for Windows paths.
|
||||
replace(directory, '\', '/') LIKE '%/vendored/plugins/%'
|
||||
OR replace(directory, '\', '/') LIKE '%/vendored-plugins/%'
|
||||
);
|
||||
|
||||
-- Keep one row per exact directory before adding uniqueness.
|
||||
-- Tie-break by recency.
|
||||
WITH ranked AS (SELECT id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY directory
|
||||
ORDER BY updated_at DESC,
|
||||
created_at DESC
|
||||
) AS row_num
|
||||
FROM plugins)
|
||||
DELETE
|
||||
FROM plugins
|
||||
WHERE id IN (SELECT id FROM ranked WHERE row_num > 1);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_plugins_directory_unique
|
||||
ON plugins (directory);
|
||||
@@ -2074,46 +2074,6 @@ pub struct Plugin {
|
||||
pub directory: String,
|
||||
pub enabled: bool,
|
||||
pub url: Option<String>,
|
||||
pub source: PluginSource,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "gen_models.ts")]
|
||||
pub enum PluginSource {
|
||||
Bundled,
|
||||
Filesystem,
|
||||
Registry,
|
||||
}
|
||||
|
||||
impl FromStr for PluginSource {
|
||||
type Err = crate::error::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
match s {
|
||||
"bundled" => Ok(Self::Bundled),
|
||||
"filesystem" => Ok(Self::Filesystem),
|
||||
"registry" => Ok(Self::Registry),
|
||||
_ => Ok(Self::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PluginSource {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let str = match self {
|
||||
PluginSource::Bundled => "bundled".to_string(),
|
||||
PluginSource::Filesystem => "filesystem".to_string(),
|
||||
PluginSource::Registry => "registry".to_string(),
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PluginSource {
|
||||
fn default() -> Self {
|
||||
Self::Filesystem
|
||||
}
|
||||
}
|
||||
|
||||
impl UpsertModelInfo for Plugin {
|
||||
@@ -2149,7 +2109,6 @@ impl UpsertModelInfo for Plugin {
|
||||
(Directory, self.directory.into()),
|
||||
(Url, self.url.into()),
|
||||
(Enabled, self.enabled.into()),
|
||||
(Source, self.source.to_string().into()),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -2160,7 +2119,6 @@ impl UpsertModelInfo for Plugin {
|
||||
PluginIden::Directory,
|
||||
PluginIden::Url,
|
||||
PluginIden::Enabled,
|
||||
PluginIden::Source,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2177,7 +2135,6 @@ impl UpsertModelInfo for Plugin {
|
||||
url: row.get("url")?,
|
||||
directory: row.get("directory")?,
|
||||
enabled: row.get("enabled")?,
|
||||
source: PluginSource::from_str(row.get::<_, String>("source")?.as_str()).unwrap(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ impl<'a> DbContext<'a> {
|
||||
}
|
||||
|
||||
pub fn upsert_plugin(&self, plugin: &Plugin, source: &UpdateSource) -> Result<Plugin> {
|
||||
let mut plugin_to_upsert = plugin.clone();
|
||||
if let Some(existing) = self.get_plugin_by_directory(&plugin.directory) {
|
||||
plugin_to_upsert.id = existing.id;
|
||||
}
|
||||
self.upsert(&plugin_to_upsert, source)
|
||||
self.upsert(plugin, source)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,3 @@ export async function checkPluginUpdates() {
|
||||
export async function updateAllPlugins() {
|
||||
return invoke<PluginNameVersion[]>('cmd_plugins_update_all', {});
|
||||
}
|
||||
|
||||
export async function installPluginFromDirectory(directory: string) {
|
||||
return invoke<void>('cmd_plugins_install_from_directory', { directory });
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use ts_rs::TS;
|
||||
use yaak_models::models::{Plugin, PluginSource};
|
||||
use yaak_models::models::Plugin;
|
||||
|
||||
/// Get plugin info from the registry.
|
||||
pub async fn get_plugin(
|
||||
@@ -58,7 +58,7 @@ pub async fn check_plugin_updates(
|
||||
) -> Result<PluginUpdatesResponse> {
|
||||
let name_versions: Vec<PluginNameVersion> = plugins
|
||||
.into_iter()
|
||||
.filter(|p| matches!(p.source, PluginSource::Registry)) // Only check registry-installed plugins
|
||||
.filter(|p| p.url.is_some()) // Only check plugins with URLs (from registry)
|
||||
.filter_map(|p| match get_plugin_meta(&Path::new(&p.directory)) {
|
||||
Ok(m) => Some(PluginNameVersion { name: m.name, version: m.version }),
|
||||
Err(e) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ use log::info;
|
||||
use std::fs::{create_dir_all, remove_dir_all};
|
||||
use std::io::Cursor;
|
||||
use std::sync::Arc;
|
||||
use yaak_models::models::{Plugin, PluginSource};
|
||||
use yaak_models::models::Plugin;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::UpdateSource;
|
||||
|
||||
@@ -78,7 +78,6 @@ pub async fn download_and_install(
|
||||
directory: plugin_dir_str.clone(),
|
||||
enabled: true,
|
||||
url: Some(plugin_version.url.clone()),
|
||||
source: PluginSource::Registry,
|
||||
..Default::default()
|
||||
},
|
||||
&UpdateSource::Background,
|
||||
|
||||
@@ -21,10 +21,9 @@ use crate::events::{
|
||||
use crate::native_template_functions::{template_function_keyring, template_function_secure};
|
||||
use crate::nodejs::start_nodejs_plugin_runtime;
|
||||
use crate::plugin_handle::PluginHandle;
|
||||
use crate::plugin_meta::get_plugin_meta;
|
||||
use crate::server_ws::PluginRuntimeServerWebsocket;
|
||||
use log::{error, info, warn};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
@@ -34,7 +33,7 @@ use tokio::net::TcpListener;
|
||||
use tokio::sync::mpsc::error::TrySendError;
|
||||
use tokio::sync::{Mutex, mpsc, oneshot};
|
||||
use tokio::time::{Instant, timeout};
|
||||
use yaak_models::models::{Plugin, PluginSource};
|
||||
use yaak_models::models::Plugin;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::{UpdateSource, generate_id};
|
||||
use yaak_templates::error::Error::RenderError;
|
||||
@@ -163,14 +162,13 @@ impl PluginManager {
|
||||
|
||||
let bundled_dirs = plugin_manager.list_bundled_plugin_dirs().await?;
|
||||
let db = query_manager.connect();
|
||||
for dir in &bundled_dirs {
|
||||
if db.get_plugin_by_directory(dir).is_none() {
|
||||
for dir in bundled_dirs {
|
||||
if db.get_plugin_by_directory(&dir).is_none() {
|
||||
db.upsert_plugin(
|
||||
&Plugin {
|
||||
directory: dir.clone(),
|
||||
directory: dir,
|
||||
enabled: true,
|
||||
url: None,
|
||||
source: PluginSource::Bundled,
|
||||
..Default::default()
|
||||
},
|
||||
&UpdateSource::Background,
|
||||
@@ -215,57 +213,6 @@ impl PluginManager {
|
||||
read_plugins_dir(&plugins_dir).await
|
||||
}
|
||||
|
||||
pub async fn resolve_plugins_for_runtime_from_db(&self, plugins: Vec<Plugin>) -> Vec<Plugin> {
|
||||
let bundled_dirs = match self.list_bundled_plugin_dirs().await {
|
||||
Ok(dirs) => dirs,
|
||||
Err(err) => {
|
||||
warn!("Failed to read bundled plugin dirs for resolution: {err:?}");
|
||||
Vec::new()
|
||||
}
|
||||
};
|
||||
self.resolve_plugins_for_runtime(plugins, bundled_dirs)
|
||||
}
|
||||
|
||||
/// Resolve the plugin set for the current runtime instance.
|
||||
///
|
||||
/// Rules:
|
||||
/// - Drop bundled rows that are not present in this instance's bundled directory list.
|
||||
/// - Deduplicate by plugin metadata name (fallback to directory key when metadata is unreadable).
|
||||
/// - Prefer sources in this order: filesystem > registry > bundled.
|
||||
/// - For same-source conflicts, prefer the most recently installed row (`created_at`).
|
||||
fn resolve_plugins_for_runtime(
|
||||
&self,
|
||||
plugins: Vec<Plugin>,
|
||||
bundled_dirs: Vec<String>,
|
||||
) -> Vec<Plugin> {
|
||||
let bundled_dir_set: HashSet<String> = bundled_dirs.into_iter().collect();
|
||||
let mut selected: HashMap<String, Plugin> = HashMap::new();
|
||||
|
||||
for plugin in plugins {
|
||||
if matches!(plugin.source, PluginSource::Bundled)
|
||||
&& !bundled_dir_set.contains(&plugin.directory)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let key = match get_plugin_meta(Path::new(&plugin.directory)) {
|
||||
Ok(meta) => meta.name,
|
||||
Err(_) => format!("__dir__{}", plugin.directory),
|
||||
};
|
||||
|
||||
match selected.get(&key) {
|
||||
Some(existing) if !prefer_plugin(&plugin, existing) => {}
|
||||
_ => {
|
||||
selected.insert(key, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut resolved = selected.into_values().collect::<Vec<_>>();
|
||||
resolved.sort_by(|a, b| b.created_at.cmp(&a.created_at));
|
||||
resolved
|
||||
}
|
||||
|
||||
pub async fn uninstall(&self, plugin_context: &PluginContext, dir: &str) -> Result<()> {
|
||||
let plugin = self.get_plugin_by_dir(dir).await.ok_or(PluginNotFoundErr(dir.to_string()))?;
|
||||
self.remove_plugin(plugin_context, &plugin).await
|
||||
@@ -340,8 +287,7 @@ impl PluginManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Initialize all plugins from the provided DB list.
|
||||
/// Plugin candidates are resolved for this runtime instance before initialization.
|
||||
/// Initialize all plugins from the provided list.
|
||||
/// Returns a list of (plugin_directory, error_message) for any plugins that failed to initialize.
|
||||
pub async fn initialize_all_plugins(
|
||||
&self,
|
||||
@@ -351,18 +297,15 @@ impl PluginManager {
|
||||
info!("Initializing all plugins");
|
||||
let start = Instant::now();
|
||||
let mut errors = Vec::new();
|
||||
let plugins = self.resolve_plugins_for_runtime_from_db(plugins).await;
|
||||
|
||||
// Rebuild runtime handles from scratch to avoid stale/duplicate handles.
|
||||
let existing_handles = { self.plugin_handles.lock().await.clone() };
|
||||
for plugin_handle in existing_handles {
|
||||
if let Err(e) = self.remove_plugin(plugin_context, &plugin_handle).await {
|
||||
error!("Failed to remove plugin {} {e:?}", plugin_handle.dir);
|
||||
errors.push((plugin_handle.dir.clone(), e.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
for plugin in plugins {
|
||||
// First remove the plugin if it exists and is enabled
|
||||
if let Some(plugin_handle) = self.get_plugin_by_dir(&plugin.directory).await {
|
||||
if let Err(e) = self.remove_plugin(plugin_context, &plugin_handle).await {
|
||||
error!("Failed to remove plugin {} {e:?}", plugin.directory);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Err(e) = self.add_plugin(plugin_context, &plugin).await {
|
||||
warn!("Failed to add plugin {} {e:?}", plugin.directory);
|
||||
errors.push((plugin.directory.clone(), e.to_string()));
|
||||
@@ -1120,24 +1063,6 @@ impl PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
fn source_priority(source: &PluginSource) -> i32 {
|
||||
match source {
|
||||
PluginSource::Filesystem => 3,
|
||||
PluginSource::Registry => 2,
|
||||
PluginSource::Bundled => 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn prefer_plugin(candidate: &Plugin, existing: &Plugin) -> bool {
|
||||
let candidate_priority = source_priority(&candidate.source);
|
||||
let existing_priority = source_priority(&existing.source);
|
||||
if candidate_priority != existing_priority {
|
||||
return candidate_priority > existing_priority;
|
||||
}
|
||||
|
||||
candidate.created_at > existing.created_at
|
||||
}
|
||||
|
||||
async fn read_plugins_dir(dir: &PathBuf) -> Result<Vec<String>> {
|
||||
let mut result = read_dir(dir).await?;
|
||||
let mut dirs: Vec<String> = vec![];
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
use yaak_models::models::AnyModel;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::UpdateSource;
|
||||
use yaak_plugins::events::{
|
||||
CloseWindowRequest, CopyTextRequest, DeleteKeyValueRequest, DeleteKeyValueResponse,
|
||||
DeleteModelRequest, DeleteModelResponse, ErrorResponse, FindHttpResponsesRequest,
|
||||
FindHttpResponsesResponse, GetCookieValueRequest, GetHttpRequestByIdRequest,
|
||||
GetHttpRequestByIdResponse, GetKeyValueRequest, GetKeyValueResponse, InternalEventPayload,
|
||||
ListCookieNamesRequest, ListFoldersRequest, ListFoldersResponse, ListHttpRequestsRequest,
|
||||
ListHttpRequestsResponse, ListOpenWorkspacesRequest, OpenExternalUrlRequest, OpenWindowRequest,
|
||||
PromptFormRequest, PromptTextRequest, ReloadResponse, RenderGrpcRequestRequest,
|
||||
RenderHttpRequestRequest, SendHttpRequestRequest, SetKeyValueRequest, ShowToastRequest,
|
||||
TemplateRenderRequest, UpsertModelRequest, UpsertModelResponse, WindowInfoRequest,
|
||||
DeleteModelRequest, ErrorResponse, FindHttpResponsesRequest, GetCookieValueRequest,
|
||||
GetHttpRequestByIdRequest, GetHttpRequestByIdResponse, GetKeyValueRequest, GetKeyValueResponse,
|
||||
InternalEventPayload, ListCookieNamesRequest, ListFoldersRequest, ListFoldersResponse,
|
||||
ListHttpRequestsRequest, ListHttpRequestsResponse, ListOpenWorkspacesRequest,
|
||||
OpenExternalUrlRequest, OpenWindowRequest, PromptFormRequest, PromptTextRequest,
|
||||
ReloadResponse, RenderGrpcRequestRequest, RenderHttpRequestRequest, SendHttpRequestRequest,
|
||||
SetKeyValueRequest, ShowToastRequest, TemplateRenderRequest, UpsertModelRequest,
|
||||
WindowInfoRequest,
|
||||
};
|
||||
|
||||
pub struct SharedPluginEventContext<'a> {
|
||||
@@ -39,9 +37,6 @@ pub enum SharedRequest<'a> {
|
||||
GetHttpRequestById(&'a GetHttpRequestByIdRequest),
|
||||
ListFolders(&'a ListFoldersRequest),
|
||||
ListHttpRequests(&'a ListHttpRequestsRequest),
|
||||
FindHttpResponses(&'a FindHttpResponsesRequest),
|
||||
UpsertModel(&'a UpsertModelRequest),
|
||||
DeleteModel(&'a DeleteModelRequest),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -50,6 +45,9 @@ pub enum HostRequest<'a> {
|
||||
CopyText(&'a CopyTextRequest),
|
||||
PromptText(&'a PromptTextRequest),
|
||||
PromptForm(&'a PromptFormRequest),
|
||||
FindHttpResponses(&'a FindHttpResponsesRequest),
|
||||
UpsertModel(&'a UpsertModelRequest),
|
||||
DeleteModel(&'a DeleteModelRequest),
|
||||
RenderGrpcRequest(&'a RenderGrpcRequestRequest),
|
||||
RenderHttpRequest(&'a RenderHttpRequestRequest),
|
||||
TemplateRender(&'a TemplateRenderRequest),
|
||||
@@ -73,6 +71,9 @@ impl HostRequest<'_> {
|
||||
HostRequest::CopyText(_) => "copy_text_request".to_string(),
|
||||
HostRequest::PromptText(_) => "prompt_text_request".to_string(),
|
||||
HostRequest::PromptForm(_) => "prompt_form_request".to_string(),
|
||||
HostRequest::FindHttpResponses(_) => "find_http_responses_request".to_string(),
|
||||
HostRequest::UpsertModel(_) => "upsert_model_request".to_string(),
|
||||
HostRequest::DeleteModel(_) => "delete_model_request".to_string(),
|
||||
HostRequest::RenderGrpcRequest(_) => "render_grpc_request_request".to_string(),
|
||||
HostRequest::RenderHttpRequest(_) => "render_http_request_request".to_string(),
|
||||
HostRequest::TemplateRender(_) => "template_render_request".to_string(),
|
||||
@@ -134,13 +135,13 @@ impl<'a> From<&'a InternalEventPayload> for GroupedPluginRequest<'a> {
|
||||
GroupedPluginRequest::Host(HostRequest::PromptForm(req))
|
||||
}
|
||||
InternalEventPayload::FindHttpResponsesRequest(req) => {
|
||||
GroupedPluginRequest::Shared(SharedRequest::FindHttpResponses(req))
|
||||
GroupedPluginRequest::Host(HostRequest::FindHttpResponses(req))
|
||||
}
|
||||
InternalEventPayload::UpsertModelRequest(req) => {
|
||||
GroupedPluginRequest::Shared(SharedRequest::UpsertModel(req))
|
||||
GroupedPluginRequest::Host(HostRequest::UpsertModel(req))
|
||||
}
|
||||
InternalEventPayload::DeleteModelRequest(req) => {
|
||||
GroupedPluginRequest::Shared(SharedRequest::DeleteModel(req))
|
||||
GroupedPluginRequest::Host(HostRequest::DeleteModel(req))
|
||||
}
|
||||
InternalEventPayload::RenderGrpcRequestRequest(req) => {
|
||||
GroupedPluginRequest::Host(HostRequest::RenderGrpcRequest(req))
|
||||
@@ -274,175 +275,17 @@ fn build_shared_reply(
|
||||
http_requests,
|
||||
})
|
||||
}
|
||||
SharedRequest::FindHttpResponses(req) => {
|
||||
let http_responses = query_manager
|
||||
.connect()
|
||||
.list_http_responses_for_request(&req.request_id, req.limit.map(|l| l as u64))
|
||||
.unwrap_or_default();
|
||||
InternalEventPayload::FindHttpResponsesResponse(FindHttpResponsesResponse {
|
||||
http_responses,
|
||||
})
|
||||
}
|
||||
SharedRequest::UpsertModel(req) => {
|
||||
use AnyModel::*;
|
||||
|
||||
let model = match &req.model {
|
||||
HttpRequest(m) => {
|
||||
match query_manager.connect().upsert_http_request(m, &UpdateSource::Plugin) {
|
||||
Ok(model) => HttpRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert HTTP request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
GrpcRequest(m) => {
|
||||
match query_manager.connect().upsert_grpc_request(m, &UpdateSource::Plugin) {
|
||||
Ok(model) => GrpcRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert gRPC request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
WebsocketRequest(m) => {
|
||||
match query_manager.connect().upsert_websocket_request(m, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => WebsocketRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert WebSocket request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Folder(m) => {
|
||||
match query_manager.connect().upsert_folder(m, &UpdateSource::Plugin) {
|
||||
Ok(model) => Folder(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert folder: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Environment(m) => {
|
||||
match query_manager.connect().upsert_environment(m, &UpdateSource::Plugin) {
|
||||
Ok(model) => Environment(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert environment: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Workspace(m) => {
|
||||
match query_manager.connect().upsert_workspace(m, &UpdateSource::Plugin) {
|
||||
Ok(model) => Workspace(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to upsert workspace: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: "Upsert not supported for this model type".to_string(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
InternalEventPayload::UpsertModelResponse(UpsertModelResponse { model })
|
||||
}
|
||||
SharedRequest::DeleteModel(req) => {
|
||||
let model = match req.model.as_str() {
|
||||
"http_request" => {
|
||||
match query_manager
|
||||
.connect()
|
||||
.delete_http_request_by_id(&req.id, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => AnyModel::HttpRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to delete HTTP request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
"grpc_request" => {
|
||||
match query_manager
|
||||
.connect()
|
||||
.delete_grpc_request_by_id(&req.id, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => AnyModel::GrpcRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to delete gRPC request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
"websocket_request" => {
|
||||
match query_manager
|
||||
.connect()
|
||||
.delete_websocket_request_by_id(&req.id, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => AnyModel::WebsocketRequest(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to delete WebSocket request: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
"folder" => match query_manager
|
||||
.connect()
|
||||
.delete_folder_by_id(&req.id, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => AnyModel::Folder(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to delete folder: {err}"),
|
||||
});
|
||||
}
|
||||
},
|
||||
"environment" => {
|
||||
match query_manager
|
||||
.connect()
|
||||
.delete_environment_by_id(&req.id, &UpdateSource::Plugin)
|
||||
{
|
||||
Ok(model) => AnyModel::Environment(model),
|
||||
Err(err) => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: format!("Failed to delete environment: {err}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return InternalEventPayload::ErrorResponse(ErrorResponse {
|
||||
error: "Delete not supported for this model type".to_string(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
InternalEventPayload::DeleteModelResponse(DeleteModelResponse { model })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use tempfile::TempDir;
|
||||
use yaak_models::models::{AnyModel, Folder, HttpRequest, Workspace};
|
||||
use yaak_models::models::{Folder, HttpRequest, Workspace};
|
||||
use yaak_models::util::UpdateSource;
|
||||
|
||||
fn seed_query_manager() -> (QueryManager, TempDir) {
|
||||
let temp_dir = TempDir::new().expect("Failed to create temp dir");
|
||||
fn seed_query_manager() -> QueryManager {
|
||||
let temp_dir = tempfile::TempDir::new().expect("Failed to create temp dir");
|
||||
let db_path = temp_dir.path().join("db.sqlite");
|
||||
let blob_path = temp_dir.path().join("blobs.sqlite");
|
||||
let (query_manager, _blob_manager, _rx) =
|
||||
@@ -489,12 +332,12 @@ mod tests {
|
||||
)
|
||||
.expect("Failed to seed request");
|
||||
|
||||
(query_manager, temp_dir)
|
||||
query_manager
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_requests_requires_workspace_when_folder_missing() {
|
||||
let (query_manager, _temp_dir) = seed_query_manager();
|
||||
let query_manager = seed_query_manager();
|
||||
let payload = InternalEventPayload::ListHttpRequestsRequest(
|
||||
yaak_plugins::events::ListHttpRequestsRequest { folder_id: None },
|
||||
);
|
||||
@@ -512,7 +355,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn list_requests_by_workspace_and_folder() {
|
||||
let (query_manager, _temp_dir) = seed_query_manager();
|
||||
let query_manager = seed_query_manager();
|
||||
|
||||
let by_workspace_payload = InternalEventPayload::ListHttpRequestsRequest(
|
||||
yaak_plugins::events::ListHttpRequestsRequest { folder_id: None },
|
||||
@@ -551,83 +394,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_http_responses_is_shared_handled() {
|
||||
let (query_manager, _temp_dir) = seed_query_manager();
|
||||
let payload = InternalEventPayload::FindHttpResponsesRequest(FindHttpResponsesRequest {
|
||||
request_id: "rq_test".to_string(),
|
||||
limit: Some(1),
|
||||
});
|
||||
|
||||
let result = handle_shared_plugin_event(
|
||||
&query_manager,
|
||||
&payload,
|
||||
SharedPluginEventContext { plugin_name: "@yaak/test", workspace_id: Some("wk_test") },
|
||||
);
|
||||
|
||||
match result {
|
||||
GroupedPluginEvent::Handled(Some(InternalEventPayload::FindHttpResponsesResponse(
|
||||
resp,
|
||||
))) => {
|
||||
assert!(resp.http_responses.is_empty());
|
||||
}
|
||||
other => panic!("unexpected find responses result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upsert_and_delete_model_are_shared_handled() {
|
||||
let (query_manager, _temp_dir) = seed_query_manager();
|
||||
|
||||
let existing = query_manager
|
||||
.connect()
|
||||
.get_http_request("rq_test")
|
||||
.expect("Failed to load seeded request");
|
||||
let upsert_payload = InternalEventPayload::UpsertModelRequest(UpsertModelRequest {
|
||||
model: AnyModel::HttpRequest(HttpRequest {
|
||||
name: "Request Updated".to_string(),
|
||||
..existing
|
||||
}),
|
||||
});
|
||||
|
||||
let upsert_result = handle_shared_plugin_event(
|
||||
&query_manager,
|
||||
&upsert_payload,
|
||||
SharedPluginEventContext { plugin_name: "@yaak/test", workspace_id: Some("wk_test") },
|
||||
);
|
||||
match upsert_result {
|
||||
GroupedPluginEvent::Handled(Some(InternalEventPayload::UpsertModelResponse(resp))) => {
|
||||
match resp.model {
|
||||
AnyModel::HttpRequest(r) => assert_eq!(r.name, "Request Updated"),
|
||||
other => panic!("unexpected upsert model type: {other:?}"),
|
||||
}
|
||||
}
|
||||
other => panic!("unexpected upsert result: {other:?}"),
|
||||
}
|
||||
|
||||
let delete_payload = InternalEventPayload::DeleteModelRequest(DeleteModelRequest {
|
||||
model: "http_request".to_string(),
|
||||
id: "rq_test".to_string(),
|
||||
});
|
||||
let delete_result = handle_shared_plugin_event(
|
||||
&query_manager,
|
||||
&delete_payload,
|
||||
SharedPluginEventContext { plugin_name: "@yaak/test", workspace_id: Some("wk_test") },
|
||||
);
|
||||
match delete_result {
|
||||
GroupedPluginEvent::Handled(Some(InternalEventPayload::DeleteModelResponse(resp))) => {
|
||||
match resp.model {
|
||||
AnyModel::HttpRequest(r) => assert_eq!(r.id, "rq_test"),
|
||||
other => panic!("unexpected delete model type: {other:?}"),
|
||||
}
|
||||
}
|
||||
other => panic!("unexpected delete result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_request_classification_works() {
|
||||
let (query_manager, _temp_dir) = seed_query_manager();
|
||||
let query_manager = seed_query_manager();
|
||||
let payload = InternalEventPayload::WindowInfoRequest(WindowInfoRequest {
|
||||
label: "main".to_string(),
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{
|
||||
"name": "@yaak/template-function-timestamp",
|
||||
"displayName": "Timestamp Template Functions",
|
||||
"description": "Template functions for dealing with timestamps",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useDebouncedValue } from '../../hooks/useDebouncedValue';
|
||||
import { useInstallPlugin } from '../../hooks/useInstallPlugin';
|
||||
import { usePluginInfo } from '../../hooks/usePluginInfo';
|
||||
import { usePluginsKey, useRefreshPlugins } from '../../hooks/usePlugins';
|
||||
import { appInfo } from '../../lib/appInfo';
|
||||
import { showConfirmDelete } from '../../lib/confirm';
|
||||
import { minPromiseMillis } from '../../lib/minPromiseMillis';
|
||||
import { Button } from '../core/Button';
|
||||
@@ -32,6 +33,16 @@ import { TabContent, Tabs } from '../core/Tabs/Tabs';
|
||||
import { EmptyStateText } from '../EmptyStateText';
|
||||
import { SelectFile } from '../SelectFile';
|
||||
|
||||
function isPluginBundled(plugin: Plugin, vendoredPluginDir: string): boolean {
|
||||
const normalizedDir = plugin.directory.replace(/\\/g, '/');
|
||||
const normalizedVendoredDir = vendoredPluginDir.replace(/\\/g, '/');
|
||||
return (
|
||||
normalizedDir.includes(normalizedVendoredDir) ||
|
||||
normalizedDir.includes('vendored/plugins') ||
|
||||
normalizedDir.includes('/plugins/')
|
||||
);
|
||||
}
|
||||
|
||||
interface SettingsPluginsProps {
|
||||
defaultSubtab?: string;
|
||||
}
|
||||
@@ -39,8 +50,8 @@ interface SettingsPluginsProps {
|
||||
export function SettingsPlugins({ defaultSubtab }: SettingsPluginsProps) {
|
||||
const [directory, setDirectory] = useState<string | null>(null);
|
||||
const plugins = useAtomValue(pluginsAtom);
|
||||
const bundledPlugins = plugins.filter((p) => p.source === 'bundled');
|
||||
const installedPlugins = plugins.filter((p) => p.source !== 'bundled');
|
||||
const bundledPlugins = plugins.filter((p) => isPluginBundled(p, appInfo.vendoredPluginDir));
|
||||
const installedPlugins = plugins.filter((p) => !isPluginBundled(p, appInfo.vendoredPluginDir));
|
||||
const createPlugin = useInstallPlugin();
|
||||
const refreshPlugins = useRefreshPlugins();
|
||||
return (
|
||||
|
||||
@@ -896,9 +896,9 @@ function MenuItem({
|
||||
};
|
||||
|
||||
const rightSlot = item.submenu ? (
|
||||
<Icon icon="chevron_right" color="secondary" />
|
||||
<Icon icon="chevron_right" color='secondary' />
|
||||
) : (
|
||||
(item.rightSlot ?? <Hotkey variant="text" action={item.hotKeyAction ?? null} />)
|
||||
(item.rightSlot ?? <Hotkey action={item.hotKeyAction ?? null} />)
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -937,7 +937,7 @@ function MenuItem({
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div className={classNames('truncate min-w-[5rem]')}>{item.label}</div>
|
||||
<div className={classNames('truncate')}>{item.label}</div>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { installPluginFromDirectory } from '@yaakapp-internal/plugins';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useFastMutation } from './useFastMutation';
|
||||
|
||||
export function useInstallPlugin() {
|
||||
return useFastMutation<void, unknown, string>({
|
||||
mutationKey: ['install_plugin'],
|
||||
mutationFn: async (directory: string) => {
|
||||
await installPluginFromDirectory(directory);
|
||||
await invokeCmd('cmd_install_plugin', { directory });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ type TauriCmd =
|
||||
| 'cmd_http_request_body'
|
||||
| 'cmd_http_response_body'
|
||||
| 'cmd_import_data'
|
||||
| 'cmd_install_plugin'
|
||||
| 'cmd_metadata'
|
||||
| 'cmd_restart'
|
||||
| 'cmd_new_child_window'
|
||||
|
||||
Reference in New Issue
Block a user