Skip to content

Commit

Permalink
feature / bring back managed state checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
psiddharthdesign committed Jul 25, 2024
1 parent 49f4a65 commit cf5aed7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/components/CreateProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Controller, useForm } from "react-hook-form";
import { z } from "zod";
import { InputTags } from "./InputTags";
import { T } from "./ui/Typography";
import { Checkbox } from "./ui/checkbox";

const MotionCard = motion(Card);

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

type CreateProjectFormData = z.infer<typeof createProjectFormSchema>;
Expand All @@ -50,6 +52,7 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
name: "",
repository: repositories[0]?.id || 0,
terraformDir: "",
managedState: true,
labels: [],
},
});
Expand All @@ -62,6 +65,7 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
name: data.name,
slug,
repoId: data.repository,
managedState: data.managedState,
terraformWorkingDir: data.terraformDir,
labels: data.labels,
});
Expand Down Expand Up @@ -268,6 +272,20 @@ export default function CreateProjectForm({ organizationId, repositories }: Crea
</CardHeader>
<CardContent>
<div className="space-y-4">
<div className="flex items-center space-x-2">
<Controller
name="managedState"
control={control}
render={({ field }) => (
<Checkbox
id="managedState"
checked={field.value}
onCheckedChange={field.onChange}
/>
)}
/>
<Label htmlFor="managedState">Managed State</Label>
</div>
<div>
<Label htmlFor="labels">Labels</Label>
<Controller
Expand Down
4 changes: 3 additions & 1 deletion src/data/user/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ export const createProjectAction = async ({
slug,
repoId,
terraformWorkingDir,
managedState,
labels,
}: {
organizationId: string;
name: string;
slug: string;
repoId: number;
terraformWorkingDir: string;
managedState: boolean;
labels: string[];
}): Promise<SAPayload<Tables<"projects">>> => {
"use server";
Expand All @@ -87,7 +89,7 @@ export const createProjectAction = async ({
slug,
repo_id: repoId,
terraform_working_dir: terraformWorkingDir,
is_managing_state: true,
is_managing_state: managedState,
is_in_main_branch: true,
is_generated: true,
project_status: "draft",
Expand Down

0 comments on commit cf5aed7

Please sign in to comment.