Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8432261
Fix settigns page delete project width issue
myftija Aug 29, 2025
1cf4e5e
Apply a couple of touch-ups to the project settings page
myftija Aug 29, 2025
1b82824
Add UI flow to connect gh repos
myftija Sep 1, 2025
829cdd6
Enabling adding another gh account in the ui
myftija Sep 1, 2025
68669e4
Enable connecting a repo to a project
myftija Sep 1, 2025
9091420
Enable updating git settings
myftija Sep 2, 2025
b7278fc
Enable disconnecting gh repos from a project
myftija Sep 2, 2025
3fc7fd5
Remove prisma migration drifts
myftija Sep 2, 2025
0aa1c5f
Hide git settings when github app is disabled
myftija Sep 2, 2025
03fab55
Fix migration order
myftija Sep 2, 2025
69df7db
Avoid using `location` to avoid SSR issues
myftija Sep 3, 2025
c462546
Make branch tracking optional
myftija Sep 3, 2025
344d33b
Disable save buttons when there are no field changes
myftija Sep 3, 2025
6d3fda0
Disable delete project button unless the input matches the project slug
myftija Sep 3, 2025
2428ce0
Show connected repo connectedAt date
myftija Sep 3, 2025
e6f8f65
Check that tracking branch exists when updating git settings
myftija Sep 3, 2025
81ca16c
Show tracking branch hint in the deployments page
myftija Sep 3, 2025
86a98e2
Fix positioning issue of the pagination pane in the deployments page
myftija Sep 3, 2025
d5aa38d
Use mono font for branch names
myftija Sep 3, 2025
588dda4
Add link to git settings
myftija Sep 3, 2025
cd7d915
Show tracking branch hint for the preview env too
myftija Sep 3, 2025
7e9dff3
Add a confirmation prompt on repo disconnect
myftija Sep 3, 2025
c74f1c8
Add link to configure repo access in gh
myftija Sep 3, 2025
86506d9
Add rel prop to github links
myftija Sep 3, 2025
9171eff
Automatically open repo connection modal after app installation
myftija Sep 3, 2025
994014c
Apply some fixes suggested by mr rabbit
myftija Sep 3, 2025
4a0c234
Fix flash cookie issue
myftija Sep 3, 2025
0ac6722
Extract project settings actions into a service
myftija Sep 5, 2025
0002bd6
Extract project settings loader into a presenter service
myftija Sep 5, 2025
9a27e59
Introduce neverthrow for error handling
myftija Sep 5, 2025
190830b
Try out neverthrow for error handling in the project setting flows
myftija Sep 5, 2025
269cf9c
Move env gh branch resolution to the presenter service
myftija Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion apps/webapp/app/presenters/v3/DeploymentListPresenter.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Prisma,
type Prisma,
type WorkerDeploymentStatus,
type WorkerInstanceGroupType,
} from "@trigger.dev/database";
Expand All @@ -9,6 +9,7 @@ import { type Project } from "~/models/project.server";
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
import { type User } from "~/models/user.server";
import { processGitMetadata } from "./BranchesPresenter.server";
import { BranchTrackingConfigSchema, getTrackedBranchForEnvironment } from "~/v3/github";

const pageSize = 20;

