import { readDir } from '@tauri-apps/plugin-fs'; import { useState } from 'react'; import { Banner } from './core/Banner'; import { Checkbox } from './core/Checkbox'; import { VStack } from './core/Stacks'; import { SelectFile } from './SelectFile'; export interface SyncToFilesystemSettingProps { onChange: (args: { filePath: string | null; initGit?: boolean }) => void; value: { filePath: string | null; initGit?: boolean }; allowNonEmptyDirectory?: boolean; forceOpen?: boolean; } export function SyncToFilesystemSetting({ onChange, value, allowNonEmptyDirectory, forceOpen, }: SyncToFilesystemSettingProps) { const [error, setError] = useState(null); return (
Data directory {typeof value.initGit === 'boolean' && ' and Git'} Sync workspace data to folder as plain text files, ideal for backup and Git collaboration. Environments are excluded in order to keep your secrets private. {error &&
{error}
} { if (filePath != null) { const files = await readDir(filePath); if (files.length > 0 && !allowNonEmptyDirectory) { setError('The directory must be empty'); return; } } onChange({ ...value, filePath }); }} /> {value.filePath && typeof value.initGit === 'boolean' && ( onChange({ ...value, initGit })} title="Initialize Git Repo" /> )}
); }