Add "Open local folder" and "Create new vault" options to the vault picker dropdown. Uses tauri-plugin-dialog for native folder picker in Tauri mode, falls back to prompt() in browser mode. - Rust: add tauri-plugin-dialog, create_vault_dir command - Frontend: pickFolder utility, StatusBar UI, App.tsx handlers - Mock: create_vault_dir mock handler for browser testing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
778 B
TypeScript
26 lines
778 B
TypeScript
/**
|
|
* Vault dialog utilities.
|
|
* In Tauri mode, uses the native dialog plugin for folder picking.
|
|
* In browser mode, falls back to window.prompt() for testing.
|
|
*/
|
|
|
|
import { isTauri } from '../mock-tauri'
|
|
|
|
/**
|
|
* Opens a native folder picker dialog (Tauri) or falls back to prompt (browser).
|
|
* Returns the selected folder path, or null if the user cancelled.
|
|
*/
|
|
export async function pickFolder(title?: string): Promise<string | null> {
|
|
if (isTauri()) {
|
|
const { open } = await import('@tauri-apps/plugin-dialog')
|
|
const selected = await open({
|
|
directory: true,
|
|
multiple: false,
|
|
title: title ?? 'Select folder',
|
|
})
|
|
return selected as string | null
|
|
}
|
|
// Browser fallback: prompt for path
|
|
return prompt(title ?? 'Enter folder path:')
|
|
}
|