diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /app/graphql/types/ci/runner_web_url_edge.rb | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'app/graphql/types/ci/runner_web_url_edge.rb')
-rw-r--r-- | app/graphql/types/ci/runner_web_url_edge.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/graphql/types/ci/runner_web_url_edge.rb b/app/graphql/types/ci/runner_web_url_edge.rb new file mode 100644 index 00000000000..3b9fdfd1571 --- /dev/null +++ b/app/graphql/types/ci/runner_web_url_edge.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + class RunnerWebUrlEdge < GraphQL::Types::Relay::BaseEdge + include FindClosest + + field :web_url, GraphQL::Types::String, null: true, + description: 'Web URL of the runner. The value depends on where you put this field in the query. You can use it for projects or groups.', + extras: [:parent] + + def initialize(node, connection) + super + + @runner = node.node + end + + def web_url(parent:) + owner = closest_parent([::Types::ProjectType, ::Types::GroupType], parent) + + case owner + when ::Group + Gitlab::Routing.url_helpers.group_runner_url(owner, @runner) + when ::Project + Gitlab::Routing.url_helpers.project_runner_url(owner, @runner) + end + end + end + end +end |