summaryrefslogtreecommitdiff
path: root/app/serializers/project_access_token_entity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/project_access_token_entity.rb')
-rw-r--r--app/serializers/project_access_token_entity.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/serializers/project_access_token_entity.rb b/app/serializers/project_access_token_entity.rb
new file mode 100644
index 00000000000..b317057c952
--- /dev/null
+++ b/app/serializers/project_access_token_entity.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+# rubocop: disable Gitlab/NamespacedClass
+class ProjectAccessTokenEntity < API::Entities::PersonalAccessToken
+ include Gitlab::Routing
+
+ expose :revoke_path do |token, options|
+ project = options.fetch(:project)
+
+ next unless project
+
+ revoke_namespace_project_settings_access_token_path(
+ id: token,
+ namespace_id: project.namespace.path,
+ project_id: project.path)
+ end
+
+ expose :access_level do |token, options|
+ project = options.fetch(:project)
+
+ next unless project
+ next unless token.user
+
+ project.member(token.user)&.access_level
+ end
+end
+# rubocop: enable Gitlab/NamespacedClass