From e673c640f6adb8ba39884f6f0bf60e0a5af47989 Mon Sep 17 00:00:00 2001 From: psiddharthdesign <107192927+psiddharthdesign@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:47:54 +0530 Subject: [PATCH] feat / add switch and input to project settings --- .../ProjectSettings.tsx | 35 +++++++++++++++++++ src/data/user/projects.tsx | 6 ++++ src/lib/database.types.ts | 6 ++++ 3 files changed, 47 insertions(+) diff --git a/src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/project/[projectSlug]/(specific-project-pages)/ProjectSettings.tsx b/src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/project/[projectSlug]/(specific-project-pages)/ProjectSettings.tsx index c5c7a403..5412a6ca 100644 --- a/src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/project/[projectSlug]/(specific-project-pages)/ProjectSettings.tsx +++ b/src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/project/[projectSlug]/(specific-project-pages)/ProjectSettings.tsx @@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; import { updateProjectSettingsAction } from "@/data/user/projects"; import { useSAToastMutation } from "@/hooks/useSAToastMutation"; import { Tables } from "@/lib/database.types"; @@ -21,6 +22,8 @@ type ProjectSettingsFormData = { terraformWorkingDir: string; labels: string[]; managedState: boolean; + is_drift_detection_enabled: boolean; + drift_crontab: string; }; export default function ProjectSettings({ project, repositoryName }: ProjectSettingsProps) { @@ -31,6 +34,8 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett terraformWorkingDir: project.terraform_working_dir || '', labels: project.labels || [], managedState: project.is_managing_state || false, + is_drift_detection_enabled: project.is_drift_detection_enabled || false, + drift_crontab: project.drift_crontab || '', }, }); @@ -41,6 +46,8 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett terraformWorkingDir: data.terraformWorkingDir, labels: data.labels, managedState: data.managedState, + is_drift_detection_enabled: data.is_drift_detection_enabled, + drift_crontab: data.drift_crontab, }); return result; }, @@ -132,6 +139,34 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett /> + + {/* Drift Detection */} +
+ + ( + + )} + /> +
+ + {/* Input to set the drift detection crontab */} +
+ + ( + + )} + /> +
+ > { const supabase = createSupabaseUserServerComponentClient(); @@ -815,6 +819,8 @@ export async function updateProjectSettingsAction({ terraform_working_dir: terraformWorkingDir, labels, is_managing_state: managedState, + is_drift_detection_enabled: is_drift_detection_enabled, + drift_crontab: drift_crontab, }) .eq('id', projectId) .select() diff --git a/src/lib/database.types.ts b/src/lib/database.types.ts index 7e6b1418..4491bd90 100644 --- a/src/lib/database.types.ts +++ b/src/lib/database.types.ts @@ -1275,7 +1275,9 @@ export type Database = { configuration_yaml: string | null created_at: string deleted_at: string | null + drift_crontab: string | null id: string + is_drift_detection_enabled: boolean | null is_generated: boolean | null is_in_main_branch: boolean | null is_managing_state: boolean | null @@ -1295,7 +1297,9 @@ export type Database = { configuration_yaml?: string | null created_at?: string deleted_at?: string | null + drift_crontab?: string | null id?: string + is_drift_detection_enabled?: boolean | null is_generated?: boolean | null is_in_main_branch?: boolean | null is_managing_state?: boolean | null @@ -1315,7 +1319,9 @@ export type Database = { configuration_yaml?: string | null created_at?: string deleted_at?: string | null + drift_crontab?: string | null id?: string + is_drift_detection_enabled?: boolean | null is_generated?: boolean | null is_in_main_branch?: boolean | null is_managing_state?: boolean | null