Skip to content

Commit cd7d915

Browse files
committed
Show tracking branch hint for the preview env too
1 parent 588dda4 commit cd7d915

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class DeploymentListPresenter {
5959
connectedGithubRepository: {
6060
select: {
6161
branchTracking: true,
62+
previewDeploymentsEnabled: true,
6263
repository: {
6364
select: {
6465
htmlUrl: true,

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.deployments/route.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,14 @@ export default function Page() {
138138
BranchTrackingConfigSchema.safeParse(connectedGithubRepository.branchTracking);
139139
const environmentGitHubBranch =
140140
branchTrackingOrError && branchTrackingOrError.success
141-
? getTrackedBranchForEnvironment(branchTrackingOrError.data, environment.type)
141+
? getTrackedBranchForEnvironment(
142+
branchTrackingOrError.data,
143+
connectedGithubRepository.previewDeploymentsEnabled,
144+
{
145+
type: environment.type,
146+
branchName: environment.branchName ?? undefined,
147+
}
148+
)
142149
: undefined;
143150
const hasDeployments = totalPages > 0;
144151

@@ -309,7 +316,7 @@ export default function Page() {
309316
)}
310317
>
311318
{connectedGithubRepository && environmentGitHubBranch && (
312-
<div className="flex flex-nowrap items-center gap-2 whitespace-nowrap py-0.5 text-sm">
319+
<div className="flex flex-nowrap items-center gap-2 whitespace-nowrap text-sm">
313320
<OctoKitty className="size-4" />
314321
Automatically triggered by pushes to{" "}
315322
<div className="flex max-w-32 items-center gap-1 truncate rounded bg-grid-dimmed px-1 font-mono">

apps/webapp/app/v3/github.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@ export type BranchTrackingConfig = z.infer<typeof BranchTrackingConfigSchema>;
1313

1414
export function getTrackedBranchForEnvironment(
1515
branchTracking: BranchTrackingConfig | undefined,
16-
environmentType: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW"
16+
previewDeploymentsEnabled: boolean,
17+
environment: {
18+
type: "PRODUCTION" | "STAGING" | "DEVELOPMENT" | "PREVIEW";
19+
branchName?: string;
20+
}
1721
): string | undefined {
1822
if (!branchTracking) return undefined;
19-
switch (environmentType) {
23+
switch (environment.type) {
2024
case "PRODUCTION":
2125
return branchTracking.prod?.branch;
2226
case "STAGING":
2327
return branchTracking.staging?.branch;
24-
default:
28+
case "PREVIEW":
29+
return previewDeploymentsEnabled ? environment.branchName : undefined;
30+
case "DEVELOPMENT":
2531
return undefined;
32+
default:
33+
return environment.type satisfies never;
2634
}
2735
}

0 commit comments

Comments
 (0)