Merge pull request #34 from refactoringhq/task/vault-picker-create-v2
fix: remove broken Create New Vault button, unify with Open Local Folder
This commit is contained in:
20
design/vault-picker-create.pen
Normal file
20
design/vault-picker-create.pen
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"children": [
|
||||
{
|
||||
"name": "Vault Picker — Before (broken Create New Vault button)",
|
||||
"type": "FRAME",
|
||||
"width": 400,
|
||||
"height": 300,
|
||||
"background": "#ffffff",
|
||||
"notes": "The old vault picker had a 'Create New Vault' button that used window.prompt() — broken in Tauri WebView (silently returns null). Clicking did nothing."
|
||||
},
|
||||
{
|
||||
"name": "Vault Picker — After (unified with Open Local Folder)",
|
||||
"type": "FRAME",
|
||||
"width": 400,
|
||||
"height": 300,
|
||||
"background": "#ffffff",
|
||||
"notes": "Removed the broken Create New Vault button. Open Local Folder is semantically equivalent — macOS Finder's folder picker lets users create new folders inline. One button, clear action, works correctly."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -136,11 +136,6 @@ fn clone_repo(url: String, token: String, local_path: String) -> Result<String,
|
||||
github::clone_repo(&url, &token, &local_path)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn create_vault_dir(path: String) -> Result<(), String> {
|
||||
std::fs::create_dir_all(&path).map_err(|e| format!("Failed to create directory: {e}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn github_device_flow_start() -> Result<DeviceFlowStart, String> {
|
||||
github::github_device_flow_start().await
|
||||
@@ -159,38 +154,6 @@ async fn github_get_user(token: String) -> Result<GitHubUser, String> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_create_vault_dir_creates_directory() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let vault_path = tmp.path().join("my-new-vault");
|
||||
assert!(!vault_path.exists());
|
||||
|
||||
let result = create_vault_dir(vault_path.to_string_lossy().to_string());
|
||||
assert!(result.is_ok());
|
||||
assert!(vault_path.is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_vault_dir_nested_path() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let vault_path = tmp.path().join("deep/nested/vault");
|
||||
assert!(!vault_path.exists());
|
||||
|
||||
let result = create_vault_dir(vault_path.to_string_lossy().to_string());
|
||||
assert!(result.is_ok());
|
||||
assert!(vault_path.is_dir());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_vault_dir_existing_dir_ok() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let vault_path = tmp.path().join("existing");
|
||||
std::fs::create_dir(&vault_path).unwrap();
|
||||
|
||||
let result = create_vault_dir(vault_path.to_string_lossy().to_string());
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
} // close mod tests
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -266,7 +229,6 @@ pub fn run() {
|
||||
github_list_repos,
|
||||
github_create_repo,
|
||||
clone_repo,
|
||||
create_vault_dir,
|
||||
github_device_flow_start,
|
||||
github_device_flow_poll,
|
||||
github_get_user
|
||||
|
||||
@@ -149,7 +149,6 @@ function App() {
|
||||
}
|
||||
}, [addAndSwitchVault])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!notes.activeTabPath) { setGitHistory([]); return }
|
||||
vault.loadGitHistory(notes.activeTabPath).then(setGitHistory)
|
||||
|
||||
@@ -1841,7 +1841,6 @@ const mockHandlers: Record<string, (args: any) => any> = {
|
||||
clone_repo: (args: { url: string; local_path: string }) => `Cloned to ${args.local_path}`,
|
||||
purge_trash: () => [],
|
||||
migrate_is_a_to_type: () => 0,
|
||||
create_vault_dir: () => null,
|
||||
github_device_flow_start: (): DeviceFlowStart => {
|
||||
mockDeviceFlowPollCount = 0
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user