Skip to content

Commit 54f96ed

Browse files
committed
simplify new env var logic
1 parent 55ccb3d commit 54f96ed

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new/route.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ export default function Page() {
220220
const [selectedEnvironmentIds, setSelectedEnvironmentIds] = useState<Set<string>>(new Set());
221221
const [selectedBranchId, setSelectedBranchId] = useState<string | undefined>(undefined);
222222

223-
const branchEnvironments = environments.filter((env) => env.parentEnvironmentId !== null);
223+
// TODO for no we only support branch-specific env vars for Preview environments
224+
// Mostly to keep the UX for setting consistent env-vars across Dev/Staging/Prod easier
225+
const previewBranches = environments.filter((env) => env.type === "PREVIEW" && env.parentEnvironmentId !== null);
224226
const nonBranchEnvironments = environments.filter((env) => env.parentEnvironmentId === null);
225227
const selectedEnvironments = environments.filter((env) => selectedEnvironmentIds.has(env.id));
226-
const previewIsSelected = selectedEnvironments.some(
227-
(env) => env.parentEnvironmentId !== null || env.type === "PREVIEW"
228-
);
228+
const previewIsSelected = selectedEnvironments.some((env) => env.type === "PREVIEW");
229229

230230
const isLoading = navigation.state !== "idle" && navigation.formMethod === "post";
231231

@@ -406,15 +406,15 @@ export default function Page() {
406406
value={selectedBranchId ?? "all"}
407407
setValue={handleBranchChange}
408408
placeholder="All branches"
409-
items={[{ id: "all", branchName: "All branches" }, ...branchEnvironments]}
409+
items={[{ id: "all", branchName: "All branches" }, ...previewBranches]}
410410
className="w-fit min-w-52"
411411
filter={{
412412
keys: [
413413
(item) => item.branchName?.replace(/\//g, " ").replace(/_/g, " ") ?? "",
414414
],
415415
}}
416416
text={(val) =>
417-
val ? branchEnvironments.find((b) => b.id === val)?.branchName : null
417+
val ? previewBranches.find((b) => b.id === val)?.branchName : null
418418
}
419419
dropdownIcon
420420
>

0 commit comments

Comments
 (0)