Skip to content

Commit

Permalink
Merge pull request #82 from diggerhq/feat/auto-approve-ui
Browse files Browse the repository at this point in the history
Add auto-approve checkbox
  • Loading branch information
ZIJ authored Nov 20, 2024
2 parents 85c5106 + d8d32b7 commit 5b496f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
17 changes: 9 additions & 8 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ model projects {
workflow_file String?
include_patterns String?
exclude_patterns String?
auto_approve Boolean @default(false)
chats chats[]
digger_runs digger_runs[]
env_vars env_vars[]
Expand Down Expand Up @@ -655,19 +656,19 @@ model user_profiles {
user_roles user_roles[]
}


model user_m2m_applications {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
email String
clientId String @unique
audience String?
issuer String?
clientId String @unique
audience String
issuer String
name String?
description String?
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
}
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
updatedAt DateTime? @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
@@index([email], map: "m2m_application_user_id_idx")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ProjectSettingsFormData = {
managedState: boolean;
is_drift_detection_enabled: boolean;
drift_crontab: string;
auto_approve: boolean;
};

export default function ProjectSettings({ project, repositoryName }: ProjectSettingsProps) {
Expand All @@ -46,6 +47,7 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
managedState: project.is_managing_state || false,
is_drift_detection_enabled: project.is_drift_detection_enabled || false,
drift_crontab: project.drift_crontab || '',
auto_approve: project.auto_approve || false,
},
});

Expand All @@ -63,6 +65,7 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
managedState: data.managedState,
is_drift_detection_enabled: data.is_drift_detection_enabled,
drift_crontab: data.drift_crontab,
auto_approve: data.auto_approve,
});
return result;
},
Expand Down Expand Up @@ -276,6 +279,20 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
/>
</div>

<div className="flex items-center gap-2">
<Label htmlFor="auto_approve">Auto-approve</Label>
<Controller
name="auto_approve"
control={control}
render={({ field }) => (
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
)}
/>
</div>

<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
Expand Down
3 changes: 3 additions & 0 deletions src/data/user/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ export async function updateProjectSettingsAction({
managedState,
is_drift_detection_enabled,
drift_crontab,
auto_approve,
}: {
projectId: string;
terraformWorkingDir: string;
Expand All @@ -993,6 +994,7 @@ export async function updateProjectSettingsAction({
managedState: boolean;
is_drift_detection_enabled: boolean;
drift_crontab: string;
auto_approve: boolean;
}): Promise<SAPayload<projects>> {
const prisma = new PrismaClient();

Expand All @@ -1012,6 +1014,7 @@ export async function updateProjectSettingsAction({
is_managing_state: managedState,
is_drift_detection_enabled,
drift_crontab,
auto_approve,
}
});

Expand Down

0 comments on commit 5b496f5

Please sign in to comment.