Skip to content

Commit 28314d3

Browse files
committed
more env filtering correctness
1 parent 54f96ed commit 28314d3

4 files changed

Lines changed: 19 additions & 3 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class OrganizationsPresenter {
109109
const environment = this.#getEnvironment({
110110
user,
111111
projectId: fullProject.id,
112-
environments: fullProject.environments,
112+
environments,
113113
environmentSlug,
114114
});
115115

apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
7373
},
7474
// Dev branches are per-org-member: only the owner may archive their own.
7575
...(authenticationResult.type !== "organizationAccessToken" &&
76-
environmentType === "DEVELOPMENT"
76+
environmentType === "DEVELOPMENT"
7777
? { orgMember: { userId: authenticationResult.result.userId } }
7878
: {}),
7979
project: {
@@ -88,7 +88,21 @@ export async function action({ request, params }: ActionFunctionArgs) {
8888
return json({ error: "Branch not found" }, { status: 404 });
8989
}
9090

91-
const environment = environments.find((env) => env.archivedAt === null);
91+
const activeEnvironments = environments.filter((env) => env.archivedAt === null);
92+
93+
if (
94+
authenticationResult.type === "organizationAccessToken" &&
95+
environmentType === "DEVELOPMENT" &&
96+
activeEnvironments.length > 1
97+
) {
98+
return json(
99+
{ error: "Branch name is ambiguous for development environments. Use a personal access token scoped to the branch owner." },
100+
{ status: 409 }
101+
);
102+
}
103+
104+
const environment = activeEnvironments[0];
105+
92106
if (!environment) {
93107
return json({ error: "Branch already archived" }, { status: 400 });
94108
}

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.presence.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const loader = createSSELoader({
2323
},
2424
project: {
2525
slug: projectParam,
26+
organization: { slug: organizationSlug },
2627
},
2728
},
2829
});

apps/webapp/app/routes/resources.taskruns.$runParam.replay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
146146
type: true,
147147
slug: true,
148148
branchName: true,
149+
parentEnvironmentId: true,
149150
orgMember: { select: { user: true } },
150151
},
151152
where: {

0 commit comments

Comments
 (0)