Skip to content

Commit 0f5cd05

Browse files
committed
wip: desktop settings update
1 parent 521e730 commit 0f5cd05

File tree

9 files changed

+643
-377
lines changed

9 files changed

+643
-377
lines changed

desktop/src-tauri/Cargo.lock

Lines changed: 6 additions & 328 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/src-tauri/Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "desktop"
33
version = "0.1.0"
4-
description = "A Tauri App"
5-
authors = ["you"]
4+
description = "A desktop application built with Tauri, providing a UI and backend integration for flow."
5+
authors = ["Jahvon Dockery <[email protected]>"]
66
edition = "2021"
77

88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -24,11 +24,6 @@ tauri = { version = "2", features = [] }
2424
tauri-plugin-opener = "2"
2525
serde = { version = "1", features = ["derive"] }
2626
serde_json = "1"
27-
cmd_lib = "1.9.5"
28-
notify = "6.1.1"
29-
serde_yaml = "0.9.34"
30-
directories = "5.0.1"
31-
dirs = "5.0.1"
3227
tauri-plugin-shell = "2"
3328
tokio = { version = "1", features = ["full"] }
3429
async-trait = "0.1"

desktop/src-tauri/src/commands/config.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ impl<E: CommandExecutor + 'static> ConfigCommands<E> {
3131
self.executor.execute::<()>(&["config", "set", "namespace", namespace]).await
3232
}
3333

34+
pub async fn set_current_workspace(&self, workspace: &str) -> CommandResult<()> {
35+
self.executor.execute::<()>(&["config", "set", "current-workspace", workspace]).await
36+
}
37+
38+
pub async fn set_current_vault(&self, vault: &str) -> CommandResult<()> {
39+
self.executor.execute::<()>(&["config", "set", "current-vault", vault]).await
40+
}
41+
42+
pub async fn set_default_timeout(&self, timeout: &str) -> CommandResult<()> {
43+
self.executor.execute::<()>(&["config", "set", "default-timeout", timeout]).await
44+
}
45+
46+
pub async fn add_workspace(&self, name: &str, path: &str) -> CommandResult<()> {
47+
self.executor.execute::<()>(&["config", "workspace", "add", name, path]).await
48+
}
49+
50+
pub async fn remove_workspace(&self, name: &str) -> CommandResult<()> {
51+
self.executor.execute::<()>(&["config", "workspace", "remove", name]).await
52+
}
53+
54+
pub async fn add_vault(&self, name: &str, path: &str) -> CommandResult<()> {
55+
self.executor.execute::<()>(&["config", "vault", "add", name, path]).await
56+
}
57+
58+
pub async fn remove_vault(&self, name: &str) -> CommandResult<()> {
59+
self.executor.execute::<()>(&["config", "vault", "remove", name]).await
60+
}
61+
62+
pub async fn add_template(&self, name: &str, path: &str) -> CommandResult<()> {
63+
self.executor.execute::<()>(&["config", "template", "add", name, path]).await
64+
}
65+
66+
pub async fn remove_template(&self, name: &str) -> CommandResult<()> {
67+
self.executor.execute::<()>(&["config", "template", "remove", name]).await
68+
}
69+
3470
pub async fn reset(&self) -> CommandResult<()> {
3571
self.executor.execute::<()>(&["config", "reset"]).await
3672
}

desktop/src-tauri/src/lib.rs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,84 @@ async fn get_config() -> Result<crate::types::generated::config::Config, String>
2626
runner.cmd.config.get().await.map_err(|e| e.to_string())
2727
}
2828

