summaryrefslogtreecommitdiff
path: root/app/presenters
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-12-05 15:03:16 +0100
committerRémy Coutable <remy@rymai.me>2017-12-12 18:14:58 +0100
commit50d7c356c2d1622203b518bf0f3d5cbf1860099a (patch)
tree4b591c06bb2eea41304985062150c5db4cd5ea67 /app/presenters
parent2cf3fc18a6e111a820f9842bb1d939790e8625eb (diff)
downloadgitlab-ce-50d7c356c2d1622203b518bf0f3d5cbf1860099a.tar.gz
Present member collection at the controller leveltmlee/gitlab-ce-28004-consider-refactoring-member-view-by-using-presenter
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/member_presenter.rb10
-rw-r--r--app/presenters/members_presenter.rb15
2 files changed, 19 insertions, 6 deletions
diff --git a/app/presenters/member_presenter.rb b/app/presenters/member_presenter.rb
index a8732226018..7d2f9303b8f 100644
--- a/app/presenters/member_presenter.rb
+++ b/app/presenters/member_presenter.rb
@@ -1,8 +1,10 @@
class MemberPresenter < Gitlab::View::Presenter::Delegated
- include Gitlab::Allowable
-
presents :member
+ def access_level_roles
+ member.class.access_level_roles
+ end
+
def can_resend_invite?
invite? &&
can?(current_user, admin_member_permission, source)
@@ -12,10 +14,6 @@ class MemberPresenter < Gitlab::View::Presenter::Delegated
can?(current_user, update_member_permission, member)
end
- def cannot_update?
- !can_update?
- end
-
def can_remove?
can?(current_user, destroy_member_permission, member)
end
diff --git a/app/presenters/members_presenter.rb b/app/presenters/members_presenter.rb
new file mode 100644
index 00000000000..e4aba37b69e
--- /dev/null
+++ b/app/presenters/members_presenter.rb
@@ -0,0 +1,15 @@
+class MembersPresenter < Gitlab::View::Presenter::Delegated
+ include Enumerable
+
+ presents :members
+
+ def to_ary
+ to_a
+ end
+
+ def each
+ members.each do |member|
+ yield member.present(current_user: current_user)
+ end
+ end
+end