diff --git a/src-web/commands/openWorkspaceFromSyncDir.tsx b/src-web/commands/openWorkspaceFromSyncDir.tsx index 2b79c1aa..ba354d12 100644 --- a/src-web/commands/openWorkspaceFromSyncDir.tsx +++ b/src-web/commands/openWorkspaceFromSyncDir.tsx @@ -1,20 +1,11 @@ -import { open } from '@tauri-apps/plugin-dialog'; import { applySync, calculateSyncFsOnly } from '@yaakapp-internal/sync'; import { createFastMutation } from '../hooks/useFastMutation'; import { showSimpleAlert } from '../lib/alert'; import { router } from '../lib/router'; -export const openWorkspaceFromSyncDir = createFastMutation({ +export const openWorkspaceFromSyncDir = createFastMutation({ mutationKey: [], - mutationFn: async () => { - const dir = await open({ - title: 'Select Workspace Directory', - directory: true, - multiple: false, - }); - - if (dir == null) return; - + mutationFn: async (dir) => { const ops = await calculateSyncFsOnly(dir); const workspace = ops diff --git a/src-web/components/CreateWorkspaceDialog.tsx b/src-web/components/CreateWorkspaceDialog.tsx index 2b80f4db..c1501560 100644 --- a/src-web/components/CreateWorkspaceDialog.tsx +++ b/src-web/components/CreateWorkspaceDialog.tsx @@ -20,7 +20,7 @@ export function CreateWorkspaceDialog({ hide }: Props) { const [syncConfig, setSyncConfig] = useState<{ filePath: string | null; initGit?: boolean; - }>({ filePath: null, initGit: true }); + }>({ filePath: null, initGit: false }); return ( + + + ) : ( + + 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. + + )} { if (filePath != null) { const files = await readDir(filePath); - if (files.length > 0 && !allowNonEmptyDirectory) { - setError('The directory must be empty'); + if (files.length > 0) { + setIsNonEmpty(filePath); return; } } + setIsNonEmpty(null); onChange({ ...value, filePath }); }} /> diff --git a/src-web/components/WorkspaceActionsDropdown.tsx b/src-web/components/WorkspaceActionsDropdown.tsx index 15449cb7..316d9300 100644 --- a/src-web/components/WorkspaceActionsDropdown.tsx +++ b/src-web/components/WorkspaceActionsDropdown.tsx @@ -1,3 +1,4 @@ +import {open} from "@tauri-apps/plugin-dialog"; import { revealItemInDir } from '@tauri-apps/plugin-opener'; import classNames from 'classnames'; import { memo, useCallback, useMemo } from 'react'; @@ -75,7 +76,16 @@ export const WorkspaceActionsDropdown = memo(function WorkspaceActionsDropdown({ { label: 'Open Existing Workspace', leftSlot: , - onSelect: openWorkspaceFromSyncDir.mutate, + onSelect: async () => { + const dir = await open({ + title: 'Select Workspace Directory', + directory: true, + multiple: false, + }); + + if (dir == null) return; + openWorkspaceFromSyncDir.mutate(dir); + }, }, ]; diff --git a/src-web/components/WorkspaceSettingsDialog.tsx b/src-web/components/WorkspaceSettingsDialog.tsx index 05b406b4..5d1d900b 100644 --- a/src-web/components/WorkspaceSettingsDialog.tsx +++ b/src-web/components/WorkspaceSettingsDialog.tsx @@ -63,6 +63,7 @@ export function WorkspaceSettingsDialog({ workspaceId, hide, openSyncMenu }: Pro { upsertWorkspaceMeta.mutate({ ...workspaceMeta, settingSyncDir: filePath }); }}