29+
#[tauri::command]
30+
async fn update_config_theme(theme: String) -> Result<(), String> {
31+
let runner = cli_runners();
32+
runner.cmd.config.set_theme(&theme).await.map_err(|e| e.to_string())
33+
}
34+
35+
#[tauri::command]
36+
async fn update_config_workspace_mode(mode: String) -> Result<(), String> {
37+
let runner = cli_runners();
38+
runner.cmd.config.set_workspace_mode(&mode).await.map_err(|e| e.to_string())
39+
}
40+
41+
#[tauri::command]
42+
async fn update_config_log_mode(mode: String) -> Result<(), String> {
43+
let runner = cli_runners();
44+
runner.cmd.config.set_log_mode(&mode).await.map_err(|e| e.to_string())
45+
}
46+
47+
#[tauri::command]
48+
async fn update_config_namespace(namespace: String) -> Result<(), String> {
49+
let runner = cli_runners();
50+
runner.cmd.config.set_namespace(&namespace).await.map_err(|e| e.to_string())
51+
}
52+
53+
#[tauri::command]
54+
async fn update_config_current_workspace(workspace: String) -> Result<(), String> {
55+
let runner = cli_runners();
56+
runner.cmd.config.set_current_workspace(&workspace).await.map_err(|e| e.to_string())
57+
}
58+
59+
#[tauri::command]
60+
async fn update_config_current_vault(vault: String) -> Result<(), String> {
61+
let runner = cli_runners();
62+
runner.cmd.config.set_current_vault(&vault).await.map_err(|e| e.to_string())
63+
}
64+
65+
#[tauri::command]
66+
async fn update_config_default_timeout(timeout: String) -> Result<(), String> {
67+
let runner = cli_runners();
68+
runner.cmd.config.set_default_timeout(&timeout).await.map_err(|e| e.to_string())
69+
}
70+
71+
#[tauri::command]
72+
async fn add_config_workspace(name: String, path: String) -> Result<(), String> {
73+
let runner = cli_runners();
74+
runner.cmd.config.add_workspace(&name, &path).await.map_err(|e| e.to_string())
75+
}
76+
77+
#[tauri::command]
78+
async fn remove_config_workspace(name: String) -> Result<(), String> {
79+
let runner = cli_runners();
80+
runner.cmd.config.remove_workspace(&name).await.map_err(|e| e.to_string())
81+
}
82+
83+
#[tauri::command]
84+
async fn add_config_vault(name: String, path: String) -> Result<(), String> {
85+
let runner = cli_runners();
86+
runner.cmd.config.add_vault(&name, &path).await.map_err(|e| e.to_string())
87+
}
88+
89+
#[tauri::command]
90+
async fn remove_config_vault(name: String) -> Result<(), String> {
91+
let runner = cli_runners();
92+
runner.cmd.config.remove_vault(&name).await.map_err(|e| e.to_string())
93+
}
94+
95+
#[tauri::command]
96+
async fn add_config_template(name: String, path: String) -> Result<(), String> {
97+
let runner = cli_runners();
98+
runner.cmd.config.add_template(&name, &path).await.map_err(|e| e.to_string())
99+
}
100+
101+
#[tauri::command]
102+
async fn remove_config_template(name: String) -> Result<(), String> {
103+
let runner = cli_runners();
104+
runner.cmd.config.remove_template(&name).await.map_err(|e| e.to_string())
105+
}
106+
29107
#[tauri::command]
30108
async fn get_workspace(name: String) -> Result<enriched::Workspace, String> {
31109
let runner = cli_runners();
@@ -102,6 +180,19 @@ pub fn run() {
102180
list_workspaces,
103181
get_config,
104182
reload_window,
183+
update_config_theme,
184+
update_config_workspace_mode,
185+
update_config_log_mode,
186+
update_config_namespace,
187+
update_config_current_workspace,
188+
update_config_current_vault,
189+
update_config_default_timeout,
190+
add_config_workspace,
191+
remove_config_workspace,
192+
add_config_vault,
193+
remove_config_vault,
194+
add_config_template,
195+
remove_config_template,
105196
])
106197
.run(tauri::generate_context!())
107198
.expect("error while running tauri application");
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Box, Group, Paper, Text } from "@mantine/core";
2+
import styles from "../pages/Settings/Settings.module.css";
3+
4+
interface SettingRowProps {
5+
label: string;
6+
description?: string;
7+
children: React.ReactNode;
8+
}
9+
10+
export function SettingRow({ label, description, children }: SettingRowProps) {
11+
return (
12+
<Box py="md">
13+
<Group align="flex-start" gap="xl">
14+
<Box className={styles.settingLabel}>
15+
<Text size="sm" fw={500}>{label}</Text>
16+
{description && (
17+
<Text size="xs" c="dimmed" mt={2}>{description}</Text>
18+
)}
19+
</Box>
20+
<Box className={styles.settingControl}>
21+
{children}
22+
</Box>
23+
</Group>
24+
</Box>
25+
);
26+
}
27+
28+
interface SettingSectionProps {
29+
title: string;
30+
children: React.ReactNode;
31+
}
32+
33+
export function SettingSection({ title, children }: SettingSectionProps) {
34+
return (
35+
<Box mb="lg">
36+
<Text size="xs" fw={500} mb="xs" c="dimmed" tt="uppercase" className={styles.sectionTitle}>
37+
{title}
38+
</Text>
39+
<Paper className={styles.settingCard}>
40+
{children}
41+
</Paper>
42+
</Box>
43+
);
44+
}

0 commit comments

Comments
 (0)