Skip to content

Commit cf5aed7

Browse files
feature / bring back managed state checkbox
1 parent 49f4a65 commit cf5aed7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/components/CreateProjectForm.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Controller, useForm } from "react-hook-form";
1919
import { z } from "zod";
2020
import { InputTags } from "./InputTags";
2121
import { T } from "./ui/Typography";
22+
import { Checkbox } from "./ui/checkbox";
2223

2324
const MotionCard = motion(Card);
2425

@@ -27,6 +28,7 @@ const createProjectFormSchema = z.object({
2728
repository: z.number().int().positive("Please select a repository"),
2829
terraformDir: z.string().min(1, "Terraform working directory is required"),
2930
labels: z.array(z.string()),
31+
managedState: z.boolean().default(true),
3032
});
3133

3234
type CreateProjectFormData = z.infer<typeof createProjectFormSchema>;
@@ -50,6 +52,7 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
5052
name: "",
5153
repository: repositories[0]?.id || 0,
5254
terraformDir: "",
55+
managedState: true,
5356
labels: [],
5457
},
5558
});
@@ -62,6 +65,7 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
6265
name: data.name,
6366
slug,
6467
repoId: data.repository,
68+
managedState: data.managedState,
6569
terraformWorkingDir: data.terraformDir,
6670
labels: data.labels,
6771
});
@@ -268,6 +272,20 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
268272
</CardHeader>
269273
<CardContent>
270274
<div className="space-y-4">
275+
<div className="flex items-center space-x-2">
276+
<Controller
277+
name="managedState"
278+
control={control}
279+
render={({ field }) => (
280+
<Checkbox
281+
id="managedState"
282+
checked={field.value}
283+
onCheckedChange={field.onChange}
284+
/>
285+
)}
286+
/>
287+
<Label htmlFor="managedState">Managed State</Label>
288+
</div>
271289
<div>
272290
<Label htmlFor="labels">Labels</Label>
273291
<Controller

src/data/user/projects.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ export const createProjectAction = async ({
6868
slug,
6969
repoId,
7070
terraformWorkingDir,
71+
managedState,
7172
labels,
7273
}: {
7374
organizationId: string;
7475
name: string;
7576
slug: string;
7677
repoId: number;
7778
terraformWorkingDir: string;
79+
managedState: boolean;
7880
labels: string[];
7981
}): Promise<SAPayload<Tables<"projects">>> => {
8082
"use server";
@@ -87,7 +89,7 @@ export const createProjectAction = async ({
8789
slug,
8890
repo_id: repoId,
8991
terraform_working_dir: terraformWorkingDir,
90-
is_managing_state: true,
92+
is_managing_state: managedState,
9193
is_in_main_branch: true,
9294
is_generated: true,
9395
project_status: "draft",

0 commit comments

Comments
 (0)