Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /app/serializers/runner_entity.rb
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'app/serializers/runner_entity.rb')
-rw-r--r--app/serializers/runner_entity.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/app/serializers/runner_entity.rb b/app/serializers/runner_entity.rb
index 6d6ba920a3b..cf0b2e2c3f6 100644
--- a/app/serializers/runner_entity.rb
+++ b/app/serializers/runner_entity.rb
@@ -9,6 +9,10 @@ class RunnerEntity < Grape::Entity
edit_project_runner_path(project, runner)
end
+ expose :admin_path, if: -> (*) { can_admin_runner? } do |runner|
+ Gitlab::Routing.url_helpers.admin_runner_url(runner)
+ end
+
private
alias_method :runner, :object
@@ -17,7 +21,17 @@ class RunnerEntity < Grape::Entity
request.project
end
+ def current_user
+ request.current_user
+ end
+
def can_edit_runner?
- can?(request.current_user, :update_runner, runner) && runner.project_type?
+ can?(current_user, :update_runner, runner) && runner.project_type?
+ end
+
+ # can_admin_all_resources? is used here because the
+ # path exposed is only available to admins
+ def can_admin_runner?
+ current_user&.can_admin_all_resources?
end
end