Expand Down Expand Up @@ -56,6 +57,18 @@ export class DeploymentListPresenter {
},
},
},
connectedGithubRepository: {
select: {
branchTracking: true,
previewDeploymentsEnabled: true,
repository: {
select: {
htmlUrl: true,
fullName: true,
},
},
},
},
},
where: {
slug: projectSlug,
Expand Down Expand Up @@ -140,9 +153,28 @@ ORDER BY
string_to_array(wd."version", '.')::int[] DESC
LIMIT ${pageSize} OFFSET ${pageSize * (page - 1)};`;

const { connectedGithubRepository } = project;

const branchTrackingOrError =
connectedGithubRepository &&
BranchTrackingConfigSchema.safeParse(connectedGithubRepository.branchTracking);
const environmentGitHubBranch =
branchTrackingOrError && branchTrackingOrError.success
? getTrackedBranchForEnvironment(
branchTrackingOrError.data,
connectedGithubRepository.previewDeploymentsEnabled,
{
type: environment.type,
branchName: environment.branchName ?? undefined,
}
)
: undefined;

return {
currentPage: page,
totalPages: Math.ceil(totalCount / pageSize),
connectedGithubRepository: project.connectedGithubRepository ?? undefined,
environmentGitHubBranch,
deployments: deployments.map((deployment, index) => {
const label = labeledDeployments.find(
(labeledDeployment) => labeledDeployment.deploymentId === deployment.id
Expand Down
34 changes: 29 additions & 5 deletions apps/webapp/app/routes/_app.github.callback/route.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { type LoaderFunctionArgs } from "@remix-run/node";
import { type LoaderFunctionArgs, redirect } from "@remix-run/node";
import { z } from "zod";
import { validateGitHubAppInstallSession } from "~/services/gitHubSession.server";
import { linkGitHubAppInstallation, updateGitHubAppInstallation } from "~/services/gitHub.server";
import { logger } from "~/services/logger.server";
import { redirectWithErrorMessage, redirectWithSuccessMessage } from "~/models/message.server";
import {
redirectWithErrorMessage,
setRequestSuccessMessage,
commitSession,
} from "~/models/message.server";
import { tryCatch } from "@trigger.dev/core";
import { $replica } from "~/db.server";
import { requireUser } from "~/services/session.server";
Expand Down Expand Up @@ -88,7 +92,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
return redirectWithErrorMessage(redirectTo, request, "Failed to install GitHub App");
}

return redirectWithSuccessMessage(redirectTo, request, "GitHub App installed successfully");
const session = await setRequestSuccessMessage(request, "GitHub App installed successfully");
session.flash("gitHubAppInstalled", true);

return redirect(redirectTo, {
headers: {
"Set-Cookie": await commitSession(session),
},
});
}

case "update": {
Expand All @@ -101,7 +112,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
return redirectWithErrorMessage(redirectTo, request, "Failed to update GitHub App");
}

return redirectWithSuccessMessage(redirectTo, request, "GitHub App updated successfully");
const session = await setRequestSuccessMessage(request, "GitHub App updated successfully");
session.flash("gitHubAppInstalled", true);

return redirect(redirectTo, {
headers: {
"Set-Cookie": await commitSession(session),
},
});
}

case "request": {
Expand All @@ -111,7 +129,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
callbackData,
});

return redirectWithSuccessMessage(redirectTo, request, "GitHub App installation requested");
const session = await setRequestSuccessMessage(request, "GitHub App installation requested");

return redirect(redirectTo, {
headers: {
"Set-Cookie": await commitSession(session),
},
});
}

default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ArrowUturnLeftIcon, BookOpenIcon } from "@heroicons/react/20/solid";
import { type MetaFunction, Outlet, useLocation, useNavigate, useParams } from "@remix-run/react";
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
import { CogIcon, GitBranchIcon } from "lucide-react";
import { useEffect } from "react";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
import { z } from "zod";
import { PromoteIcon } from "~/assets/icons/PromoteIcon";
import { DeploymentsNone, DeploymentsNoneDev } from "~/components/BlankStatePanels";
import { OctoKitty } from "~/components/GitHubLoginButton";
import { GitMetadata } from "~/components/GitMetadata";
import { RuntimeIcon } from "~/components/RuntimeIcon";
import { UserAvatar } from "~/components/UserProfilePhoto";
Expand Down Expand Up @@ -50,7 +52,13 @@ import {
} from "~/presenters/v3/DeploymentListPresenter.server";
import { requireUserId } from "~/services/session.server";
import { titleCase } from "~/utils";
import { EnvironmentParamSchema, docsPath, v3DeploymentPath } from "~/utils/pathBuilder";
import { cn } from "~/utils/cn";
import {
EnvironmentParamSchema,
docsPath,
v3DeploymentPath,
v3ProjectSettingsPath,
} from "~/utils/pathBuilder";
import { createSearchParams } from "~/utils/searchParams";
import { compareDeploymentVersions } from "~/v3/utils/deploymentVersions";

Expand Down Expand Up @@ -122,8 +130,14 @@ export default function Page() {
const organization = useOrganization();
const project = useProject();
const environment = useEnvironment();
const { deployments, currentPage, totalPages, selectedDeployment } =
useTypedLoaderData<typeof loader>();
const {
deployments,
currentPage,
totalPages,
selectedDeployment,
connectedGithubRepository,
environmentGitHubBranch,
} = useTypedLoaderData<typeof loader>();
const hasDeployments = totalPages > 0;

const { deploymentParam } = useParams();
Expand Down Expand Up @@ -160,8 +174,8 @@ export default function Page() {
<ResizablePanelGroup orientation="horizontal" className="h-full max-h-full">
<ResizablePanel id="deployments-main" min="100px" className="max-h-full">
{hasDeployments ? (
<div className="grid max-h-full grid-rows-[1fr_auto]">
<Table containerClassName="border-t-0">
<div className="flex h-full max-h-full flex-col">
<Table containerClassName="border-t-0 grow">
<TableHeader>
<TableRow>
<TableHeaderCell>Deploy</TableHeaderCell>
Expand Down Expand Up @@ -286,11 +300,38 @@ export default function Page() {
)}
</TableBody>
</Table>
{totalPages > 1 && (
<div className="-mt-px flex justify-end border-t border-grid-dimmed py-2 pr-2">
<PaginationControls currentPage={currentPage} totalPages={totalPages} />
</div>
)}
<div
className={cn(
"-mt-px flex flex-wrap justify-end gap-2 border-t border-grid-dimmed px-3 pb-[7px] pt-[6px]",
connectedGithubRepository && environmentGitHubBranch && "justify-between"
)}
>
{connectedGithubRepository && environmentGitHubBranch && (
<div className="flex flex-nowrap items-center gap-2 whitespace-nowrap text-sm">
<OctoKitty className="size-4" />
Automatically triggered by pushes to{" "}
<div className="flex max-w-32 items-center gap-1 truncate rounded bg-grid-dimmed px-1 font-mono">
<GitBranchIcon className="size-3 shrink-0" />
<span className="max-w-28 truncate">{environmentGitHubBranch}</span>
</div>{" "}
in
<a
href={connectedGithubRepository.repository.htmlUrl}
target="_blank"
rel="noreferrer noopener"
className="max-w-52 truncate text-sm text-text-dimmed underline transition-colors hover:text-text-bright"
>
{connectedGithubRepository.repository.fullName}
</a>
<LinkButton
variant="minimal/small"
LeadingIcon={CogIcon}
to={v3ProjectSettingsPath(organization, project, environment)}
/>
</div>
)}
<PaginationControls currentPage={currentPage} totalPages={totalPages} />
</div>
</div>
) : environment.type === "DEVELOPMENT" ? (
<MainCenteredContainer className="max-w-md">
Expand Down
Loading
Loading