diff options
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/deployment_entity.rb | 1 | ||||
-rw-r--r-- | app/serializers/environment_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/environment_status_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/group_link/group_group_link_entity.rb | 16 | ||||
-rw-r--r-- | app/serializers/group_link/group_link_entity.rb | 27 | ||||
-rw-r--r-- | app/serializers/group_link/project_group_link_entity.rb | 12 | ||||
-rw-r--r-- | app/serializers/issue_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/member_user_entity.rb | 3 | ||||
-rw-r--r-- | app/serializers/merge_request_noteable_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/merge_request_serializer.rb | 2 |
10 files changed, 43 insertions, 26 deletions
diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index 020c66af777..f63a1bf094a 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -23,6 +23,7 @@ class DeploymentEntity < Grape::Entity expose :tag expose :last? expose :last?, as: :is_last + expose :tier_in_yaml expose :deployed_by, as: :user, using: UserEntity diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index d484f60ed8f..634be365a9d 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -18,7 +18,7 @@ class EnvironmentEntity < Grape::Entity expose :environment_type expose :name_without_type expose :last_deployment, using: DeploymentEntity - expose :stop_action_available?, as: :has_stop_action + expose :stop_actions_available?, as: :has_stop_action expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: RolloutStatusEntity expose :tier diff --git a/app/serializers/environment_status_entity.rb b/app/serializers/environment_status_entity.rb index 40db23c143e..e8cf7980f5e 100644 --- a/app/serializers/environment_status_entity.rb +++ b/app/serializers/environment_status_entity.rb @@ -16,7 +16,7 @@ class EnvironmentStatusEntity < Grape::Entity end expose :metrics_monitoring_url, if: ->(*) { can_read_environment? } do |es| - environment_metrics_path(es.environment) + project_metrics_dashboard_path(es.project, environment: es.environment) end expose :stop_url, if: ->(*) { can_stop_environment? } do |es| diff --git a/app/serializers/group_link/group_group_link_entity.rb b/app/serializers/group_link/group_group_link_entity.rb index cedc8bd8582..563a75ccdaa 100644 --- a/app/serializers/group_link/group_group_link_entity.rb +++ b/app/serializers/group_link/group_group_link_entity.rb @@ -4,22 +4,14 @@ module GroupLink class GroupGroupLinkEntity < GroupLink::GroupLinkEntity include RequestAwareEntity - expose :can_update do |group_link| - can_manage?(group_link) - end - - expose :can_remove do |group_link| - can_manage?(group_link) + expose :source do |group_link| + GroupEntity.represent(group_link.shared_from, only: [:id, :full_name, :web_url]) end private - def current_user - options[:current_user] - end - - def can_manage?(group_link) - can?(current_user, :admin_group_member, group_link.shared_group) + def admin_permission_name + :admin_group_member end end end diff --git a/app/serializers/group_link/group_link_entity.rb b/app/serializers/group_link/group_link_entity.rb index 12349320b6f..73c9931fc70 100644 --- a/app/serializers/group_link/group_link_entity.rb +++ b/app/serializers/group_link/group_link_entity.rb @@ -30,5 +30,32 @@ module GroupLink expose :shared_with_group, merge: true, using: GroupBasicEntity end + + expose :can_update do |group_link, options| + can_admin_shared_from?(group_link, options) + end + + expose :can_remove do |group_link, options| + can_admin_shared_from?(group_link, options) + end + + expose :is_direct_member do |group_link, options| + direct_member?(group_link, options) + end + + private + + def current_user + options[:current_user] + end + + def direct_member?(group_link, options) + group_link.shared_from == options[:source] + end + + def can_admin_shared_from?(group_link, options) + direct_member?(group_link, options) && + can?(current_user, admin_permission_name, group_link.shared_from) + end end end diff --git a/app/serializers/group_link/project_group_link_entity.rb b/app/serializers/group_link/project_group_link_entity.rb index bcdafd8d685..c667bcd5bf4 100644 --- a/app/serializers/group_link/project_group_link_entity.rb +++ b/app/serializers/group_link/project_group_link_entity.rb @@ -4,18 +4,14 @@ module GroupLink class ProjectGroupLinkEntity < GroupLink::GroupLinkEntity include RequestAwareEntity - expose :can_update do |group_link| - can?(current_user, :admin_project_member, group_link.project) - end - - expose :can_remove do |group_link| - can?(current_user, :admin_project_member, group_link.project) + expose :source do |group_link| + ProjectEntity.represent(group_link.shared_from, only: [:id, :full_name]) end private - def current_user - options[:current_user] + def admin_permission_name + :admin_project_member end end end diff --git a/app/serializers/issue_entity.rb b/app/serializers/issue_entity.rb index 773bbf268eb..fbcfcf84d9b 100644 --- a/app/serializers/issue_entity.rb +++ b/app/serializers/issue_entity.rb @@ -61,7 +61,7 @@ class IssueEntity < IssuableEntity end expose :locked_discussion_docs_path, if: -> (issue) { issue.discussion_locked? } do |issue| - help_page_path('user/discussions/index.md', anchor: 'lock-discussions') + help_page_path('user/discussions/index.md', anchor: 'prevent-comments-by-locking-an-issue') end expose :is_project_archived do |issue| diff --git a/app/serializers/member_user_entity.rb b/app/serializers/member_user_entity.rb index fde3282ad25..b3d8efc9143 100644 --- a/app/serializers/member_user_entity.rb +++ b/app/serializers/member_user_entity.rb @@ -5,6 +5,9 @@ class MemberUserEntity < UserEntity unexpose :state unexpose :status_tooltip_html + expose :created_at + expose :last_activity_on + expose :avatar_url do |user| user.avatar_url(size: Member::AVATAR_SIZE, only_path: false) end diff --git a/app/serializers/merge_request_noteable_entity.rb b/app/serializers/merge_request_noteable_entity.rb index a356b5b5cd4..f8c8e3538da 100644 --- a/app/serializers/merge_request_noteable_entity.rb +++ b/app/serializers/merge_request_noteable_entity.rb @@ -43,7 +43,7 @@ class MergeRequestNoteableEntity < IssuableEntity end expose :locked_discussion_docs_path, if: -> (merge_request) { merge_request.discussion_locked? } do |merge_request| - help_page_path('user/discussions/index.md', anchor: 'lock-discussions') + help_page_path('user/discussions/index.md', anchor: 'prevent-comments-by-locking-an-issue') end expose :is_project_archived do |merge_request| diff --git a/app/serializers/merge_request_serializer.rb b/app/serializers/merge_request_serializer.rb index e8fc18e6cf3..9fd50c8c51d 100644 --- a/app/serializers/merge_request_serializer.rb +++ b/app/serializers/merge_request_serializer.rb @@ -27,5 +27,3 @@ class MergeRequestSerializer < BaseSerializer super(merge_request, opts, entity) end end - -MergeRequestSerializer.prepend_mod_with('MergeRequestSerializer') |