Improve displaying validation messages for runner
This commit is contained in:
parent
2ee24bd9ec
commit
9fd6f1b600
3 changed files with 13 additions and 4 deletions
|
@ -20,7 +20,6 @@ class Projects::RunnersController < Projects::ApplicationController
|
|||
if @runner.update_attributes(runner_params)
|
||||
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
||||
else
|
||||
flash[:alert] = @runner.errors.full_messages.to_sentence
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,9 +27,9 @@ module Ci
|
|||
end
|
||||
|
||||
validate do |runner|
|
||||
if runner.tag_list.empty? && !runner.run_untagged?
|
||||
errors.add(:tags_errors,
|
||||
'Runner without tags must be able to pick untagged jobs!')
|
||||
unless runner.has_tags? || runner.run_untagged?
|
||||
errors.add(:tags_list,
|
||||
'can not be empty when runner is not allowed to pick untagged jobs')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,5 +103,9 @@ module Ci
|
|||
def short_sha
|
||||
token[0...8] if token
|
||||
end
|
||||
|
||||
def has_tags?
|
||||
tag_list.any?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
- page_title "Edit", "#{@runner.description} ##{@runner.id}", "Runners"
|
||||
|
||||
%h4 Runner ##{@runner.id}
|
||||
|
||||
- if @runner.errors.any?
|
||||
.error-message.js-errors
|
||||
- @runner.errors.full_messages.each do |error|
|
||||
%div= error
|
||||
|
||||
%hr
|
||||
= render 'form', runner: @runner, runner_form_url: runner_path(@runner)
|
||||
|
|
Loading…
Reference in a new issue