diff --git a/src-tauri/yaak-models/src/queries/batch.rs b/src-tauri/yaak-models/src/queries/batch.rs index 9eeb1d3c..b5a711e0 100644 --- a/src-tauri/yaak-models/src/queries/batch.rs +++ b/src-tauri/yaak-models/src/queries/batch.rs @@ -49,15 +49,7 @@ impl<'a> DbContext<'a> { info!("Upserted {} websocket_requests", imported_resources.websocket_requests.len()); } - if environments.len() > 0 { - for x in environments { - let x = self.upsert_environment(&x, source)?; - imported_resources.environments.push(x.clone()); - } - info!("Upserted {} environments", imported_resources.environments.len()); - } - - // Do folders last so it doesn't cause the UI to render empty folders before populating + // Do folders after their children so the UI doesn't render empty folders before populating // immediately after. if folders.len() > 0 { for v in folders { @@ -67,6 +59,15 @@ impl<'a> DbContext<'a> { info!("Upserted {} folders", imported_resources.folders.len()); } + // Do environments last because they can depend on many models (requests, folders, etc) + if environments.len() > 0 { + for x in environments { + let x = self.upsert_environment(&x, source)?; + imported_resources.environments.push(x.clone()); + } + info!("Upserted {} environments", imported_resources.environments.len()); + } + Ok(imported_resources) } } diff --git a/src-web/commands/createEnvironment.ts b/src-web/commands/createEnvironment.ts index 4ac57e20..98867dac 100644 --- a/src-web/commands/createEnvironment.ts +++ b/src-web/commands/createEnvironment.ts @@ -5,7 +5,7 @@ import { jotaiStore } from '../lib/jotai'; import { showPrompt } from '../lib/prompt'; import { setWorkspaceSearchParams } from '../lib/setWorkspaceSearchParams'; -export const createEnvironmentAndActivate = createFastMutation< +export const createSubEnvironmentAndActivate = createFastMutation< string | null, unknown, Environment | null @@ -46,7 +46,6 @@ export const createEnvironmentAndActivate = createFastMutation< return; // Was not created } - console.log('NAVIGATING', jotaiStore.get(activeWorkspaceIdAtom), environmentId); setWorkspaceSearchParams({ environment_id: environmentId }); }, }); diff --git a/src-web/components/CommandPaletteDialog.tsx b/src-web/components/CommandPaletteDialog.tsx index f17df452..47941116 100644 --- a/src-web/components/CommandPaletteDialog.tsx +++ b/src-web/components/CommandPaletteDialog.tsx @@ -5,7 +5,7 @@ import { useAtomValue } from 'jotai'; import type { KeyboardEvent, ReactNode } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createFolder } from '../commands/commands'; -import { createEnvironmentAndActivate } from '../commands/createEnvironment'; +import { createSubEnvironmentAndActivate } from '../commands/createEnvironment'; import { openSettings } from '../commands/openSettings'; import { switchWorkspace } from '../commands/switchWorkspace'; import { useActiveCookieJar } from '../hooks/useActiveCookieJar'; @@ -130,7 +130,7 @@ export function CommandPaletteDialog({ onClose }: { onClose: () => void }) { { key: 'environment.create', label: 'Create Environment', - onSelect: () => createEnvironmentAndActivate.mutate(baseEnvironment), + onSelect: () => createSubEnvironmentAndActivate.mutate(baseEnvironment), }, { key: 'sidebar.toggle', diff --git a/src-web/components/EnvironmentEditDialog.tsx b/src-web/components/EnvironmentEditDialog.tsx index 8ba940f4..e9a5379e 100644 --- a/src-web/components/EnvironmentEditDialog.tsx +++ b/src-web/components/EnvironmentEditDialog.tsx @@ -3,7 +3,7 @@ import { duplicateModel, patchModel } from '@yaakapp-internal/models'; import classNames from 'classnames'; import type { ReactNode } from 'react'; import React, { useCallback, useState } from 'react'; -import { createEnvironmentAndActivate } from '../commands/createEnvironment'; +import { createSubEnvironmentAndActivate } from '../commands/createEnvironment'; import { useEnvironmentsBreakdown } from '../hooks/useEnvironmentsBreakdown'; import { deleteModelWithConfirm } from '../lib/deleteModelWithConfirm'; import { isBaseEnvironment } from '../lib/model_util'; @@ -42,7 +42,7 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) { const handleCreateEnvironment = async () => { if (baseEnvironment == null) return; - const id = await createEnvironmentAndActivate.mutateAsync(baseEnvironment); + const id = await createSubEnvironmentAndActivate.mutateAsync(baseEnvironment); if (id != null) setSelectedEnvironmentId(id); }; diff --git a/src-web/main.css b/src-web/main.css index d4b8a00d..a69ef254 100644 --- a/src-web/main.css +++ b/src-web/main.css @@ -48,10 +48,6 @@ } } - .select-all * { - /*@apply select-all;*/ - } - a, a[href] * { @apply cursor-pointer !important;