Skip to content

Commit dd62ba4

Browse files
committed
Add fields to project creation page
1 parent d090ff2 commit dd62ba4

File tree

2 files changed

+172
-54
lines changed

2 files changed

+172
-54
lines changed

src/components/CreateProjectForm.tsx

+167-49
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const createProjectFormSchema = z.object({
2727
name: z.string().min(1, "Project name is required"),
2828
repository: z.number().int().positive("Please select a repository"),
2929
terraformDir: z.string().min(1, "Terraform working directory is required"),
30+
iac_type: z.enum(["terraform", "terragrunt", "opentofu"]).default("terraform"),
31+
workspace: z.string().default("default").optional(),
32+
workflow_file: z.string().default("digger_workflow.yml").optional(),
33+
include_patterns: z.string().optional(),
34+
exclude_patterns: z.string().optional(),
3035
branch: z.string().min(1, "Branch is required").default("main"),
3136
labels: z.array(z.string()),
3237
managedState: z.boolean().default(true),
@@ -65,6 +70,9 @@ export default function CreateProjectForm({ organizationId, repositories, teams,
6570
name: "",
6671
repository: repositories[0]?.id || 0,
6772
terraformDir: "",
73+
iac_type: "terraform",
74+
workflow_file: "digger_workflow.yml",
75+
workspace: "default",
6876
managedState: true,
6977
labels: [],
7078
teamId: teamId || null,
@@ -77,17 +85,22 @@ export default function CreateProjectForm({ organizationId, repositories, teams,
7785
async (data: CreateProjectFormData) => {
7886
const slug = generateSlug(data.name);
7987
return await createProjectAction({
80-
organizationId,
81-
teamId: data.teamId,
8288
name: data.name,
8389
slug,
8490
repoId: data.repository,
85-
managedState: data.managedState,
91+
branch: data.branch,
92+
organizationId: organizationId,
93+
teamId: data.teamId,
8694
terraformWorkingDir: data.terraformDir,
87-
branch: data.branch || '',
95+
iac_type: data.iac_type,
96+
workspace: data.workspace,
97+
workflow_file: data.workflow_file,
98+
include_patterns: data.include_patterns,
99+
exclude_patterns: data.exclude_patterns,
88100
labels: data.labels,
101+
managedState: data.managedState,
89102
is_drift_detection_enabled: data.is_drift_detection_enabled,
90-
drift_crontab: data.drift_crontab || '',
103+
drift_crontab: data.drift_crontab,
91104
});
92105
},
93106
{
@@ -311,53 +324,95 @@ export default function CreateProjectForm({ organizationId, repositories, teams,
311324
<CardHeader>
312325
<div className="flex flex-col">
313326
<CardTitle className="text-lg ">Configuration</CardTitle>
314-
<CardDescription className="text-sm text-muted-foreground">Specify branch and working directory for Terraform</CardDescription>
327+
<CardDescription className="text-sm text-muted-foreground">Specify key settings for Terraform</CardDescription>
315328
</div>
316329
</CardHeader>
317330
<CardContent>
318-
<div>
319-
<Label htmlFor="terraformDir">Terraform Working Directory *</Label>
320-
<Controller
321-
name="terraformDir"
322-
control={control}
323-
render={({ field }) => (
324-
<div className="relative">
325-
<Input
326-
id="terraformDir"
327-
placeholder="e.g. ./"
328-
className={`mt-1 ${errors.terraformDir ? 'border-destructive' : ''}`}
329-
{...field}
330-
/>
331-
{errors.terraformDir && (
332-
<div className="flex items-center mt-1 text-destructive">
333-
<AlertCircle className="h-4 w-4 mr-1" />
334-
<span className="text-sm">{errors.terraformDir.message}</span>
335-
</div>
336-
)}
337-
</div>
338-
)}
339-
/>
340-
<Label htmlFor="branch">Branch</Label>
341-
<Controller
342-
name="branch"
343-
control={control}
344-
render={({ field }) => (
345-
<div className="relative">
346-
<Input
347-
id="branch"
348-
placeholder="if not specified, main branch will be used"
349-
className={`mt-1 ${errors.branch ? 'border-destructive' : ''}`}
350-
{...field}
351-
/>
352-
{errors.branch && (
353-
<div className="flex items-center mt-1 text-destructive">
354-
<AlertCircle className="h-4 w-4 mr-1" />
355-
<span className="text-sm">{errors.branch.message}</span>
356-
</div>
357-
)}
358-
</div>
359-
)}
360-
/>
331+
<div className="space-y-4">
332+
<motion.div
333+
initial={{ opacity: 0 }}
334+
animate={{ opacity: 1 }}
335+
transition={{ duration: 0.15, delay: 0.4 }}
336+
>
337+
<Label htmlFor="terraformDir">Terraform Working Directory *</Label>
338+
<Controller
339+
name="terraformDir"
340+
control={control}
341+
render={({ field }) => (
342+
<div className="relative">
343+
<Input
344+
id="terraformDir"
345+
placeholder="e.g. ./"
346+
className={`mt-1 ${errors.terraformDir ? 'border-destructive' : ''}`}
347+
{...field}
348+
/>
349+
{errors.terraformDir && (
350+
<div className="flex items-center mt-1 text-destructive">
351+
<AlertCircle className="h-4 w-4 mr-1" />
352+
<span className="text-sm">{errors.terraformDir.message}</span>
353+
</div>
354+
)}
355+
</div>
356+
)}
357+
/>
358+
</motion.div>
359+
<motion.div
360+
initial={{ opacity: 0 }}
361+
animate={{ opacity: 1 }}
362+
transition={{ duration: 0.15, delay: 0.4 }}
363+
>
364+
<Label htmlFor="branch">Branch</Label>
365+
<Controller
366+
name="branch"
367+
control={control}
368+
render={({ field }) => (
369+
<div className="relative">
370+
<Input
371+
id="branch"
372+
placeholder="if not specified, main branch will be used"
373+
className={`mt-1 ${errors.branch ? 'border-destructive' : ''}`}
374+
{...field}
375+
/>
376+
{errors.branch && (
377+
<div className="flex items-center mt-1 text-destructive">
378+
<AlertCircle className="h-4 w-4 mr-1" />
379+
<span className="text-sm">{errors.branch.message}</span>
380+
</div>
381+
)}
382+
</div>
383+
)}
384+
/>
385+
</motion.div>
386+
387+
<motion.div
388+
initial={{ opacity: 0 }}
389+
animate={{ opacity: 1 }}
390+
transition={{ duration: 0.15, delay: 0.4 }}
391+
>
392+
<Label htmlFor="iac_type">IAC type</Label>
393+
<Controller
394+
name="iac_type"
395+
control={control}
396+
render={({ field }) => (
397+
<Select onValueChange={field.onChange} value={field.value}>
398+
<SelectTrigger>
399+
<SelectValue placeholder="Select IAC type" />
400+
</SelectTrigger>
401+
<SelectContent className="rounded-xl">
402+
<SelectItem value="terraform" className="rounded-lg">
403+
Terraform
404+
</SelectItem>
405+
<SelectItem value="terragrunt" className="rounded-lg">
406+
Terragrunt
407+
</SelectItem>
408+
<SelectItem value="opentofu" className="rounded-lg">
409+
Opentofu
410+
</SelectItem>
411+
</SelectContent>
412+
</Select>
413+
)}
414+
/>
415+
</motion.div>
361416
</div>
362417
</CardContent>
363418
</MotionCard>
@@ -376,6 +431,69 @@ export default function CreateProjectForm({ organizationId, repositories, teams,
376431
</CardHeader>
377432
<CardContent>
378433
<div className="space-y-4">
434+
<motion.div
435+
initial={{ opacity: 0 }}
436+
animate={{ opacity: 1 }}
437+
transition={{ duration: 0.15, delay: 0.4 }}
438+
>
439+
<Label htmlFor="workspace">Workspace</Label>
440+
<Controller
441+
name="workspace"
442+
control={control}
443+
render={({ field }) => (
444+
<Input id="workspace" {...field} />
445+
)}
446+
/>
447+
</motion.div>
448+
449+
<motion.div
450+
initial={{ opacity: 0 }}
451+
animate={{ opacity: 1 }}
452+
transition={{ duration: 0.15, delay: 0.4 }}
453+
>
454+
<Label htmlFor="workflow_file">Workflow file</Label>
455+
<Controller
456+
name="workflow_file"
457+
control={control}
458+
render={({ field }) => (
459+
<Input id="workflow_file" {...field} />
460+
)}
461+
/>
462+
</motion.div>
463+
464+
<div className="grid grid-cols-2 gap-6">
465+
466+
<motion.div
467+
initial={{ opacity: 0 }}
468+
animate={{ opacity: 1 }}
469+
transition={{ duration: 0.15, delay: 0.4 }}
470+
>
471+
<Label htmlFor="include_patterns">Include patterns</Label>
472+
<Controller
473+
name="include_patterns"
474+
control={control}
475+
render={({ field }) => (
476+
<Input id="include_patterns" {...field} />
477+
)}
478+
/>
479+
</motion.div>
480+
481+
<motion.div
482+
initial={{ opacity: 0 }}
483+
animate={{ opacity: 1 }}
484+
transition={{ duration: 0.15, delay: 0.4 }}
485+
>
486+
<Label htmlFor="Exclude patterns">Exclude patterns</Label>
487+
<Controller
488+
name="exclude_patterns"
489+
control={control}
490+
render={({ field }) => (
491+
<Input id="exclude_patterns" {...field} />
492+
)}
493+
/>
494+
</motion.div>
495+
496+
</div>
379497
<div>
380498
<Label htmlFor="labels">Labels</Label>
381499
<Controller

src/data/user/projects.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ export const createProjectAction = async ({
8888
repoId: number;
8989
branch: string;
9090
terraformWorkingDir: string;
91-
workspace: string;
92-
workflow_file: string;
91+
workspace?: string;
92+
workflow_file?: string;
9393
iac_type: "terraform" | "terragrunt" | "opentofu";
94-
include_patterns: string;
95-
exclude_patterns: string;
94+
include_patterns?: string;
95+
exclude_patterns?: string;
9696
managedState: boolean;
9797
labels: string[];
9898
teamId: number | null;
9999
is_drift_detection_enabled: boolean;
100-
drift_crontab: string;
100+
drift_crontab?: string;
101101
}): Promise<SAPayload<Tables<"projects">>> => {
102102
"use server";
103103
const supabaseClient = createSupabaseUserServerActionClient();

0 commit comments

Comments
 (0)