diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /app/graphql/resolvers/clusters | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'app/graphql/resolvers/clusters')
-rw-r--r-- | app/graphql/resolvers/clusters/agent_activity_events_resolver.rb | 25 | ||||
-rw-r--r-- | app/graphql/resolvers/clusters/agents_resolver.rb | 5 |
2 files changed, 29 insertions, 1 deletions
diff --git a/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb b/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb new file mode 100644 index 00000000000..b6fec3d3772 --- /dev/null +++ b/app/graphql/resolvers/clusters/agent_activity_events_resolver.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Resolvers + module Clusters + class AgentActivityEventsResolver < BaseResolver + type Types::Clusters::AgentActivityEventType, null: true + + alias_method :agent, :object + + delegate :project, to: :agent + + def resolve(**args) + return ::Clusters::Agents::ActivityEvent.none unless can_view_activity_events? + + agent.activity_events + end + + private + + def can_view_activity_events? + current_user.can?(:admin_cluster, project) + end + end + end +end diff --git a/app/graphql/resolvers/clusters/agents_resolver.rb b/app/graphql/resolvers/clusters/agents_resolver.rb index 9b8cea52e3b..5ad66ed7cdd 100644 --- a/app/graphql/resolvers/clusters/agents_resolver.rb +++ b/app/graphql/resolvers/clusters/agents_resolver.rb @@ -28,7 +28,10 @@ module Resolvers private def preloads - { tokens: :last_used_agent_tokens } + { + activity_events: { activity_events: [:user, agent_token: :agent] }, + tokens: :last_used_agent_tokens + } end end end |