mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-25 21:04:04 +02:00
Use model labels in import preview
This commit is contained in:
@@ -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>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user