diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index e6cecdf8..12e906f3 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -38,16 +38,24 @@ 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, Color, FilterResponse, GetGrpcRequestActionsResponse, GetHttpAuthenticationConfigResponse, GetHttpAuthenticationSummaryResponse, GetHttpRequestActionsResponse, GetTemplateFunctionSummaryResponse, GetTemplateFunctionConfigResponse, InternalEvent, InternalEventPayload, JsonPrimitive, PluginWindowContext, RenderPurpose, ShowToastRequest}; +use yaak_plugins::events::{ + CallGrpcRequestActionArgs, CallGrpcRequestActionRequest, CallHttpRequestActionArgs, + CallHttpRequestActionRequest, Color, FilterResponse, GetGrpcRequestActionsResponse, + GetHttpAuthenticationConfigResponse, GetHttpAuthenticationSummaryResponse, + GetHttpRequestActionsResponse, GetTemplateFunctionConfigResponse, + GetTemplateFunctionSummaryResponse, InternalEvent, InternalEventPayload, JsonPrimitive, + PluginWindowContext, RenderPurpose, ShowToastRequest, +}; use yaak_plugins::manager::PluginManager; use yaak_plugins::plugin_meta::PluginMetadata; use yaak_plugins::template_callback::PluginTemplateCallback; use yaak_sse::sse::ServerSentEvent; use yaak_templates::format::format_json; -use yaak_templates::{RenderErrorBehavior, RenderOptions, Tokens, transform_args}; use yaak_templates::format_xml::format_xml; +use yaak_templates::{RenderErrorBehavior, RenderOptions, Tokens, transform_args}; mod commands; +mod dns; mod encoding; mod error; mod grpc; @@ -61,7 +69,6 @@ mod updates; mod uri_scheme; mod window; mod window_menu; -mod dns; #[derive(serde::Serialize)] #[serde(default, rename_all = "camelCase")] @@ -852,12 +859,16 @@ async fn cmd_template_function_config( AnyModel::Folder(m) => (m.workspace_id, m.folder_id), AnyModel::Workspace(m) => (m.id, None), m => { - return Err(GenericError(format!("Unsupported model to call template functions {m:?}"))); + return Err(GenericError(format!( + "Unsupported model to call template functions {m:?}" + ))); } }; let environment_chain = window.db().resolve_environments(&workspace_id, folder_id.as_deref(), environment_id)?; - Ok(plugin_manager.get_template_function_config(&window, function_name, environment_chain, values, model.id()).await?) + Ok(plugin_manager + .get_template_function_config(&window, function_name, environment_chain, values, model.id()) + .await?) } #[tauri::command] diff --git a/src-tauri/src/notifications.rs b/src-tauri/src/notifications.rs index 766a819a..5c94ce15 100644 --- a/src-tauri/src/notifications.rs +++ b/src-tauri/src/notifications.rs @@ -3,7 +3,7 @@ use std::time::SystemTime; use crate::error::Result; use crate::history::get_or_upsert_launch_info; use chrono::{DateTime, Utc}; -use log::debug; +use log::{debug, info}; use reqwest::Method; use serde::{Deserialize, Serialize}; use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow}; @@ -77,6 +77,13 @@ impl YaakNotifier { self.last_check = SystemTime::now(); + if !app_handle.db().get_settings().check_notifications { + info!("Notifications are disabled. Skipping check."); + return Ok(()); + } + + debug!("Checking for notifications"); + #[cfg(feature = "license")] let license_check = { use yaak_license::{check_license, LicenseCheckStatus}; diff --git a/src-tauri/yaak-models/bindings/gen_models.ts b/src-tauri/yaak-models/bindings/gen_models.ts index 51f78ff8..f4bf5f90 100644 --- a/src-tauri/yaak-models/bindings/gen_models.ts +++ b/src-tauri/yaak-models/bindings/gen_models.ts @@ -62,7 +62,7 @@ export type ProxySetting = { "type": "enabled", http: string, https: string, aut export type ProxySettingAuth = { user: string, password: string, }; -export type Settings = { model: "settings", id: string, createdAt: string, updatedAt: string, appearance: string, coloredMethods: boolean, editorFont: string | null, editorFontSize: number, editorKeymap: EditorKeymap, editorSoftWrap: boolean, hideWindowControls: boolean, interfaceFont: string | null, interfaceFontSize: number, interfaceScale: number, openWorkspaceNewWindow: boolean | null, proxy: ProxySetting | null, themeDark: string, themeLight: string, updateChannel: string, hideLicenseBadge: boolean, autoupdate: boolean, autoDownloadUpdates: boolean, }; +export type Settings = { model: "settings", id: string, createdAt: string, updatedAt: string, appearance: string, coloredMethods: boolean, editorFont: string | null, editorFontSize: number, editorKeymap: EditorKeymap, editorSoftWrap: boolean, hideWindowControls: boolean, interfaceFont: string | null, interfaceFontSize: number, interfaceScale: number, openWorkspaceNewWindow: boolean | null, proxy: ProxySetting | null, themeDark: string, themeLight: string, updateChannel: string, hideLicenseBadge: boolean, autoupdate: boolean, autoDownloadUpdates: boolean, checkNotifications: boolean, }; export type SyncState = { model: "sync_state", id: string, workspaceId: string, createdAt: string, updatedAt: string, flushedAt: string, modelId: string, checksum: string, relPath: string, syncDir: string, }; diff --git a/src-tauri/yaak-models/migrations/20251028060300_check_notifications_setting.sql b/src-tauri/yaak-models/migrations/20251028060300_check_notifications_setting.sql new file mode 100644 index 00000000..9b1f3507 --- /dev/null +++ b/src-tauri/yaak-models/migrations/20251028060300_check_notifications_setting.sql @@ -0,0 +1 @@ +ALTER TABLE settings ADD COLUMN check_notifications BOOLEAN DEFAULT true NOT NULL; diff --git a/src-tauri/yaak-models/src/models.rs b/src-tauri/yaak-models/src/models.rs index 96a14f59..e4f96b18 100644 --- a/src-tauri/yaak-models/src/models.rs +++ b/src-tauri/yaak-models/src/models.rs @@ -123,6 +123,7 @@ pub struct Settings { pub hide_license_badge: bool, pub autoupdate: bool, pub auto_download_updates: bool, + pub check_notifications: bool, } impl UpsertModelInfo for Settings { @@ -175,6 +176,7 @@ impl UpsertModelInfo for Settings { (Autoupdate, self.autoupdate.into()), (AutoDownloadUpdates, self.auto_download_updates.into()), (ColoredMethods, self.colored_methods.into()), + (CheckNotifications, self.check_notifications.into()), (Proxy, proxy.into()), ]) } @@ -200,6 +202,7 @@ impl UpsertModelInfo for Settings { SettingsIden::Autoupdate, SettingsIden::AutoDownloadUpdates, SettingsIden::ColoredMethods, + SettingsIden::CheckNotifications, ] } @@ -232,6 +235,7 @@ impl UpsertModelInfo for Settings { auto_download_updates: row.get("auto_download_updates")?, hide_license_badge: row.get("hide_license_badge")?, colored_methods: row.get("colored_methods")?, + check_notifications: row.get("check_notifications")?, }) } } diff --git a/src-tauri/yaak-models/src/queries/settings.rs b/src-tauri/yaak-models/src/queries/settings.rs index 472a6697..6cb89390 100644 --- a/src-tauri/yaak-models/src/queries/settings.rs +++ b/src-tauri/yaak-models/src/queries/settings.rs @@ -35,6 +35,7 @@ impl<'a> DbContext<'a> { colored_methods: false, hide_license_badge: false, auto_download_updates: true, + check_notifications: true, }; self.upsert(&settings, &UpdateSource::Background).expect("Failed to upsert settings") } diff --git a/src-web/components/Settings/SettingsGeneral.tsx b/src-web/components/Settings/SettingsGeneral.tsx index 12827035..8f1ebfa3 100644 --- a/src-web/components/Settings/SettingsGeneral.tsx +++ b/src-web/components/Settings/SettingsGeneral.tsx @@ -71,37 +71,25 @@ export function SettingsGeneral() { disabled={!settings.autoupdate} help="Automatically download Yaak updates (!50MB) in the background, so they will be immediately ready to install." title="Automatically download updates" - onChange={(autoDownloadUpdates) => - patchModel(settings, { autoDownloadUpdates }) - } + onChange={(autoDownloadUpdates) => patchModel(settings, { autoDownloadUpdates })} /> - - - { + if (v === 'current') await patchModel(settings, { openWorkspaceNewWindow: false }); + else if (v === 'new') await patchModel(settings, { openWorkspaceNewWindow: true }); + else await patchModel(settings, { openWorkspaceNewWindow: null }); + }} + options={[ + { label: 'Always ask', value: 'ask' }, + { label: 'Open in current window', value: 'current' }, + { label: 'Open in new window', value: 'new' }, + ]} + /> {fonts.data && ( ({ label: f, value: f, @@ -112,19 +135,19 @@ export function SettingsInterface() { leftSlot={} size="sm" name="editorKeymap" - label="Editor Keymap" + label="Editor keymap" value={`${settings.editorKeymap}`} options={keymaps} onChange={(v) => patchModel(settings, { editorKeymap: v })} /> patchModel(settings, { editorSoftWrap })} /> patchModel(settings, { coloredMethods })} /> @@ -134,7 +157,7 @@ export function SettingsInterface() { {type() !== 'macos' && ( patchModel(settings, { hideWindowControls })} /> diff --git a/src-web/components/Settings/SettingsLicense.tsx b/src-web/components/Settings/SettingsLicense.tsx index 6b689d06..7e540adf 100644 --- a/src-web/components/Settings/SettingsLicense.tsx +++ b/src-web/components/Settings/SettingsLicense.tsx @@ -56,8 +56,8 @@ function SettingsLicenseCmp() {

