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