diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-25 15:09:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-25 15:09:06 +0300 |
commit | cc1e91be1cd930f58baebb89f2ff1893045a2aea (patch) | |
tree | ad35ee30978a657f17d87fcd569f35337b96da12 /app/serializers | |
parent | 012ed4e4f69ab58f9d9b58140865a734fa5a9c88 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/group_access_token_entity.rb | 26 | ||||
-rw-r--r-- | app/serializers/group_access_token_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/personal_access_token_entity.rb | 11 | ||||
-rw-r--r-- | app/serializers/personal_access_token_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/project_access_token_entity.rb | 27 | ||||
-rw-r--r-- | app/serializers/project_access_token_serializer.rb | 7 |
6 files changed, 85 insertions, 0 deletions
diff --git a/app/serializers/group_access_token_entity.rb b/app/serializers/group_access_token_entity.rb new file mode 100644 index 00000000000..e832eef1188 --- /dev/null +++ b/app/serializers/group_access_token_entity.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# rubocop: disable Gitlab/NamespacedClass +class GroupAccessTokenEntity < API::Entities::PersonalAccessToken + include Gitlab::Routing + + expose :revoke_path do |token, options| + group = options.fetch(:group) + + next unless group + + revoke_group_settings_access_token_path( + id: token, + group_id: group.path) + end + + expose :access_level do |token, options| + group = options.fetch(:group) + + next unless group + next unless token.user + + group.member(token.user)&.access_level + end +end +# rubocop: enable Gitlab/NamespacedClass diff --git a/app/serializers/group_access_token_serializer.rb b/app/serializers/group_access_token_serializer.rb new file mode 100644 index 00000000000..55f6de77844 --- /dev/null +++ b/app/serializers/group_access_token_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# rubocop: disable Gitlab/NamespacedClass +class GroupAccessTokenSerializer < BaseSerializer + entity GroupAccessTokenEntity +end +# rubocop: enable Gitlab/NamespacedClass diff --git a/app/serializers/personal_access_token_entity.rb b/app/serializers/personal_access_token_entity.rb new file mode 100644 index 00000000000..acd06fecd12 --- /dev/null +++ b/app/serializers/personal_access_token_entity.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# rubocop: disable Gitlab/NamespacedClass +class PersonalAccessTokenEntity < API::Entities::PersonalAccessToken + include Gitlab::Routing + + expose :revoke_path do |token, options| + revoke_profile_personal_access_token_path(token) + end +end +# rubocop: enable Gitlab/NamespacedClass diff --git a/app/serializers/personal_access_token_serializer.rb b/app/serializers/personal_access_token_serializer.rb new file mode 100644 index 00000000000..0a59fa117f9 --- /dev/null +++ b/app/serializers/personal_access_token_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# rubocop: disable Gitlab/NamespacedClass +class PersonalAccessTokenSerializer < BaseSerializer + entity PersonalAccessTokenEntity +end +# rubocop: enable Gitlab/NamespacedClass 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 diff --git a/app/serializers/project_access_token_serializer.rb b/app/serializers/project_access_token_serializer.rb new file mode 100644 index 00000000000..97db088cf64 --- /dev/null +++ b/app/serializers/project_access_token_serializer.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# rubocop: disable Gitlab/NamespacedClass +class ProjectAccessTokenSerializer < BaseSerializer + entity ProjectAccessTokenEntity +end +# rubocop: enable Gitlab/NamespacedClass |