Hey, I'm Greg 👋🏼

Yaak is free for personal projects and learning.{' '} - {check.data?.type === 'trialing' ? 'After your trial, a ' : 'A '} - license is required for work or commercial use. + {check.data?.type === 'trialing' ? 'Once your trial ends, a ' : 'A '} + license will be required for work or commercial use.

{settings.proxy?.type === 'enabled' && ( diff --git a/src-web/components/core/Confirm.tsx b/src-web/components/core/Confirm.tsx index 6b76ee64..431912a2 100644 --- a/src-web/components/core/Confirm.tsx +++ b/src-web/components/core/Confirm.tsx @@ -44,19 +44,19 @@ export function Confirm({ autoFocus onChange={setConfirm} placeholder={requireTyping} + labelRightSlot={ + + } label={ -

-

- Type {requireTyping} to confirm -

- -
+ <> + Type {requireTyping} to confirm + } /> )} diff --git a/src-web/components/core/Label.tsx b/src-web/components/core/Label.tsx index fae6db4f..4010ade3 100644 --- a/src-web/components/core/Label.tsx +++ b/src-web/components/core/Label.tsx @@ -9,6 +9,7 @@ export function Label({ visuallyHidden, tags = [], required, + rightSlot, help, ...props }: HTMLAttributes & { @@ -16,6 +17,7 @@ export function Label({ required?: boolean; tags?: string[]; visuallyHidden?: boolean; + rightSlot?: ReactNode; children: ReactNode; help?: ReactNode; }) { @@ -30,7 +32,7 @@ export function Label({ )} {...props} > - + {children} {required === true && *} @@ -40,6 +42,7 @@ export function Label({ ))} {help && } + {rightSlot &&
{rightSlot}
} ); }