Skip to content

Commit

Permalink
fix(schedule): disallow empty schedule name
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Jun 25, 2023
1 parent 22f070d commit c8eb703
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/i18n/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export default {
trigger_success: 'Schedule Triggered'
},
edit: {
new: 'New Schedule'
new: 'New Schedule',
empty_name: 'Schedule Name cannot be empty'
}
},
air: {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locale/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export default {
trigger_success: '定时任务执行完成'
},
edit: {
new: '新建定时任务'
new: '新建定时任务',
empty_name: '定时任务名称不能为空'
}
},
air: {
Expand Down
5 changes: 5 additions & 0 deletions src/pages/schedule/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export default {
'deleteSchedule'
]),
handleUpdate() {
/** @type {ApiTypes.V3.Schedule} */
const schedule = this.$refs.detail.getSchedule();
if (schedule.name.trim().length <= 0) {
this.$message.error(this.$t('schedule.edit.empty_name'));
return;
}
this.updateSchedule(schedule)
.then(() => this.$router.push({ name: 'schedule/view', params: { id: this.schedule.id } }))
.catch(e => this.$message.error(this.$t('plan.edit.update_failed', { code: e.status })));
Expand Down
5 changes: 5 additions & 0 deletions src/pages/schedule/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export default {
'createSchedule'
]),
handleCreate() {
/** @type {ApiTypes.V3.Schedule} */
const schedule = this.$refs.detail.getSchedule();
if (schedule.name.trim().length <= 0) {
this.$message.error(this.$t('schedule.edit.empty_name'));
return;
}
this.createSchedule(schedule)
.then(p => this.$router.push({ name: 'schedule/view', params: { id: p.id } }))
.catch(e => this.$message.error(this.$t('plan.edit.create_failed', { code: e.status })));
Expand Down

0 comments on commit c8eb703

Please sign in to comment.