Skip to content

Commit

Permalink
Merge pull request #85 from diggerhq/feat/add-field-for-workflow-in-s…
Browse files Browse the repository at this point in the history
…ettings

feat/add field for workflow in settings
  • Loading branch information
motatoes authored Nov 22, 2024
2 parents ca5a3bd + 79675eb commit f4f3f9a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
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';

0 comments on commit f4f3f9a

Please sign in to comment.