Skip to content

Commit 8b3e7b8

Browse files
authored
Merge pull request #56 from diggerhq/feat/project-fields-again
Add project fields
2 parents 64ffac9 + dd62ba4 commit 8b3e7b8

File tree

4 files changed

+326
-54
lines changed

4 files changed

+326
-54
lines changed

src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/project/[projectSlug]/(specific-project-pages)/ProjectSettings.tsx

+108
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button";
55
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
66
import { Input } from "@/components/ui/input";
77
import { Label } from "@/components/ui/label";
8+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
89
import { Switch } from "@/components/ui/switch";
910
import { updateProjectSettingsAction } from "@/data/user/projects";
1011
import { useSAToastMutation } from "@/hooks/useSAToastMutation";
@@ -20,6 +21,11 @@ type ProjectSettingsProps = {
2021

2122
type ProjectSettingsFormData = {
2223
terraformWorkingDir: string;
24+
iac_type: "terraform" | "terragrunt" | "opentofu";
25+
workspace: string;
26+
workflow_file: string;
27+
include_patterns: string;
28+
exclude_patterns: string;
2329
labels: string[];
2430
managedState: boolean;
2531
is_drift_detection_enabled: boolean;
@@ -32,6 +38,9 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
3238
const { control, handleSubmit, formState: { isDirty } } = useForm<ProjectSettingsFormData>({
3339
defaultValues: {
3440
terraformWorkingDir: project.terraform_working_dir || '',
41+
iac_type: project.iac_type || 'terraform',
42+
workspace: project.workspace || 'default',
43+
workflow_file: project.workflow_file || 'digger_workflow.yml',
3544
labels: project.labels || [],
3645
managedState: project.is_managing_state || false,
3746
is_drift_detection_enabled: project.is_drift_detection_enabled || false,
@@ -44,6 +53,11 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
4453
const result = await updateProjectSettingsAction({
4554
projectId: project.id,
4655
terraformWorkingDir: data.terraformWorkingDir,
56+
iac_type: data.iac_type,
57+
workspace: data.workspace,
58+
workflow_file: data.workflow_file,
59+
include_patterns: data.include_patterns,
60+
exclude_patterns: data.exclude_patterns,
4761
labels: data.labels,
4862
managedState: data.managedState,
4963
is_drift_detection_enabled: data.is_drift_detection_enabled,
@@ -118,6 +132,100 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
118132
/>
119133
</motion.div>
120134

135+
<motion.div
136+
initial={{ opacity: 0 }}
137+
animate={{ opacity: 1 }}
138+
transition={{ duration: 0.15, delay: 0.4 }}
139+
>
140+
<Label htmlFor="iac_type">IAC type</Label>
141+
<Controller
142+
name="iac_type"
143+
control={control}
144+
render={({ field }) => (
145+
<Select onValueChange={field.onChange} value={field.value}>
146+
<SelectTrigger>
147+
<SelectValue placeholder="Select IAC type" />
148+
</SelectTrigger>
149+
<SelectContent className="rounded-xl">
150+
<SelectItem value="terraform" className="rounded-lg">
151+
Terraform
152+
</SelectItem>
153+
<SelectItem value="terragrunt" className="rounded-lg">
154+
Terragrunt
155+
</SelectItem>
156+
<SelectItem value="opentofu" className="rounded-lg">
157+
Opentofu
158+
</SelectItem>
159+
</SelectContent>
160+
</Select>
161+
)}
162+
/>
163+
</motion.div>
164+
165+
<motion.div
166+
initial={{ opacity: 0 }}
167+
animate={{ opacity: 1 }}
168+
transition={{ duration: 0.15, delay: 0.4 }}
169+
>
170+
<Label htmlFor="workspace">Workspace</Label>
171+
<Controller
172+
name="workspace"
173+
control={control}
174+
render={({ field }) => (
175+
<Input id="workspace" {...field} />
176+
)}
177+
/>
178+
</motion.div>
179+
180+
<motion.div
181+
initial={{ opacity: 0 }}
182+
animate={{ opacity: 1 }}
183+
transition={{ duration: 0.15, delay: 0.4 }}
184+
>
185+
<Label htmlFor="workflow_file">Workflow file</Label>
186+
<Controller
187+
name="workflow_file"
188+
control={control}
189+
render={({ field }) => (
190+
<Input id="workflow_file" {...field} />
191+
)}
192+
/>
193+
</motion.div>
194+
195+
<div className="grid grid-cols-2 gap-6">
196+
197+
<motion.div
198+
initial={{ opacity: 0 }}
199+
animate={{ opacity: 1 }}
200+
transition={{ duration: 0.15, delay: 0.4 }}
201+
>
202+
<Label htmlFor="include_patterns">Include patterns</Label>
203+
<Controller
204+
name="include_patterns"
205+
control={control}
206+
render={({ field }) => (
207+
<Input id="include_patterns" {...field} />
208+
)}
209+
/>
210+
</motion.div>
211+
212+
<motion.div
213+
initial={{ opacity: 0 }}
214+
animate={{ opacity: 1 }}
215+
transition={{ duration: 0.15, delay: 0.4 }}
216+
>
217+
<Label htmlFor="Exclude patterns">Exclude patterns</Label>
218+
<Controller
219+
name="exclude_patterns"
220+
control={control}
221+
render={({ field }) => (
222+
<Input id="exclude_patterns" {...field} />
223+
)}
224+
/>
225+
</motion.div>
226+
227+
</div>
228+
121229
<motion.div
122230
initial={{ opacity: 0 }}
123231
animate={{ opacity: 1 }}

0 commit comments

Comments
 (0)