History

feat(environments): draw each environment as the machine it runs on (#9299)

Julius Marminge committed 2 months ago

Commit 0fbb9421 parent d89764132 files · +1222 −84Browse files

Showing the changes to apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts (1 of 32 files). Show all

Unified · Split

apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts+13−6
@@ -1,4 +1,4 @@
1−import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
1+import type { EnvironmentId, EnvironmentMachineKind, ProjectId } from "@t3tools/contracts";
22
33 /** The little of a project this needs: who holds it, and which repository it is a copy of. */
44 export interface AssignableProject {
@@ -69,6 +69,7 @@ export interface PickableEnvironment { · 64 unmodified lines
6969 readonly projectId: ProjectId;
7070 readonly workspaceRoot: string;
7171 readonly label: string;
72+ readonly machine?: EnvironmentMachineKind;
7273 }
7374
7475 /**
@@ -85,17 +86,21 @@ export interface PickableEnvironment { · 10 unmodified lines
8586 export function resolvePickableEnvironments(
8687 current: { readonly environmentId: EnvironmentId; readonly projectId: ProjectId },
8788 projects: ReadonlyArray<AssignableProject & { readonly workspaceRoot: string }>,
88− environments: ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string }>,
89+ environments: ReadonlyArray<{
90+ readonly environmentId: EnvironmentId;
91+ readonly label: string;
92+ readonly machine?: EnvironmentMachineKind;
93+ }>,
8994 ): ReadonlyArray<PickableEnvironment> {
9095 const own = projects.find(
9196 (project) =>
9297 project.environmentId === current.environmentId && project.id === current.projectId,
9398 );
9499 const key = own === undefined ? undefined : repositoryKey(own);
95− const ownLabel = environments.find(
100+ const ownEnvironment = environments.find(
96101 (environment) => environment.environmentId === current.environmentId,
97− )?.label;
98− if (own === undefined || !key || ownLabel === undefined) return [];
102+ );
103+ if (own === undefined || !key || ownEnvironment === undefined) return [];
99104 const others = environments.flatMap((environment) => {
100105 if (environment.environmentId === current.environmentId) return [];
101106 // One entry per server, whichever copy comes first: a server holding two worktrees of the
@@ -112,6 +117,7 @@ export function resolvePickableEnvironments( · 10 unmodified lines
112117 projectId: copy.id,
113118 workspaceRoot: copy.workspaceRoot,
114119 label: environment.label,
120+ ...(environment.machine === undefined ? {} : { machine: environment.machine }),
115121 },
116122 ];
117123 });
@@ -123,7 +129,8 @@ export function resolvePickableEnvironments( · 5 unmodified lines
123129 environmentId: current.environmentId,
124130 projectId: own.id,
125131 workspaceRoot: own.workspaceRoot,
126− label: ownLabel,
132+ label: ownEnvironment.label,
133+ ...(ownEnvironment.machine === undefined ? {} : { machine: ownEnvironment.machine }),
127134 },
128135 ...others,
129136 ];