diff options
author | Rémy Coutable <remy@rymai.me> | 2016-06-18 06:44:15 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-06-18 07:06:34 +0300 |
commit | bceee987134ad578b3d6f89c9bc61bef8e0c6066 (patch) | |
tree | 7a108b77c628bf8eddd8f35e5272d9db2c40159e /app/views | |
parent | 654565c9dc734a597c525a75c8f72dd63235604b (diff) |
Show 'Leave project' only if member can actually leave the project
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/layouts/nav/_project.html.haml | 11 | ||||
-rw-r--r-- | app/views/layouts/nav/_project_settings.html.haml | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index 39ea4920ccc..a9289a8552a 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -5,19 +5,20 @@ = icon('cog') = icon('caret-down') %ul.dropdown-menu.dropdown-menu-align-right - - is_project_member = @project.users.exists?(current_user.id) - - access = @project.team.max_member_access(current_user.id) - can_edit = can?(current_user, :admin_project, @project) + -# We don't use @project.team.find_member because it searches for group members too... + - member = @project.members.non_request.find_by(user_id: current_user.id) + - can_leave = member && can?(current_user, :destroy_project_member, member) - = render 'layouts/nav/project_settings', access: access, can_edit: can_edit + = render 'layouts/nav/project_settings', can_edit: can_edit - - if can_edit || is_project_member + - if can_edit || can_leave %li.divider - if can_edit %li = link_to edit_project_path(@project) do Edit Project - - if is_project_member + - if can_leave %li = link_to polymorphic_path([:leave, @project, :members]), data: { confirm: leave_confirmation_message(@project) }, method: :delete, title: 'Leave project' do diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml index 13d32bd1354..51a54b4f262 100644 --- a/app/views/layouts/nav/_project_settings.html.haml +++ b/app/views/layouts/nav/_project_settings.html.haml @@ -3,7 +3,7 @@ = link_to namespace_project_project_members_path(@project.namespace, @project), title: 'Members', class: 'team-tab tab' do %span Members -- if access && can_edit +- if can_edit - if @project.allowed_to_share_with_group? = nav_link(controller: :group_links) do = link_to namespace_project_group_links_path(@project.namespace, @project), title: "Groups" do |