From a1b1eafd39d714599b4b54eb0cea6f5dd75d7188 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 23 Jun 2025 09:46:54 -0700 Subject: [PATCH] Add links to plugins --- src-tauri/yaak-plugins/bindings/gen_search.ts | 2 +- src-tauri/yaak-plugins/src/api.rs | 3 ++- src-tauri/yaak-plugins/src/install.rs | 2 +- src-web/components/Settings/SettingsPlugins.tsx | 17 +++++++++++++++-- src-web/components/core/Link.tsx | 13 +++++++++---- src-web/hooks/useUninstallPlugin.tsx | 1 + 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src-tauri/yaak-plugins/bindings/gen_search.ts b/src-tauri/yaak-plugins/bindings/gen_search.ts index 9dbe0103..dd3c1ad7 100644 --- a/src-tauri/yaak-plugins/bindings/gen_search.ts +++ b/src-tauri/yaak-plugins/bindings/gen_search.ts @@ -2,4 +2,4 @@ export type PluginMetadata = { version: string, name: string, displayName: string, description: string | null, homepageUrl: string | null, repositoryUrl: string | null, }; -export type PluginVersion = { id: string, version: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, }; +export type PluginVersion = { id: string, version: string, url: string, description: string | null, name: string, displayName: string, homepageUrl: string | null, repositoryUrl: string | null, checksum: string, readme: string | null, yanked: boolean, }; diff --git a/src-tauri/yaak-plugins/src/api.rs b/src-tauri/yaak-plugins/src/api.rs index ba64d258..b9d5a4fc 100644 --- a/src-tauri/yaak-plugins/src/api.rs +++ b/src-tauri/yaak-plugins/src/api.rs @@ -1,3 +1,4 @@ +use crate::error::Error::ApiErr; use crate::error::Result; use crate::plugin_meta::get_plugin_meta; use log::{info, warn}; @@ -9,7 +10,6 @@ use tauri::{AppHandle, Runtime, is_dev}; use ts_rs::TS; use yaak_common::api_client::yaak_api_client; use yaak_models::query_manager::QueryManagerExt; -use crate::error::Error::ApiErr; pub async fn get_plugin( app_handle: &AppHandle, @@ -108,6 +108,7 @@ fn base_url(path: &str) -> Url { pub struct PluginVersion { pub id: String, pub version: String, + pub url: String, pub description: Option, pub name: String, pub display_name: String, diff --git a/src-tauri/yaak-plugins/src/install.rs b/src-tauri/yaak-plugins/src/install.rs index 105e9a08..9cc691f6 100644 --- a/src-tauri/yaak-plugins/src/install.rs +++ b/src-tauri/yaak-plugins/src/install.rs @@ -52,7 +52,7 @@ pub async fn download_and_install( checked_at: Some(Utc::now().naive_utc()), directory: plugin_dir_str.clone(), enabled: true, - url: None, + url: Some(plugin_version.url.clone()), ..Default::default() }, &UpdateSource::Background, diff --git a/src-web/components/Settings/SettingsPlugins.tsx b/src-web/components/Settings/SettingsPlugins.tsx index 37b0d4be..ac19f90d 100644 --- a/src-web/components/Settings/SettingsPlugins.tsx +++ b/src-web/components/Settings/SettingsPlugins.tsx @@ -18,6 +18,7 @@ import { useUninstallPlugin } from '../../hooks/useUninstallPlugin'; import { Button } from '../core/Button'; import { IconButton } from '../core/IconButton'; import { InlineCode } from '../core/InlineCode'; +import { Link } from '../core/Link'; import { LoadingIcon } from '../core/LoadingIcon'; import { PlainInput } from '../core/PlainInput'; import { HStack } from '../core/Stacks'; @@ -115,7 +116,15 @@ function PluginTableRow({ return ( - {pluginInfo.data.displayName} + + {plugin.url ? ( + + {pluginInfo.data.displayName} + + ) : ( + pluginInfo.data.displayName + )} + {pluginInfo.data?.version} @@ -187,7 +196,11 @@ function PluginSearch() { {results.data.plugins.map((plugin) => ( - {plugin.displayName} + + + {plugin.displayName} + + {plugin.version} diff --git a/src-web/components/core/Link.tsx b/src-web/components/core/Link.tsx index 7dbd3d1e..82b8774f 100644 --- a/src-web/components/core/Link.tsx +++ b/src-web/components/core/Link.tsx @@ -6,12 +6,13 @@ import { Icon } from './Icon'; interface Props extends HTMLAttributes { href: string; + noUnderline?: boolean; } -export function Link({ href, children, className, ...other }: Props) { +export function Link({ href, children, noUnderline, className, ...other }: Props) { const isExternal = href.match(/^https?:\/\//); - className = classNames(className, 'relative underline hover:text-violet-600'); + className = classNames(className, 'relative'); if (isExternal) { let finalHref = href; @@ -25,13 +26,17 @@ export function Link({ href, children, className, ...other }: Props) { href={finalHref} target="_blank" rel="noopener noreferrer" - className={classNames(className, 'pr-4 inline-flex items-center')} + className={classNames( + className, + 'pr-4 inline-flex items-center hover:underline', + !noUnderline && 'underline', + )} onClick={(e) => { e.preventDefault(); }} {...other} > - {children} + {children} ); diff --git a/src-web/hooks/useUninstallPlugin.tsx b/src-web/hooks/useUninstallPlugin.tsx index ebbbc9aa..038c541e 100644 --- a/src-web/hooks/useUninstallPlugin.tsx +++ b/src-web/hooks/useUninstallPlugin.tsx @@ -11,6 +11,7 @@ export function useUninstallPlugin() { const confirmed = await showConfirmDelete({ id: 'uninstall-plugin-' + name, title: 'Uninstall Plugin', + confirmText: 'Uninstall', description: ( <> Permanently uninstall {name}?