Skip to content

Commit f0f8099

Browse files
committed
refactor: rename feature flags route to v2, match v1 param naming
1 parent fd422ea commit f0f8099

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

apps/webapp/app/components/admin/FeatureFlagsDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function FeatureFlagsDialog({
5151
useEffect(() => {
5252
if (open && orgId) {
5353
setSaveError(null);
54-
loadFetcher.load(`/admin/api/orgs/${orgId}/feature-flags`);
54+
loadFetcher.load(`/admin/api/v2/orgs/${orgId}/feature-flags`);
5555
}
5656
}, [open, orgId]);
5757

@@ -90,7 +90,7 @@ export function FeatureFlagsDialog({
9090
const body = Object.keys(overrides).length === 0 ? null : overrides;
9191
saveFetcher.submit(JSON.stringify(body), {
9292
method: "POST",
93-
action: `/admin/api/orgs/${orgId}/feature-flags`,
93+
action: `/admin/api/v2/orgs/${orgId}/feature-flags`,
9494
encType: "application/json",
9595
});
9696
};

apps/webapp/app/routes/admin.api.orgs.$orgId.feature-flags.ts renamed to apps/webapp/app/routes/admin.api.v2.orgs.$organizationId.feature-flags.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ import { requireUser } from "~/services/session.server";
77
import { flags as getGlobalFlags } from "~/v3/featureFlags.server";
88
import { validatePartialFeatureFlags, getAllFlagControlTypes } from "~/v3/featureFlags";
99

10+
// Session-auth route for the admin feature flags dialog.
11+
// Uses replace semantics: the action writes the full flag set (or null to clear).
12+
// Compare with v1 (admin.api.v1.orgs.$organizationId.feature-flags.ts) which
13+
// uses PAT auth and merge semantics for programmatic use.
14+
1015
const ParamsSchema = z.object({
11-
orgId: z.string(),
16+
organizationId: z.string(),
1217
});
1318

1419
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -17,11 +22,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
1722
throw new Response("Unauthorized", { status: 403 });
1823
}
1924

20-
const { orgId } = ParamsSchema.parse(params);
25+
const { organizationId } = ParamsSchema.parse(params);
2126

2227
const [organization, globalFlags] = await Promise.all([
2328
prisma.organization.findFirst({
24-
where: { id: orgId },
29+
where: { id: organizationId },
2530
select: {
2631
id: true,
2732
title: true,
@@ -61,7 +66,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
6166
throw new Response("Unauthorized", { status: 403 });
6267
}
6368

64-
const { orgId } = ParamsSchema.parse(params);
69+
const { organizationId } = ParamsSchema.parse(params);
6570

6671
let body: unknown;
6772
try {
@@ -90,7 +95,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
9095

9196
try {
9297
await prisma.organization.update({
93-
where: { id: orgId },
98+
where: { id: organizationId },
9499
data: { featureFlags: featureFlags as Prisma.InputJsonValue },
95100
});
96101
} catch (e) {

0 commit comments

Comments
 (0)