feat(environments): draw each environment as the machine it runs on (#9299)
Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
32 files changed
+1222
-84
No files matched your search
@@ -1,13 +1,14 @@
|
||||
import { scopedThreadKey, scopeProjectRef } from "@t3tools/client-runtime/environment";
|
||||
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
|
||||
import type {
|
||||
EnvironmentId,
|
||||
PullRequestAction,
|
||||
PullRequestMergeMethod,
|
||||
PullRequestUpdateMethod,
|
||||
PullRequestRef,
|
||||
PullRequestState,
|
||||
ScopedThreadRef,
|
||||
import {
|
||||
type EnvironmentId,
|
||||
type PullRequestAction,
|
||||
type PullRequestMergeMethod,
|
||||
type PullRequestUpdateMethod,
|
||||
type PullRequestRef,
|
||||
type PullRequestState,
|
||||
resolveEnvironmentMachineKind,
|
||||
type ScopedThreadRef,
|
||||
} from "@t3tools/contracts";
|
||||
import {
|
||||
ArrowDownUpIcon,
|
||||
@@ -36,7 +37,6 @@ import {
|
||||
PlayIcon,
|
||||
RefreshCwIcon,
|
||||
RotateCcwIcon,
|
||||
ServerIcon,
|
||||
TriangleAlertIcon,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
@@ -77,6 +77,7 @@ import {
|
||||
AlertDialogPopup,
|
||||
AlertDialogTitle,
|
||||
} from "../ui/alert-dialog";
|
||||
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
|
||||
import { Badge } from "../ui/badge";
|
||||
import { Button } from "../ui/button";
|
||||
import { Input } from "../ui/input";
|
||||
@@ -272,7 +273,10 @@ function ActOnEnvironmentPicker({
|
||||
{/* The radio item lays its children out as one block, so the icon and the label
|
||||
need their own row to share a line. */}
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<ServerIcon className="size-3.5 shrink-0" />
|
||||
<EnvironmentMachineIcon
|
||||
kind={environment.machine ?? "server"}
|
||||
className="size-3.5 shrink-0"
|
||||
/>
|
||||
<span className="truncate">{environment.label}</span>
|
||||
</span>
|
||||
</MenuRadioItem>
|
||||
@@ -729,7 +733,11 @@ export function PullRequestDetailPanel({
|
||||
? resolvePickableEnvironments(
|
||||
{ environmentId, projectId: reference.projectId },
|
||||
projects,
|
||||
environments,
|
||||
environments.map((environment) => ({
|
||||
environmentId: environment.environmentId,
|
||||
label: environment.label,
|
||||
machine: resolveEnvironmentMachineKind(environment.serverConfig),
|
||||
})),
|
||||
)
|
||||
: [],
|
||||
[context, environmentId, environments, projects, reference.projectId],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { EnvironmentId, ProjectId } from "@t3tools/contracts";
|
||||
import type { EnvironmentId, EnvironmentMachineKind, ProjectId } from "@t3tools/contracts";
|
||||
|
||||
/** The little of a project this needs: who holds it, and which repository it is a copy of. */
|
||||
export interface AssignableProject {
|
||||
@@ -69,6 +69,7 @@ export interface PickableEnvironment {
|
||||
readonly projectId: ProjectId;
|
||||
readonly workspaceRoot: string;
|
||||
readonly label: string;
|
||||
readonly machine?: EnvironmentMachineKind;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,17 +86,21 @@ export interface PickableEnvironment {
|
||||
export function resolvePickableEnvironments(
|
||||
current: { readonly environmentId: EnvironmentId; readonly projectId: ProjectId },
|
||||
projects: ReadonlyArray<AssignableProject & { readonly workspaceRoot: string }>,
|
||||
environments: ReadonlyArray<{ readonly environmentId: EnvironmentId; readonly label: string }>,
|
||||
environments: ReadonlyArray<{
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly label: string;
|
||||
readonly machine?: EnvironmentMachineKind;
|
||||
}>,
|
||||
): ReadonlyArray<PickableEnvironment> {
|
||||
const own = projects.find(
|
||||
(project) =>
|
||||
project.environmentId === current.environmentId && project.id === current.projectId,
|
||||
);
|
||||
const key = own === undefined ? undefined : repositoryKey(own);
|
||||
const ownLabel = environments.find(
|
||||
const ownEnvironment = environments.find(
|
||||
(environment) => environment.environmentId === current.environmentId,
|
||||
)?.label;
|
||||
if (own === undefined || !key || ownLabel === undefined) return [];
|
||||
);
|
||||
if (own === undefined || !key || ownEnvironment === undefined) return [];
|
||||
const others = environments.flatMap((environment) => {
|
||||
if (environment.environmentId === current.environmentId) return [];
|
||||
// One entry per server, whichever copy comes first: a server holding two worktrees of the
|
||||
@@ -112,6 +117,7 @@ export function resolvePickableEnvironments(
|
||||
projectId: copy.id,
|
||||
workspaceRoot: copy.workspaceRoot,
|
||||
label: environment.label,
|
||||
...(environment.machine === undefined ? {} : { machine: environment.machine }),
|
||||
},
|
||||
];
|
||||
});
|
||||
@@ -123,7 +129,8 @@ export function resolvePickableEnvironments(
|
||||
environmentId: current.environmentId,
|
||||
projectId: own.id,
|
||||
workspaceRoot: own.workspaceRoot,
|
||||
label: ownLabel,
|
||||
label: ownEnvironment.label,
|
||||
...(ownEnvironment.machine === undefined ? {} : { machine: ownEnvironment.machine }),
|
||||
},
|
||||
...others,
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user