From a3e6afcdc95fa258de1c037a11b554c34aa8d2a4 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 8 Sep 2026 08:23:14 -0700 Subject: [PATCH] fix(import): list environments above folders in the preview Sorting put folders first and swept environments in with the requests, so the two environments an OpenAPI import creates landed underneath every folder in the document. Co-Authored-By: Claude Opus 5 --- apps/yaak-client/components/ImportDataDialog.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/yaak-client/components/ImportDataDialog.tsx b/apps/yaak-client/components/ImportDataDialog.tsx index 47c16c7e..0d9264b9 100644 --- a/apps/yaak-client/components/ImportDataDialog.tsx +++ b/apps/yaak-client/components/ImportDataDialog.tsx @@ -684,9 +684,10 @@ function buildItemTree(items: ImportPlanItem[]): CheckboxTreeNode [ + const byKind = (list: ImportPlanItem[]) => [ + ...list.filter((i) => i.model === "environment"), ...list.filter((i) => i.model === "folder"), - ...list.filter((i) => i.model !== "folder"), + ...list.filter((i) => i.model !== "environment" && i.model !== "folder"), ]; const toNode = (item: ImportPlanItem, seen: Set): CheckboxTreeNode => ({ @@ -694,12 +695,12 @@ function buildItemTree(items: ImportPlanItem[]): CheckboxTreeNode + : byKind(childrenOf.get(item.modelId) ?? []).map((c) => toNode(c, new Set([...seen, item.modelId])), ), }); - return foldersFirst(roots).map((r) => toNode(r, new Set())); + return byKind(roots).map((r) => toNode(r, new Set())); } function collectItems(node: CheckboxTreeNode): ImportPlanItem[] {