Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/add field for workflow in settings #85

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ model projects {
organizations organizations @relation(fields: [organization_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_projects_organization")
repos repos @relation(fields: [repo_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "fk_projects_repo")
teams teams? @relation(fields: [team_id], references: [id], onDelete: Cascade)
workflow String
}

/// 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 @@ -32,6 +32,7 @@ type ProjectSettingsFormData = {
is_drift_detection_enabled: boolean;
drift_crontab: string;
auto_approve: boolean;
workflow: string; // digger.yml workflow
};

export default function ProjectSettings({ project, repositoryName }: ProjectSettingsProps) {
Expand All @@ -48,6 +49,7 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
is_drift_detection_enabled: project.is_drift_detection_enabled || false,
drift_crontab: project.drift_crontab || '',
auto_approve: project.auto_approve || false,
workflow: project.workflow || "default",
},
});

Expand All @@ -66,6 +68,7 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
is_drift_detection_enabled: data.is_drift_detection_enabled,
drift_crontab: data.drift_crontab,
auto_approve: data.auto_approve,
workflow: data.workflow
});
return result;
},
Expand Down Expand Up @@ -136,6 +139,22 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
/>
</motion.div>


<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.15, delay: 0.4 }}
>
<Label htmlFor="workflow">workflow (digger.yml)</Label>
<Controller
name="workflow"
control={control}
render={({ field }) => (
<Input id="workflow" {...field} />
)}
/>
</motion.div>

<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
Expand Down Expand Up @@ -186,7 +205,7 @@ export default function ProjectSettings({ project, repositoryName }: ProjectSett
animate={{ opacity: 1 }}
transition={{ duration: 0.15, delay: 0.4 }}
>
<Label htmlFor="workflow_file">Workflow file</Label>
<Label htmlFor="workflow_file">Workflow file (github action workflow)</Label>
<Controller
name="workflow_file"
control={control}
Expand Down
5 changes: 5 additions & 0 deletions src/data/user/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export const createProjectAction = async ({
labels,
is_drift_detection_enabled,
drift_crontab,
workflow: "default",

}
});
// why are we revalidating paths in a getter query?
Expand Down Expand Up @@ -982,6 +984,7 @@ export async function updateProjectSettingsAction({
is_drift_detection_enabled,
drift_crontab,
auto_approve,
workflow,
}: {
projectId: string;
terraformWorkingDir: string;
Expand All @@ -995,6 +998,7 @@ export async function updateProjectSettingsAction({
is_drift_detection_enabled: boolean;
drift_crontab: string;
auto_approve: boolean;
workflow: string;
}): Promise<SAPayload<projects>> {
const prisma = new PrismaClient();

Expand All @@ -1015,6 +1019,7 @@ export async function updateProjectSettingsAction({
is_drift_detection_enabled,
drift_crontab,
auto_approve,
workflow,
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER table projects add column workflow TEXT default 'default';
Loading