diff --git a/src-tauri/.sqlx/query-ca3485d87b060cd77c4114d2af544adf18f6f15341d9d5db40865e92a80da4e2.json b/src-tauri/.sqlx/query-05dca7fe15ab1bf03952e94498ef3130e16f752da72782783696eb2cca4736d5.json similarity index 81% rename from src-tauri/.sqlx/query-ca3485d87b060cd77c4114d2af544adf18f6f15341d9d5db40865e92a80da4e2.json rename to src-tauri/.sqlx/query-05dca7fe15ab1bf03952e94498ef3130e16f752da72782783696eb2cca4736d5.json index 118bdd64..bfe436e1 100644 --- a/src-tauri/.sqlx/query-ca3485d87b060cd77c4114d2af544adf18f6f15341d9d5db40865e92a80da4e2.json +++ b/src-tauri/.sqlx/query-05dca7fe15ab1bf03952e94498ef3130e16f752da72782783696eb2cca4736d5.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "\n SELECT\n id, model, created_at, updated_at, theme, appearance,\n theme_dark, theme_light, update_channel,\n interface_font_size, interface_scale, editor_font_size, editor_soft_wrap\n FROM settings\n WHERE id = 'default'\n ", + "query": "\n SELECT\n id, model, created_at, updated_at, theme, appearance,\n theme_dark, theme_light, update_channel,\n interface_font_size, interface_scale, editor_font_size, editor_soft_wrap, \n open_workspace_new_window\n FROM settings\n WHERE id = 'default'\n ", "describe": { "columns": [ { @@ -67,6 +67,11 @@ "name": "editor_soft_wrap", "ordinal": 12, "type_info": "Bool" + }, + { + "name": "open_workspace_new_window", + "ordinal": 13, + "type_info": "Bool" } ], "parameters": { @@ -85,8 +90,9 @@ false, false, false, - false + false, + true ] }, - "hash": "ca3485d87b060cd77c4114d2af544adf18f6f15341d9d5db40865e92a80da4e2" + "hash": "05dca7fe15ab1bf03952e94498ef3130e16f752da72782783696eb2cca4736d5" } diff --git a/src-tauri/.sqlx/query-efd8ba41ea909b18dd520c57c1d464c5ae057b720cbbedcaec1513d43535632c.json b/src-tauri/.sqlx/query-6b5edf45a6799cd7f87c23a3c7f818ad110d58c601f694a619d9345ae9e8e11d.json similarity index 55% rename from src-tauri/.sqlx/query-efd8ba41ea909b18dd520c57c1d464c5ae057b720cbbedcaec1513d43535632c.json rename to src-tauri/.sqlx/query-6b5edf45a6799cd7f87c23a3c7f818ad110d58c601f694a619d9345ae9e8e11d.json index eed32b7a..dcf32d4f 100644 --- a/src-tauri/.sqlx/query-efd8ba41ea909b18dd520c57c1d464c5ae057b720cbbedcaec1513d43535632c.json +++ b/src-tauri/.sqlx/query-6b5edf45a6799cd7f87c23a3c7f818ad110d58c601f694a619d9345ae9e8e11d.json @@ -1,12 +1,12 @@ { "db_name": "SQLite", - "query": "\n UPDATE settings SET (\n theme, appearance, theme_dark, theme_light, update_channel,\n interface_font_size, interface_scale, editor_font_size, editor_soft_wrap\n ) = (?, ?, ?, ?, ?, ?, ?, ?, ?) WHERE id = 'default';\n ", + "query": "\n UPDATE settings SET (\n theme, appearance, theme_dark, theme_light, update_channel,\n interface_font_size, interface_scale, editor_font_size, editor_soft_wrap,\n open_workspace_new_window\n ) = (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) WHERE id = 'default';\n ", "describe": { "columns": [], "parameters": { - "Right": 9 + "Right": 10 }, "nullable": [] }, - "hash": "efd8ba41ea909b18dd520c57c1d464c5ae057b720cbbedcaec1513d43535632c" + "hash": "6b5edf45a6799cd7f87c23a3c7f818ad110d58c601f694a619d9345ae9e8e11d" } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1d3605b8..0a02e6e7 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -30,27 +30,27 @@ base64 = "0.22.0" boa_engine = { version = "0.18.0", features = ["annex-b"] } boa_runtime = { version = "0.18.0" } chrono = { version = "0.4.31", features = ["serde"] } +datetime = "0.5.2" +hex_color = "3.0.0" http = "0.2.10" +log = "0.4.21" rand = "0.8.5" +regex = "1.10.2" reqwest = { version = "0.11.23", features = ["multipart", "cookies", "gzip", "brotli", "deflate", "json"] } +reqwest_cookie_store = "0.6.0" serde = { version = "1.0.198", features = ["derive"] } serde_json = { version = "1.0.116", features = ["raw_value"] } sqlx = { version = "0.7.4", features = ["sqlite", "runtime-tokio-rustls", "json", "chrono", "time"] } tauri = { version = "2.0.0-beta", features = ["config-toml", "devtools", "protocol-asset"] } tauri-plugin-clipboard-manager = "2.1.0-beta" +tauri-plugin-deep-link = "2.0.0-beta" tauri-plugin-dialog = "2.0.0-beta" +tauri-plugin-fs = "2.0.0-beta" tauri-plugin-log = { version = "2.0.0-beta", features = ["colored"] } -tauri-plugin-shell = "2.0.0-beta" tauri-plugin-os = "2.0.0-beta" +tauri-plugin-shell = "2.0.0-beta" tauri-plugin-updater = "2.0.0-beta" tauri-plugin-window-state = "2.0.0-beta" -tauri-plugin-fs = "2.0.0-beta" -tauri-plugin-deep-link = "2.0.0-beta" tokio = { version = "1.36.0", features = ["sync"] } -uuid = "1.7.0" -log = "0.4.21" -datetime = "0.5.2" -reqwest_cookie_store = "0.6.0" tokio-stream = "0.1.15" -regex = "1.10.2" -hex_color = "3.0.0" +uuid = "1.7.0" diff --git a/src-tauri/migrations/20240607151115_open-workspace-setting.sql b/src-tauri/migrations/20240607151115_open-workspace-setting.sql new file mode 100644 index 00000000..99869d9c --- /dev/null +++ b/src-tauri/migrations/20240607151115_open-workspace-setting.sql @@ -0,0 +1 @@ +ALTER TABLE settings ADD COLUMN open_workspace_new_window BOOLEAN NULL DEFAULT NULL; diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs index 2982526f..82cca640 100644 --- a/src-tauri/src/models.rs +++ b/src-tauri/src/models.rs @@ -59,6 +59,7 @@ pub struct Settings { pub interface_scale: i64, pub editor_font_size: i64, pub editor_soft_wrap: bool, + pub open_workspace_new_window: Option, } #[derive(sqlx::FromRow, Debug, Clone, Serialize, Deserialize, Default)] @@ -891,7 +892,8 @@ async fn get_settings(mgr: &impl Manager) -> Result SELECT id, model, created_at, updated_at, theme, appearance, theme_dark, theme_light, update_channel, - interface_font_size, interface_scale, editor_font_size, editor_soft_wrap + interface_font_size, interface_scale, editor_font_size, editor_soft_wrap, + open_workspace_new_window FROM settings WHERE id = 'default' "#, @@ -928,8 +930,9 @@ pub async fn update_settings( r#" UPDATE settings SET ( theme, appearance, theme_dark, theme_light, update_channel, - interface_font_size, interface_scale, editor_font_size, editor_soft_wrap - ) = (?, ?, ?, ?, ?, ?, ?, ?, ?) WHERE id = 'default'; + interface_font_size, interface_scale, editor_font_size, editor_soft_wrap, + open_workspace_new_window + ) = (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) WHERE id = 'default'; "#, settings.theme, settings.appearance, @@ -940,6 +943,7 @@ pub async fn update_settings( settings.interface_scale, settings.editor_font_size, settings.editor_soft_wrap, + settings.open_workspace_new_window, ) .execute(&db) .await?; diff --git a/src-web/components/OpenWorkspaceDialog.tsx b/src-web/components/OpenWorkspaceDialog.tsx new file mode 100644 index 00000000..9222cf74 --- /dev/null +++ b/src-web/components/OpenWorkspaceDialog.tsx @@ -0,0 +1,64 @@ +import { useState } from 'react'; +import { useOpenWorkspace } from '../hooks/useOpenWorkspace'; +import { useSettings } from '../hooks/useSettings'; +import { useUpdateSettings } from '../hooks/useUpdateSettings'; +import type { Workspace } from '../lib/models'; +import { Button } from './core/Button'; +import { Checkbox } from './core/Checkbox'; +import { Icon } from './core/Icon'; +import { InlineCode } from './core/InlineCode'; +import { HStack, VStack } from './core/Stacks'; + +interface Props { + hide: () => void; + workspace: Workspace; +} + +export function OpenWorkspaceDialog({ hide, workspace }: Props) { + const openWorkspace = useOpenWorkspace(); + const settings = useSettings(); + const updateSettings = useUpdateSettings(); + const [remember, setRemember] = useState(false); + + return ( + +

+ Where would you like to open {workspace.name}? +

+ + + + + {settings && ( + + + + )} +
+ ); +} diff --git a/src-web/components/Settings/SettingsGeneral.tsx b/src-web/components/Settings/SettingsGeneral.tsx index a793b83b..464073cd 100644 --- a/src-web/components/Settings/SettingsGeneral.tsx +++ b/src-web/components/Settings/SettingsGeneral.tsx @@ -50,6 +50,33 @@ export function SettingsGeneral() { onClick={() => checkForUpdates.mutateAsync()} /> +