import { readDir } from '@tauri-apps/plugin-fs'; import { useState } from 'react'; import { Banner } from './core/Banner'; import { VStack } from './core/Stacks'; import { SelectFile } from './SelectFile'; export interface SyncToFilesystemSettingProps { onChange: (filePath: string | null) => void; value: string | null; allowNonEmptyDirectory?: boolean; } export function SyncToFilesystemSetting({ onChange, value, allowNonEmptyDirectory, }: SyncToFilesystemSettingProps) { const [error, setError] = useState(null); return (
Sync to filesystem When enabled, workspace data syncs to the chosen folder as text files, ideal for backup and Git collaboration. {error &&
{error}
} { if (filePath != null) { const files = await readDir(filePath); if (files.length > 0 && !allowNonEmptyDirectory) { setError('The directory must be empty'); return; } } onChange(filePath); }} />
); }