Use model labels in import preview

This commit is contained in:
Gregory Schier
2026-08-17 08:30:30 -07:00
parent f4d9e3f784
commit d48c1b7a79
@@ -1,4 +1,10 @@
import type { Folder, ImportDestination, ImportPlan, Workspace } from "@yaakapp-internal/models"; import {
type Folder,
type ImportDestination,
type ImportPlan,
modelTypeLabel,
type Workspace,
} from "@yaakapp-internal/models";
import { HStack, Icon, VStack } from "@yaakapp-internal/ui"; import { HStack, Icon, VStack } from "@yaakapp-internal/ui";
import { platform } from "@yaakapp-internal/platform"; import { platform } from "@yaakapp-internal/platform";
import classNames from "classnames"; import classNames from "classnames";
@@ -135,12 +141,12 @@ export function ImportDataDialog({
if (plan != null) { if (plan != null) {
const counts = [ const counts = [
["Workspace", plan.resources.workspaces.length], [plan.resources.workspaces[0]?.resource, plan.resources.workspaces.length],
["Environment", plan.resources.environments.length], [plan.resources.environments[0]?.resource, plan.resources.environments.length],
["Folder", plan.resources.folders.length], [plan.resources.folders[0]?.resource, plan.resources.folders.length],
["HTTP Request", plan.resources.httpRequests.length], [plan.resources.httpRequests[0]?.resource, plan.resources.httpRequests.length],
["gRPC Request", plan.resources.grpcRequests.length], [plan.resources.grpcRequests[0]?.resource, plan.resources.grpcRequests.length],
["WebSocket Request", plan.resources.websocketRequests.length], [plan.resources.websocketRequests[0]?.resource, plan.resources.websocketRequests.length],
] as const; ] as const;
const destinationLabel = const destinationLabel =
plan.destination.type === "new_workspace" plan.destination.type === "new_workspace"
@@ -159,11 +165,11 @@ export function ImportDataDialog({
<div> <div>
<div className="text-sm font-semibold mb-1">Resources</div> <div className="text-sm font-semibold mb-1">Resources</div>
<ul className="list-disc pl-6 text-sm text-text-subtle"> <ul className="list-disc pl-6 text-sm text-text-subtle">
{counts {counts.map(([model, count]) =>
.filter(([, count]) => count > 0) model == null ? null : (
.map(([label, count]) => ( <li key={model.model}>{pluralizeCount(modelTypeLabel(model), count)}</li>
<li key={label}>{pluralizeCount(label, count)}</li> ),
))} )}
</ul> </ul>
</div> </div>