Skip to content

Commit b746e76

Browse files
authored
Merge branch 'main' into feat/daily-runs-graph
2 parents a27a4a9 + 0b657b3 commit b746e76

34 files changed

Lines changed: 445 additions & 401 deletions

File tree

apps/webapp/app/components/jobs/DeleteJobModalContent.tsx

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
1-
import { RuntimeEnvironmentType } from "@trigger.dev/database";
1+
import { useFetcher } from "@remix-run/react";
2+
import { useEffect } from "react";
3+
import { loader } from "~/routes/resources.jobs.$jobId";
24
import { cn } from "~/utils/cn";
3-
import { JobStatusTable } from "../JobsStatusTable";
5+
import { JobEnvironment, JobStatusTable } from "../JobsStatusTable";
46
import { Button } from "../primitives/Buttons";
57
import { Header1, Header2 } from "../primitives/Headers";
68
import { NamedIcon } from "../primitives/NamedIcon";
79
import { Paragraph } from "../primitives/Paragraph";
8-
import { TextLink } from "../primitives/TextLink";
9-
import { useFetcher } from "@remix-run/react";
1010
import { Spinner } from "../primitives/Spinner";
11+
import { TextLink } from "../primitives/TextLink";
12+
import { useTypedFetcher } from "remix-typedjson";
1113

12-
type JobEnvironment = {
13-
type: RuntimeEnvironmentType;
14-
lastRun?: Date;
15-
version: string;
16-
enabled: boolean;
17-
};
14+
export function DeleteJobDialog({ id, title, slug }: { id: string; title: string; slug: string }) {
15+
const fetcher = useTypedFetcher<typeof loader>();
16+
useEffect(() => {
17+
fetcher.load(`/resources/jobs/${id}`);
18+
}, [id]);
19+
20+
const isLoading = fetcher.state === "loading" || fetcher.state === "submitting";
21+
22+
if (isLoading || !fetcher.data) {
23+
return (
24+
<div className="flex w-full flex-col items-center gap-y-6">
25+
<div className="mt-5 flex flex-col items-center justify-center gap-y-2">
26+
<Header1>{title}</Header1>
27+
<Paragraph variant="small">ID: {slug}</Paragraph>
28+
</div>
29+
<Spinner />
30+
</div>
31+
);
32+
} else {
33+
return (
34+
<DeleteJobDialogContent
35+
id={id}
36+
title={title}
37+
slug={slug}
38+
environments={fetcher.data.environments}
39+
/>
40+
);
41+
}
42+
}
1843

