Showing the changes to apps/web/src/components/pullRequest/pullRequestProjectAssignment.logic.ts (1 of 32 files). Show all
Unified · Split
| @@ -1,4 +1,4 @@ | ||
| 1 | −import type { EnvironmentId, ProjectId } from "@t3tools/contracts"; | |
| 1 | +import type { EnvironmentId, EnvironmentMachineKind, ProjectId } from "@t3tools/contracts"; | |
| 2 | 2 | |
| 3 | 3 | /** The little of a project this needs: who holds it, and which repository it is a copy of. */ |
| 4 | 4 | export interface AssignableProject { |
| @@ -69,6 +69,7 @@ export interface PickableEnvironment { · 64 unmodified lines | ||
| 69 | 69 | readonly projectId: ProjectId; |
| 70 | 70 | readonly workspaceRoot: string; |
| 71 | 71 | readonly label: string; |
| 72 | + readonly machine?: EnvironmentMachineKind; | |
| 72 | 73 | } |
| 73 | 74 | |
| 74 | 75 | /** |
| @@ -85,17 +86,21 @@ export interface PickableEnvironment { · 10 unmodified lines | ||
| 85 | 86 | export function resolvePickableEnvironments( |
| 86 | 87 | current: { readonly environmentId: EnvironmentId; readonly projectId: ProjectId }, |
| 87 | 88 | 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 | + }>, | |
| 89 | 94 | ): ReadonlyArray<PickableEnvironment> { |
| 90 | 95 | const own = projects.find( |
| 91 | 96 | (project) => |
| 92 | 97 | project.environmentId === current.environmentId && project.id === current.projectId, |
| 93 | 98 | ); |
| 94 | 99 | const key = own === undefined ? undefined : repositoryKey(own); |
| 95 | − const ownLabel = environments.find( | |
| 100 | + const ownEnvironment = environments.find( | |
| 96 | 101 | (environment) => environment.environmentId === current.environmentId, |
| 97 | − )?.label; | |
| 98 | − if (own === undefined || !key || ownLabel === undefined) return []; | |
| 102 | + ); | |
| 103 | + if (own === undefined || !key || ownEnvironment === undefined) return []; | |
| 99 | 104 | const others = environments.flatMap((environment) => { |
| 100 | 105 | if (environment.environmentId === current.environmentId) return []; |
| 101 | 106 | // 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 | ||
| 112 | 117 | projectId: copy.id, |
| 113 | 118 | workspaceRoot: copy.workspaceRoot, |
| 114 | 119 | label: environment.label, |
| 120 | + ...(environment.machine === undefined ? {} : { machine: environment.machine }), | |
| 115 | 121 | }, |
| 116 | 122 | ]; |
| 117 | 123 | }); |
| @@ -123,7 +129,8 @@ export function resolvePickableEnvironments( · 5 unmodified lines | ||
| 123 | 129 | environmentId: current.environmentId, |
| 124 | 130 | projectId: own.id, |
| 125 | 131 | workspaceRoot: own.workspaceRoot, |
| 126 | − label: ownLabel, | |
| 132 | + label: ownEnvironment.label, | |
| 133 | + ...(ownEnvironment.machine === undefined ? {} : { machine: ownEnvironment.machine }), | |
| 127 | 134 | }, |
| 128 | 135 | ...others, |
| 129 | 136 | ]; |