diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index 5774afbd..0cc5b6ed 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -3,7 +3,7 @@ use crate::window_menu::app_menu; use log::{info, warn}; use rand::random; use tauri::{ - AppHandle, Emitter, LogicalSize, Manager, Runtime, WebviewUrl, WebviewWindow, WindowEvent, + AppHandle, Emitter, LogicalSize, Manager, PhysicalSize, Runtime, WebviewUrl, WebviewWindow, WindowEvent }; use tauri_plugin_opener::OpenerExt; use tokio::sync::mpsc; @@ -160,6 +160,11 @@ pub(crate) fn create_window( "dev.reset_size" => webview_window .set_size(LogicalSize::new(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)) .unwrap(), + "dev.reset_size_record" => { + let width = webview_window.outer_size().unwrap().width; + let height = width * 9 / 16; + webview_window.set_size(PhysicalSize::new(width, height)).unwrap() + } "dev.refresh" => webview_window.eval("location.reload()").unwrap(), "dev.generate_theme_css" => { w.emit("generate_theme_css", true).unwrap(); diff --git a/src-tauri/src/window_menu.rs b/src-tauri/src/window_menu.rs index 1fb549d5..5411d2ce 100644 --- a/src-tauri/src/window_menu.rs +++ b/src-tauri/src/window_menu.rs @@ -143,6 +143,8 @@ pub fn app_menu(app_handle: &AppHandle) -> tauri::Result> .build(app_handle)?, &MenuItemBuilder::with_id("dev.reset_size".to_string(), "Reset Size") .build(app_handle)?, + &MenuItemBuilder::with_id("dev.reset_size_record".to_string(), "Reset Size 16x9") + .build(app_handle)?, &MenuItemBuilder::with_id( "dev.generate_theme_css".to_string(), "Generate Theme CSS", diff --git a/src-web/components/WorkspaceEncryptionSetting.tsx b/src-web/components/WorkspaceEncryptionSetting.tsx index 06dac129..0effb576 100644 --- a/src-web/components/WorkspaceEncryptionSetting.tsx +++ b/src-web/components/WorkspaceEncryptionSetting.tsx @@ -1,35 +1,49 @@ -import { enableEncryption, revealWorkspaceKey, setWorkspaceKey } from '@yaakapp-internal/crypto'; -import type { WorkspaceMeta } from '@yaakapp-internal/models'; -import classNames from 'classnames'; -import { useAtomValue } from 'jotai'; -import { useEffect, useState } from 'react'; -import { activeWorkspaceAtom, activeWorkspaceMetaAtom } from '../hooks/useActiveWorkspace'; -import { createFastMutation } from '../hooks/useFastMutation'; -import { useStateWithDeps } from '../hooks/useStateWithDeps'; -import { CopyIconButton } from './CopyIconButton'; -import { Banner } from './core/Banner'; -import type { ButtonProps } from './core/Button'; -import { Button } from './core/Button'; -import { IconButton } from './core/IconButton'; -import { IconTooltip } from './core/IconTooltip'; -import { Label } from './core/Label'; -import { PlainInput } from './core/PlainInput'; -import { HStack, VStack } from './core/Stacks'; -import { EncryptionHelp } from './EncryptionHelp'; +import { + enableEncryption, + revealWorkspaceKey, + setWorkspaceKey, +} from "@yaakapp-internal/crypto"; +import type { WorkspaceMeta } from "@yaakapp-internal/models"; +import classNames from "classnames"; +import { useAtomValue } from "jotai"; +import { useEffect, useState } from "react"; +import { + activeWorkspaceAtom, + activeWorkspaceMetaAtom, +} from "../hooks/useActiveWorkspace"; +import { createFastMutation } from "../hooks/useFastMutation"; +import { useStateWithDeps } from "../hooks/useStateWithDeps"; +import { CopyIconButton } from "./CopyIconButton"; +import { Banner } from "./core/Banner"; +import type { ButtonProps } from "./core/Button"; +import { Button } from "./core/Button"; +import { IconButton } from "./core/IconButton"; +import { IconTooltip } from "./core/IconTooltip"; +import { Label } from "./core/Label"; +import { PlainInput } from "./core/PlainInput"; +import { HStack, VStack } from "./core/Stacks"; +import { EncryptionHelp } from "./EncryptionHelp"; interface Props { - size?: ButtonProps['size']; + size?: ButtonProps["size"]; expanded?: boolean; onDone?: () => void; onEnabledEncryption?: () => void; } -export function WorkspaceEncryptionSetting({ size, expanded, onDone, onEnabledEncryption }: Props) { - const [justEnabledEncryption, setJustEnabledEncryption] = useState(false); +export function WorkspaceEncryptionSetting( + { size, expanded, onDone, onEnabledEncryption }: Props, +) { + const [justEnabledEncryption, setJustEnabledEncryption] = useState( + false, + ); + const [error, setError] = useState(null); const workspace = useAtomValue(activeWorkspaceAtom); const workspaceMeta = useAtomValue(activeWorkspaceMetaAtom); - const [key, setKey] = useState<{ key: string | null; error: string | null } | null>(null); + const [key, setKey] = useState< + { key: string | null; error: string | null } | null + >(null); useEffect(() => { if (workspaceMeta == null) { @@ -108,30 +122,39 @@ export function WorkspaceEncryptionSetting({ size, expanded, onDone, onEnabledEn return (
- {expanded ? ( - - - - ) : ( - - )} + {error && {error}} + {expanded + ? ( + + + + ) + : ( + + )}
); } const setWorkspaceKeyMut = createFastMutation({ - mutationKey: ['set-workspace-key'], + mutationKey: ["set-workspace-key"], mutationFn: setWorkspaceKey, }); @@ -144,15 +167,13 @@ function EnterWorkspaceKey({ onEnabled?: () => void; error?: string | null; }) { - const [key, setKey] = useState(''); + const [key, setKey] = useState(""); return ( - {error ? ( - {error} - ) : ( + {error ? {error} : ( - This workspace contains encrypted values but no key is configured. Please enter the - workspace key to access the encrypted data. + This workspace contains encrypted values but no key is configured. + Please enter the workspace key to access the encrypted data. )} {!disableLabel && ( - Workspace encryption key{' '} - + Workspace encryption key{" "} + )} - {encryptionKey && } + {encryptionKey && ( + + )} - {encryptionKey && } + {encryptionKey && ( + + )} setShow((v) => !v)} /> @@ -227,31 +259,32 @@ function KeyRevealer({ function HighlightedKey({ keyText, show }: { keyText: string; show: boolean }) { return ( - {show ? ( - keyText.split('').map((c, i) => { - return ( - - {c} - - ); - }) - ) : ( -
•••••••••••••••••••••
- )} + {show + ? ( + keyText.split("").map((c, i) => { + return ( + + {c} + + ); + }) + ) + :
•••••••••••••••••••••
}
); } const helpAfterEncryption = (

- The following key is used for encryption operations within this workspace. It is stored securely - using your OS keychain, but it is recommended to back it up. If you share this workspace with - others, you'll need to send them this key to access any encrypted values. + The following key is used for encryption operations within this workspace. + It is stored securely using your OS keychain, but it is recommended to back + it up. If you share this workspace with others, you'll need to send + them this key to access any encrypted values.

);