Remove folder/environment foreign keys to make sync/import easier, and simplify batch upsert code.

This commit is contained in:
Gregory Schier
2025-04-24 19:57:02 -07:00
parent 9fa0650647
commit bb014b7c43
6 changed files with 279 additions and 58 deletions

View File

@@ -11,6 +11,7 @@ export const openWorkspaceFromSyncDir = createFastMutation<void, void, string>({
const workspace = ops
.map((o) => (o.type === 'dbCreate' && o.fs.model.type === 'workspace' ? o.fs.model : null))
.filter((m) => m)[0];
if (workspace == null) {
showSimpleAlert('Failed to Open', 'No workspace found in directory');
return;

View File

@@ -18,10 +18,10 @@ export function SyncToFilesystemSetting({
onCreateNewWorkspace,
value,
}: SyncToFilesystemSettingProps) {
const [isNonEmpty, setIsNonEmpty] = useState<string | null>(null);
const [syncDir, setSyncDir] = useState<string | null>(null);
return (
<VStack className="w-full my-2" space={3}>
{isNonEmpty && (
{syncDir && (
<Banner color="notice" className="flex flex-col gap-1.5">
<p>Directory is not empty. Do you want to open it instead?</p>
<div>
@@ -31,7 +31,7 @@ export function SyncToFilesystemSetting({
size="xs"
type="button"
onClick={() => {
openWorkspaceFromSyncDir.mutate(isNonEmpty);
openWorkspaceFromSyncDir.mutate(syncDir);
onCreateNewWorkspace();
}}
>
@@ -52,12 +52,12 @@ export function SyncToFilesystemSetting({
if (filePath != null) {
const files = await readDir(filePath);
if (files.length > 0) {
setIsNonEmpty(filePath);
setSyncDir(filePath);
return;
}
}
setIsNonEmpty(null);
setSyncDir(null);
onChange({ ...value, filePath });
}}
/>