Skip to content

Commit 8f78f66

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/tier-scheduling
2 parents 2e402fe + f767654 commit 8f78f66

File tree

16 files changed

+1254
-150
lines changed

16 files changed

+1254
-150
lines changed

apps/webapp/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ build-storybook.log
1818
storybook-static
1919

2020
/prisma/seed.js
21-
/prisma/populate.js
21+
/prisma/populate.js
22+
.memory-snapshots

apps/webapp/app/components/code/CodeBlock.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ const defaultTheme: PrismTheme = {
8686
},
8787
},
8888
{
89-
types: ["property", "tag", "boolean", "number", "constant", "symbol", "deleted"],
89+
types: ["property", "tag", "constant", "symbol", "deleted"],
9090
style: {
9191
color: "#9B99FF",
9292
},
9393
},
94+
{
95+
types: ["boolean", "number"],
96+
style: {
97+
color: "#E5C07B",
98+
},
99+
},
94100
{
95101
types: ["selector", "attr-name", "string", "char", "builtin", "inserted"],
96102
style: {
@@ -151,12 +157,6 @@ const defaultTheme: PrismTheme = {
151157
color: "#F85149",
152158
},
153159
},
154-
{
155-
types: ["boolean"],
156-
style: {
157-
color: "#9B99FF",
158-
},
159-
},
160160
{
161161
types: ["char"],
162162
style: {

apps/webapp/app/components/code/codeMirrorTheme.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export function darkTheme(): Extension {
1111
ivory = "#abb2bf",
1212
stone = "#7d8799",
1313
malibu = "#61afef",
14-
sage = "#98c379",
14+
sage = "#afec73",
1515
whiskey = "#d19a66",
1616
violet = "#c678dd",
17+
lilac = "#9b99ff",
1718
darkBackground = "#21252b",
1819
highlightBackground = "rgba(71,85,105,0.2)",
1920
background = "#121317",
@@ -173,7 +174,7 @@ export function darkTheme(): Extension {
173174
{ tag: tags.keyword, color: violet },
174175
{
175176
tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
176-
color: coral,
177+
color: lilac,
177178
},
178179
{ tag: [tags.function(tags.variableName), tags.labelName], color: malibu },
179180
{
@@ -186,6 +187,7 @@ export function darkTheme(): Extension {
186187
tags.typeName,
187188
tags.className,
188189
tags.number,
190+
tags.bool,
189191
tags.changed,
190192
tags.annotation,
191193
tags.modifier,
@@ -213,7 +215,7 @@ export function darkTheme(): Extension {
213215
{ tag: tags.link, color: stone, textDecoration: "underline" },
214216
{ tag: tags.heading, fontWeight: "bold", color: coral },
215217
{
216-
tag: [tags.atom, tags.bool, tags.special(tags.variableName)],
218+
tag: [tags.atom, tags.special(tags.variableName)],
217219
color: whiskey,
218220
},
219221
{

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GitMeta } from "@trigger.dev/core/v3";
22
import { type z } from "zod";
3-
import { Prisma, type PrismaClient, prisma } from "~/db.server";
3+
import { type Prisma, type PrismaClient, prisma } from "~/db.server";
44
import { type Project } from "~/models/project.server";
55
import { type User } from "~/models/user.server";
66
import { type BranchesOptions } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.branches/route";
@@ -38,6 +38,13 @@ export type GitMetaLinks = {
3838
commitMessage: string;
3939
/** The commit author */
4040
commitAuthor: string;
41+
42+
/** The git provider, e.g., `github` */
43+
provider?: string;
44+
45+
source?: "trigger_github_app" | "github_actions" | "local";
46+
ghUsername?: string;
47+
ghUserAvatarUrl?: string;
4148
};
4249

4350
export class BranchesPresenter {
@@ -239,5 +246,9 @@ export function processGitMetadata(data: Prisma.JsonValue): GitMetaLinks | null
239246
isDirty: parsed.data.dirty ?? false,
240247
commitMessage: parsed.data.commitMessage ?? "",
241248
commitAuthor: parsed.data.commitAuthorName ?? "",
249+
provider: parsed.data.provider,
250+
source: parsed.data.source,
251+
ghUsername: parsed.data.ghUsername,
252+
ghUserAvatarUrl: parsed.data.ghUserAvatarUrl,
242253
};
243254
}

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,20 @@ export default function Page() {
245245
)}
246246
</TableCell>
247247
<TableCell to={path} isSelected={isSelected}>
248-
{deployment.deployedBy ? (
249-
<div className="flex items-center gap-1">
250-
<UserAvatar
251-
avatarUrl={deployment.deployedBy.avatarUrl}
252-
name={
253-
deployment.deployedBy.name ??
254-
deployment.deployedBy.displayName
255-
}
256-
className="h-4 w-4"
257-
/>
258-
<Paragraph variant="extra-small">
259-
{deployment.deployedBy.name ??
260-
deployment.deployedBy.displayName}
261-
</Paragraph>
262-
</div>
248+
{deployment.git?.source === "trigger_github_app" ? (
249+
<UserTag
250+
name={deployment.git.ghUsername ?? "GitHub Integration"}
251+
avatarUrl={deployment.git.ghUserAvatarUrl}
252+
/>
253+
) : deployment.deployedBy ? (
254+
<UserTag
255+
name={
256+
deployment.deployedBy.name ??
257+
deployment.deployedBy.displayName ??
258+
""
259+
}
260+
avatarUrl={deployment.deployedBy.avatarUrl ?? undefined}
261+
/>
263262
) : (
264263
"–"
265264
)}
@@ -318,6 +317,15 @@ export default function Page() {
318317
);
319318
}
320319

320+
function UserTag({ name, avatarUrl }: { name: string; avatarUrl?: string }) {
321+
return (
322+
<div className="flex items-center gap-1">
323+
<UserAvatar avatarUrl={avatarUrl} name={name} className="h-4 w-4" />
324+
<Paragraph variant="extra-small">{name}</Paragraph>
325+
</div>
326+
);
327+
}
328+
321329
function DeploymentActionsCell({
322330
deployment,
323331
path,

apps/webapp/app/routes/admin.api.v1.gc.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { type DataFunctionArgs } from "@remix-run/node";
22
import { PerformanceObserver } from "node:perf_hooks";
33
import { runInNewContext } from "node:vm";
44
import v8 from "v8";
5-
import { requireUser } from "~/services/session.server";
5+
import { prisma } from "~/db.server";
6+
import { authenticateApiRequestWithPersonalAccessToken } from "~/services/personalAccessToken.server";
67

78
async function waitTillGcFinishes() {
89
let resolver: (value: PerformanceEntry) => void;
@@ -35,9 +36,19 @@ async function waitTillGcFinishes() {
3536
}
3637

3738
export async function loader({ request }: DataFunctionArgs) {
38-
const user = await requireUser(request);
39+
const authenticationResult = await authenticateApiRequestWithPersonalAccessToken(request);
3940

40-
if (!user.admin) {
41+
if (!authenticationResult) {
42+
throw new Response("You must be an admin to perform this action", { status: 403 });
43+
}
44+
45+
const user = await prisma.user.findFirst({
46+
where: {
47+
id: authenticationResult.userId,
48+
},
49+
});
50+
51+
if (!user?.admin) {
4152
throw new Response("You must be an admin to perform this action", { status: 403 });
4253
}
4354

apps/webapp/app/routes/admin.api.v1.snapshot.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import os from "os";
44
import path from "path";
55
import { PassThrough } from "stream";
66
import v8 from "v8";
7-
import { requireUser } from "~/services/session.server";
7+
import { prisma } from "~/db.server";
8+
import { authenticateApiRequestWithPersonalAccessToken } from "~/services/personalAccessToken.server";
89

910
// Format date as yyyy-MM-dd HH_mm_ss_SSS
1011
function formatDate(date: Date) {
@@ -24,9 +25,19 @@ function formatDate(date: Date) {
2425
}
2526

2627
export async function loader({ request }: DataFunctionArgs) {
27-
const user = await requireUser(request);
28+
const authenticationResult = await authenticateApiRequestWithPersonalAccessToken(request);
2829

29-
if (!user.admin) {
30+
if (!authenticationResult) {
31+
throw new Response("You must be an admin to perform this action", { status: 403 });
32+
}
33+
34+
const user = await prisma.user.findFirst({
35+
where: {
36+
id: authenticationResult.userId,
37+
},
38+
});
39+
40+
if (!user?.admin) {
3041
throw new Response("You must be an admin to perform this action", { status: 403 });
3142
}
3243

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ActionFunctionArgs } from "@remix-run/server-runtime";
2+
3+
export async function action({ request }: ActionFunctionArgs) {
4+
if (process.env.NODE_ENV === "production") {
5+
return new Response("Not found", { status: 404 });
6+
}
7+
8+
return new Response(
9+
JSON.stringify({
10+
data: {
11+
id: "123",
12+
type: "mock",
13+
attributes: {
14+
name: "Mock",
15+
},
16+
},
17+
}),
18+
{ status: 200 }
19+
);
20+
}

0 commit comments

Comments
 (0)