Skip to content

Commit 7ae67a6

Browse files
authored
Merge branch 'main' into fix/repair-more-runs
2 parents c0cdefd + 9aedda2 commit 7ae67a6

File tree

48 files changed

+983
-370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+983
-370
lines changed

.changeset/kind-kids-teach.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"trigger.dev": patch
3+
"@trigger.dev/core": patch
4+
---
5+
6+
Added INSTALLING status to the deployment status enum.

apps/webapp/app/components/runs/v3/DeploymentStatus.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function DeploymentStatusIcon({
5353
return (
5454
<RectangleStackIcon className={cn(deploymentStatusClassNameColor(status), className)} />
5555
);
56+
case "INSTALLING":
5657
case "BUILDING":
5758
case "DEPLOYING":
5859
return <Spinner className={cn(deploymentStatusClassNameColor(status), className)} />;
@@ -78,6 +79,7 @@ export function deploymentStatusClassNameColor(status: WorkerDeploymentStatus):
7879
switch (status) {
7980
case "PENDING":
8081
return "text-charcoal-500";
82+
case "INSTALLING":
8183
case "BUILDING":
8284
case "DEPLOYING":
8385
return "text-pending";
@@ -98,6 +100,8 @@ export function deploymentStatusTitle(status: WorkerDeploymentStatus, isBuilt: b
98100
switch (status) {
99101
case "PENDING":
100102
return "Queued…";
103+
case "INSTALLING":
104+
return "Installing…";
101105
case "BUILDING":
102106
return "Building…";
103107
case "DEPLOYING":
@@ -127,17 +131,21 @@ export function deploymentStatusTitle(status: WorkerDeploymentStatus, isBuilt: b
127131
// PENDING and CANCELED are not used so are ommited from the UI
128132
export const deploymentStatuses: WorkerDeploymentStatus[] = [
129133
"PENDING",
134+
"INSTALLING",
130135
"BUILDING",
131136
"DEPLOYING",
132137
"DEPLOYED",
133138
"FAILED",
134139
"TIMED_OUT",
140+
"CANCELED",
135141
];
136142

137143
export function deploymentStatusDescription(status: WorkerDeploymentStatus): string {
138144
switch (status) {
139145
case "PENDING":
140146
return "The deployment is queued and waiting to be processed.";
147+
case "INSTALLING":
148+
return "The project dependencies are being installed.";
141149
case "BUILDING":
142150
return "The code is being built and prepared for deployment.";
143151
case "DEPLOYING":

apps/webapp/app/components/runs/v3/RollbackDeploymentDialog.tsx

Lines changed: 0 additions & 102 deletions
This file was deleted.

apps/webapp/app/models/member.server.ts

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { prisma } from "~/db.server";
1+
import { type Prisma, prisma } from "~/db.server";
22
import { createEnvironment } from "./organization.server";
3+
import { customAlphabet } from "nanoid";
4+
5+
const tokenValueLength = 40;
6+
const tokenGenerator = customAlphabet("123456789abcdefghijkmnopqrstuvwxyz", tokenValueLength);
37

48
export async function getTeamMembersAndInvites({
59
userId,
@@ -95,14 +99,19 @@ export async function inviteMembers({
9599
throw new Error("User does not have access to this organization");
96100
}
97101

98-
const created = await prisma.orgMemberInvite.createMany({
99-
data: emails.map((email) => ({
100-
email,
101-
organizationId: org.id,
102-
inviterId: userId,
103-
role: "MEMBER",
104-
})),
105-
skipDuplicates: true,
102+
const invites = [...new Set(emails)].map(
103+
(email) =>
104+
({
105+
email,
106+
token: tokenGenerator(),
107+
organizationId: org.id,
108+
inviterId: userId,
109+
role: "MEMBER",
110+
} satisfies Prisma.OrgMemberInviteCreateManyInput)
111+
);
112+
113+
await prisma.orgMemberInvite.createMany({
114+
data: invites,
106115
});
107116

108117
return await prisma.orgMemberInvite.findMany({
@@ -147,12 +156,19 @@ export async function getUsersInvites({ email }: { email: string }) {
147156
});
148157
}
149158

150-
export async function acceptInvite({ userId, inviteId }: { userId: string; inviteId: string }) {
159+
export async function acceptInvite({
160+
user,
161+
inviteId,
162+
}: {
163+
user: { id: string; email: string };
164+
inviteId: string;
165+
}) {
151166
return await prisma.$transaction(async (tx) => {
152167
// 1. Delete the invite and get the invite details
153168
const invite = await tx.orgMemberInvite.delete({
154169
where: {
155170
id: inviteId,
171+
email: user.email,
156172
},
157173
include: {
158174
organization: {
@@ -167,7 +183,7 @@ export async function acceptInvite({ userId, inviteId }: { userId: string; invit
167183
const member = await tx.orgMember.create({
168184
data: {
169185
organizationId: invite.organizationId,
170-
userId,
186+
userId: user.id,
171187
role: invite.role,
172188
},
173189
});
@@ -187,47 +203,49 @@ export async function acceptInvite({ userId, inviteId }: { userId: string; invit
187203
// 4. Check for other invites
188204
const remainingInvites = await tx.orgMemberInvite.findMany({
189205
where: {
190-
email: invite.email,
206+
email: user.email,
191207
},
192208
});
193209

194210
return { remainingInvites, organization: invite.organization };
195211
});
196212
}
197213

198-
export async function declineInvite({ userId, inviteId }: { userId: string; inviteId: string }) {
214+
export async function declineInvite({
215+
user,
216+
inviteId,
217+
}: {
218+
user: { id: string; email: string };
219+
inviteId: string;
220+
}) {
199221
return await prisma.$transaction(async (tx) => {
200222
//1. delete invite
201223
const declinedInvite = await prisma.orgMemberInvite.delete({
202224
where: {
203225
id: inviteId,
226+
email: user.email,
204227
},
205228
include: {
206229
organization: true,
207230
},
208231
});
209232

210-
//2. get email
211-
const user = await prisma.user.findUnique({
212-
where: { id: userId },
213-
select: { email: true },
214-
});
215-
216-
//3. check for other invites
233+
//2. check for other invites
217234
const remainingInvites = await prisma.orgMemberInvite.findMany({
218235
where: {
219-
email: user!.email,
236+
email: user.email,
220237
},
221238
});
222239

223240
return { remainingInvites, organization: declinedInvite.organization };
224241
});
225242
}
226243

227-
export async function resendInvite({ inviteId }: { inviteId: string }) {
244+
export async function resendInvite({ inviteId, userId }: { inviteId: string; userId: string }) {
228245
return await prisma.orgMemberInvite.update({
229246
where: {
230247
id: inviteId,
248+
inviterId: userId,
231249
},
232250
data: {
233251
updatedAt: new Date(),
@@ -241,26 +259,27 @@ export async function resendInvite({ inviteId }: { inviteId: string }) {
241259

242260
export async function revokeInvite({
243261
userId,
244-
slug,
262+
orgSlug,
245263
inviteId,
246264
}: {
247265
userId: string;
248-
slug: string;
266+
orgSlug: string;
249267
inviteId: string;
250268
}) {
251-
const org = await prisma.organization.findFirst({
252-
where: { slug, members: { some: { userId } } },
253-
});
254-
255-
if (!org) {
256-
throw new Error("User does not have access to this organization");
257-
}
258-
const invite = await prisma.orgMemberInvite.delete({
269+
const invite = await prisma.orgMemberInvite.findFirst({
259270
where: {
260271
id: inviteId,
261-
organizationId: org.id,
272+
organization: {
273+
slug: orgSlug,
274+
members: {
275+
some: {
276+
userId,
277+
},
278+
},
279+
},
262280
},
263281
select: {
282+
id: true,
264283
email: true,
265284
organization: true,
266285
},
@@ -270,5 +289,11 @@ export async function revokeInvite({
270289
throw new Error("Invite not found");
271290
}
272291

292+
await prisma.orgMemberInvite.delete({
293+
where: {
294+
id: invite.id,
295+
},
296+
});
297+
273298
return { email: invite.email, organization: invite.organization };
274299
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export class DeploymentPresenter {
103103
deployedAt: true,
104104
createdAt: true,
105105
startedAt: true,
106+
installedAt: true,
107+
canceledAt: true,
108+
canceledReason: true,
106109
git: true,
107110
promotions: {
108111
select: {
@@ -147,8 +150,11 @@ export class DeploymentPresenter {
147150
status: deployment.status,
148151
createdAt: deployment.createdAt,
149152
startedAt: deployment.startedAt,
153+
installedAt: deployment.installedAt,
150154
builtAt: deployment.builtAt,
151155
deployedAt: deployment.deployedAt,
156+
canceledAt: deployment.canceledAt,
157+
canceledReason: deployment.canceledReason,
152158
tasks: deployment.worker?.tasks,
153159
label: deployment.promotions?.[0]?.label,
154160
environment: {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ export class RunPresenter {
2828
public async call({
2929
userId,
3030
projectSlug,
31-
organizationSlug,
3231
environmentSlug,
3332
runFriendlyId,
3433
showDeletedLogs,
3534
showDebug,
3635
}: {
3736
userId: string;
3837
projectSlug: string;
39-
organizationSlug: string;
4038
environmentSlug: string;
4139
runFriendlyId: string;
4240
showDeletedLogs: boolean;
@@ -93,6 +91,13 @@ export class RunPresenter {
9391
friendlyId: runFriendlyId,
9492
project: {
9593
slug: projectSlug,
94+
organization: {
95+
members: {
96+
some: {
97+
userId,
98+
},
99+
},
100+
},
96101
},
97102
},
98103
});

0 commit comments

Comments
 (0)