1944
type DeleteJobDialogContentProps = {
2045
id: string;

apps/webapp/app/components/jobs/JobsTable.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from "../primitives/Table";
2323
import { SimpleTooltip } from "../primitives/Tooltip";
2424
import { runStatusTitle } from "../runs/RunStatuses";
25-
import { DeleteJobDialogContent } from "./DeleteJobModalContent";
25+
import { DeleteJobDialog, DeleteJobDialogContent } from "./DeleteJobModalContent";
2626
import { JobStatusBadge } from "./JobStatusBadge";
2727

2828
export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResultsText: string }) {
@@ -49,13 +49,13 @@ export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResul
4949
<TableRow key={job.id} className="group">
5050
<TableCell to={path}>
5151
<span className="flex items-center gap-2">
52-
<NamedIcon name={job.event.icon} className="w-8 h-8" />
52+
<NamedIcon name={job.event.icon} className="h-8 w-8" />
5353
<LabelValueStack
5454
label={job.title}
5555
value={
5656
job.dynamic ? (
5757
<span className="flex items-center gap-0.5">
58-
<NamedIcon name="dynamic" className="w-4 h-4" />{" "}
58+
<NamedIcon name="dynamic" className="h-4 w-4" />{" "}
5959
<span className="uppercase">Dynamic:</span> {job.event.title}
6060
</span>
6161
) : (
@@ -75,9 +75,9 @@ export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResul
7575
key={integration.key}
7676
button={
7777
<div className="relative">
78-
<NamedIcon name={integration.icon} className="w-6 h-6" />
78+
<NamedIcon name={integration.icon} className="h-6 w-6" />
7979
{integration.setupStatus === "MISSING_FIELDS" && (
80-
<NamedIcon name="error" className="absolute w-4 h-4 -left-1 -top-1" />
80+
<NamedIcon name="error" className="absolute -left-1 -top-1 h-4 w-4" />
8181
)}
8282
</div>
8383
}
@@ -165,12 +165,7 @@ export function JobsTable({ jobs, noResultsText }: { jobs: ProjectJob[]; noResul
165165
</DialogTrigger>
166166
<DialogContent>
167167
<DialogHeader>Delete Job</DialogHeader>
168-
<DeleteJobDialogContent
169-
id={job.id}
170-
title={job.title}
171-
slug={job.slug}
172-
environments={job.environments}
173-
/>
168+
<DeleteJobDialog id={job.id} title={job.title} slug={job.slug} />
174169
</DialogContent>
175170
</Dialog>
176171
</TableCellMenu>

apps/webapp/app/components/navigation/PageNavigationIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { cn } from "~/utils/cn";
55
export function PageNavigationIndicator({ className }: { className?: string }) {
66
const navigation = useNavigation();
77
if (navigation.state === "loading") {
8-
return <Spinner color="muted" className={cn("h-4 w-4", className)} />;
8+
return <Spinner color="blue" className={cn("h-4 w-4", className)} />;
99
}
1010
}

apps/webapp/app/components/primitives/PageHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ function PageInfoPropertyContent({
129129
{label && (
130130
<Paragraph variant="extra-small/caps" className="mt-0.5 whitespace-nowrap">
131131
{label}
132-
{value && ":"}
132+
{value !== undefined && ":"}
133133
</Paragraph>
134134
)}
135-
{value && <Paragraph variant="small">{value}</Paragraph>}
135+
{value !== undefined && <Paragraph variant="small">{value}</Paragraph>}
136136
</div>
137137
);
138138
}

apps/webapp/app/components/stories/FreePlanUsage.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const mockOrganization: MatchedOrganization = {
2121
{ id: "mockId2", slug: "mockSlug2", name: "mockName2", jobCount: 2 },
2222
],
2323
hasUnconfiguredIntegrations: false,
24-
memberCount: 1,
2524
runsEnabled: true,
2625
};
2726

apps/webapp/app/db.server.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ function getClient() {
110110
// emit: "stdout",
111111
// level: "query",
112112
// },
113+
// {
114+
// emit: "event",
115+
// level: "query",
116+
// },
113117
],
114118
});
115119

116120
// client.$on("query", (e) => {
117-
// console.log("Query: " + e.query);
118-
// console.log("Params: " + e.params);
119-
// console.log("Duration: " + e.duration + "ms");
121+
// console.log(`Query tooks ${e.duration}ms`, {
122+
// query: e.query,
123+
// params: e.params,
124+
// duration: e.duration,
125+
// });
120126
// });
121127

122128
// connect eagerly

apps/webapp/app/hooks/useProject.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { UIMatch } from "@remix-run/react";
22
import { UseDataFunctionReturn } from "remix-typedjson";
33
import invariant from "tiny-invariant";
4-
import type { loader } from "~/routes/_app.orgs.$organizationSlug.projects.$projectParam/route";
4+
import type { loader as orgLoader } from "~/routes/_app.orgs.$organizationSlug/route";
55
import { useChanged } from "./useChanged";
66
import { useTypedMatchesData } from "./useTypedMatchData";
7+
import { organizationMatchId } from "./useOrganizations";
78

8-
export type MatchedProject = UseDataFunctionReturn<typeof loader>["project"];
9-
10-
export const projectMatchId = "routes/_app.orgs.$organizationSlug.projects.$projectParam";
9+
export type MatchedProject = UseDataFunctionReturn<typeof orgLoader>["project"];
1110

1211
export function useOptionalProject(matches?: UIMatch[]) {
13-
const routeMatch = useTypedMatchesData<typeof loader>({
14-
id: projectMatchId,
12+
const routeMatch = useTypedMatchesData<typeof orgLoader>({
13+
id: organizationMatchId,
1514
matches,
1615
});
1716

apps/webapp/app/hooks/useUser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import { UIMatch } from "@remix-run/react";
12
import type { User } from "~/models/user.server";
2-
import { useMatchesData } from "~/utils";
3+
import { loader } from "~/root";
34
import { useChanged } from "./useChanged";
4-
import { UIMatch } from "@remix-run/react";
55
import { useTypedMatchesData } from "./useTypedMatchData";
6-
import { loader } from "~/root";
76

87
export function useOptionalUser(matches?: UIMatch[]): User | undefined {
98
const routeMatch = useTypedMatchesData<typeof loader>({

apps/webapp/app/presenters/EventListPresenter.server.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,25 @@ export class EventListPresenter {
4040

4141
// Find the organization that the user is a member of
4242
const organization = await this.#prismaClient.organization.findFirstOrThrow({
43+
select: {
44+
id: true,
45+
},
4346
where: {
4447
slug: organizationSlug,
4548
members: { some: { userId } },
4649
},
4750
});
4851

49-
// Find the project scoped to the organization
5052
const project = await this.#prismaClient.project.findFirstOrThrow({
53+
select: {
54+
id: true,
55+
},
5156
where: {
5257
slug: projectSlug,
5358
organizationId: organization.id,
5459
},
5560
});
5661

57-
// Find all runtimeEnvironments that the user has access to
58-
const environments = await this.#prismaClient.runtimeEnvironment.findMany({
59-
where: {
60-
projectId: project.id,
61-
},
62-
});
63-
6462
const events = await this.#prismaClient.eventRecord.findMany({
6563
select: {
6664
id: true,
@@ -100,9 +98,6 @@ export class EventListPresenter {
10098
},
10199
projectId: project.id,
102100
organizationId: organization.id,
103-
environmentId: {
104-
in: environments.map((environment) => environment.id),
105-
},
106101
environment: filterEnvironment ? { type: filterEnvironment } : undefined,
107102
createdAt: {
108103
gte: from ? new Date(from).toISOString() : undefined,

0 commit comments

Comments
 (0)