2018-07-19 18:43:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-23 15:10:07 +00:00
|
|
|
class RunnerEntity < Grape::Entity
|
2017-05-26 08:31:42 +00:00
|
|
|
include RequestAwareEntity
|
|
|
|
|
2021-04-16 00:09:09 +00:00
|
|
|
expose :id, :description, :short_sha
|
2017-05-26 08:31:42 +00:00
|
|
|
|
2018-09-05 11:49:39 +00:00
|
|
|
expose :edit_path, if: -> (*) { can_edit_runner? } do |runner|
|
2017-06-29 17:06:35 +00:00
|
|
|
edit_project_runner_path(project, runner)
|
2017-05-26 08:31:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-05-29 07:58:20 +00:00
|
|
|
alias_method :runner, :object
|
|
|
|
|
2017-05-26 08:31:42 +00:00
|
|
|
def project
|
|
|
|
request.project
|
|
|
|
end
|
2018-09-05 11:49:39 +00:00
|
|
|
|
|
|
|
def can_edit_runner?
|
|
|
|
can?(request.current_user, :update_runner, runner) && runner.project_type?
|
|
|
|
end
|
2017-05-23 15:10:07 +00:00
|
|
|
end
|