From b5113854651c9fb20ff280b10ac1d6b756c64e56 Mon Sep 17 00:00:00 2001 From: fiftin Date: Sun, 23 Jun 2024 23:59:14 +0500 Subject: [PATCH] feat(schedule): don't show repo commit check schedules --- db/bolt/schedule.go | 5 +- db/sql/schedule.go | 2 +- web/src/components/TemplateForm.vue | 78 ++++++++++++++++------------- web/src/views/project/Schedule.vue | 33 +++++++++++- 4 files changed, 80 insertions(+), 38 deletions(-) diff --git a/db/bolt/schedule.go b/db/bolt/schedule.go index a9083091..954f4ad6 100644 --- a/db/bolt/schedule.go +++ b/db/bolt/schedule.go @@ -32,7 +32,10 @@ func (d *BoltDb) getProjectSchedules(projectID int) (schedules []db.Schedule, er } func (d *BoltDb) GetProjectSchedules(projectID int) (schedules []db.ScheduleWithTpl, err error) { - err = d.getObjects(projectID, db.ScheduleProps, db.RetrieveQueryParams{}, nil, &schedules) + err = d.getObjects(projectID, db.ScheduleProps, db.RetrieveQueryParams{}, func(referringObj interface{}) bool { + s := referringObj.(db.ScheduleWithTpl) + return s.RepositoryID == nil + }, &schedules) return } diff --git a/db/sql/schedule.go b/db/sql/schedule.go index d4702269..d7738964 100644 --- a/db/sql/schedule.go +++ b/db/sql/schedule.go @@ -76,7 +76,7 @@ func (d *SqlDb) GetProjectSchedules(projectID int) (schedules []db.ScheduleWithT _, err = d.selectAll(&schedules, "SELECT ps.*, pt.name as tpl_name FROM project__schedule ps "+ "JOIN project__template pt ON pt.id = ps.template_id "+ - "WHERE ps.project_id=?", + "WHERE ps.repository_id IS NULL AND ps.project_id=?", projectID) return } diff --git a/web/src/components/TemplateForm.vue b/web/src/components/TemplateForm.vue index fb484b2d..70a752ab 100644 --- a/web/src/components/TemplateForm.vue +++ b/web/src/components/TemplateForm.vue @@ -238,34 +238,16 @@ dense > - - - - + + - - {{ $t('iWantToRunATaskByTheCronOnlyForForNewCommitsOfSome') }} - - + + + - - {{ $t('readThe') }} - {{ $t('docs') }} - {{ $t('toLearnMoreAboutCron') }} - - 0) { + const schedule = this.schedules.find((s) => s.repository_id != null); + if (schedule != null) { + this.cronFormat = schedule.cron_format; + this.cronRepositoryId = schedule.repository_id; + this.cronRepositoryIdVisible = this.cronRepositoryId != null; + } } this.itemTypeIndex = Object.keys(TEMPLATE_TYPE_ICONS).indexOf(this.item.type); @@ -566,7 +576,7 @@ export default { } } else if (this.schedules.length > 1) { // do nothing - } else if (this.cronFormat == null || this.cronFormat === '') { + } else if (this.cronFormat == null || this.cronFormat === '' || !this.cronRepositoryIdVisible) { // drop schedule await axios({ method: 'delete', diff --git a/web/src/views/project/Schedule.vue b/web/src/views/project/Schedule.vue index 0862cea9..6b2f2664 100644 --- a/web/src/views/project/Schedule.vue +++ b/web/src/views/project/Schedule.vue @@ -52,6 +52,16 @@ class="mt-4" :items-per-page="Number.MAX_VALUE" > + + + + @@ -78,16 +102,21 @@