Commit c47d8ab6 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Removed leave buttons from settings dropdowns

Updated specs
parent fc035011
- if current_user - if current_user
- can_admin_group = can?(current_user, :admin_group, @group) - can_admin_group = can?(current_user, :admin_group, @group)
- can_edit = can?(current_user, :admin_group, @group) - can_edit = can?(current_user, :admin_group, @group)
- member = @group.members.find_by(user_id: current_user.id)
- can_leave = member && can?(current_user, :destroy_group_member, member)
- if can_admin_group || can_edit || can_leave - if can_admin_group || can_edit
.controls .controls
.dropdown.group-settings-dropdown .dropdown.group-settings-dropdown
%a.dropdown-new.btn.btn-default#group-settings-button{href: '#', 'data-toggle' => 'dropdown'} %a.dropdown-new.btn.btn-default#group-settings-button{href: '#', 'data-toggle' => 'dropdown'}
...@@ -14,13 +12,7 @@ ...@@ -14,13 +12,7 @@
- if can_admin_group - if can_admin_group
= nav_link(path: 'groups#projects') do = nav_link(path: 'groups#projects') do
= link_to 'Projects', projects_group_path(@group), title: 'Projects' = link_to 'Projects', projects_group_path(@group), title: 'Projects'
- if (can_edit || can_leave) && can_admin_group - if can_edit && can_admin_group
%li.divider %li.divider
- if can_edit
%li %li
= link_to 'Edit Group', edit_group_path(@group) = link_to 'Edit Group', edit_group_path(@group)
- if can_leave
%li
= link_to polymorphic_path([:leave, @group, :members]),
data: { confirm: leave_confirmation_message(@group) }, method: :delete, title: 'Leave group' do
Leave Group
...@@ -6,23 +6,14 @@ ...@@ -6,23 +6,14 @@
= icon('caret-down') = icon('caret-down')
%ul.dropdown-menu.dropdown-menu-align-right %ul.dropdown-menu.dropdown-menu-align-right
- can_edit = can?(current_user, :admin_project, @project) - 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.find_by(user_id: current_user.id)
- can_leave = member && can?(current_user, :destroy_project_member, member)
= render 'layouts/nav/project_settings', can_edit: can_edit = render 'layouts/nav/project_settings', can_edit: can_edit
- if can_edit || can_leave - if can_edit
%li.divider %li.divider
- if can_edit %li
%li = link_to edit_project_path(@project) do
= link_to edit_project_path(@project) do Edit Project
Edit Project
- if can_leave
%li
= link_to polymorphic_path([:leave, @project, :members]),
data: { confirm: leave_confirmation_message(@project) }, method: :delete, title: 'Leave project' do
Leave Project
.scrolling-tabs-container{ class: nav_control_class } .scrolling-tabs-container{ class: nav_control_class }
.fade-left .fade-left
......
- if can?(current_user, :request_access, source) - model_name = source.model_name.to_s.downcase
- if requester = source.requesters.find_by(user_id: current_user.id)
= link_to 'Withdraw Access Request', polymorphic_path([:leave, source, :members]), - if can?(current_user, :"destroy_#{model_name}_member", source.members.find_by(user_id: current_user.id))
method: :delete, = link_to "Leave #{model_name}", polymorphic_path([:leave, source, :members]),
data: { confirm: remove_member_message(requester) }, method: :delete,
class: 'btn' data: { confirm: leave_confirmation_message(source) },
- else class: 'btn'
= link_to 'Request Access', polymorphic_path([:request_access, source, :members]), - elsif requester = source.requesters.find_by(user_id: current_user.id)
method: :post, = link_to 'Withdraw Access Request', polymorphic_path([:leave, source, :members]),
class: 'btn' method: :delete,
data: { confirm: remove_member_message(requester) },
class: 'btn'
- elsif source.request_access_enabled && can?(current_user, :request_access, source)
= link_to 'Request Access', polymorphic_path([:request_access, source, :members]),
method: :post,
class: 'btn'
---
title: Moved Leave Project and Leave Group buttons to access_request_buttons from
the settings dropdown
merge_request: 7600
author:
...@@ -10,7 +10,7 @@ feature 'Groups > Members > Last owner cannot leave group', feature: true do ...@@ -10,7 +10,7 @@ feature 'Groups > Members > Last owner cannot leave group', feature: true do
visit group_path(group) visit group_path(group)
end end
scenario 'user does not see a "Leave Group" link' do scenario 'user does not see a "Leave group" link' do
expect(page).not_to have_content 'Leave Group' expect(page).not_to have_content 'Leave group'
end end
end end
...@@ -13,7 +13,7 @@ feature 'Groups > Members > Member leaves group', feature: true do ...@@ -13,7 +13,7 @@ feature 'Groups > Members > Member leaves group', feature: true do
end end
scenario 'user leaves group' do scenario 'user leaves group' do
click_link 'Leave Group' click_link 'Leave group'
expect(current_path).to eq(dashboard_groups_path) expect(current_path).to eq(dashboard_groups_path)
expect(group.users.exists?(user.id)).to be_falsey expect(group.users.exists?(user.id)).to be_falsey
......
...@@ -29,7 +29,7 @@ feature 'Groups > Members > User requests access', feature: true do ...@@ -29,7 +29,7 @@ feature 'Groups > Members > User requests access', feature: true do
expect(page).to have_content 'Your request for access has been queued for review.' expect(page).to have_content 'Your request for access has been queued for review.'
expect(page).to have_content 'Withdraw Access Request' expect(page).to have_content 'Withdraw Access Request'
expect(page).not_to have_content 'Leave Group' expect(page).not_to have_content 'Leave group'
end end
scenario 'user does not see private projects' do scenario 'user does not see private projects' do
......
...@@ -12,6 +12,6 @@ feature 'Projects > Members > Group member cannot leave group project', feature: ...@@ -12,6 +12,6 @@ feature 'Projects > Members > Group member cannot leave group project', feature:
end end
scenario 'user does not see a "Leave project" link' do scenario 'user does not see a "Leave project" link' do
expect(page).not_to have_content 'Leave Project' expect(page).not_to have_content 'Leave project'
end end
end end
require 'spec_helper' require 'spec_helper'
feature 'Projects > Members > Group requester cannot request access to project', feature: true do feature 'Projects > Members > Group requester cannot request access to project', feature: true, js: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:owner) { create(:user) } let(:owner) { create(:user) }
let(:group) { create(:group, :public, :access_requestable) } let(:group) { create(:group, :public, :access_requestable) }
......
...@@ -11,7 +11,7 @@ feature 'Projects > Members > Member leaves project', feature: true do ...@@ -11,7 +11,7 @@ feature 'Projects > Members > Member leaves project', feature: true do
end end
scenario 'user leaves project' do scenario 'user leaves project' do
click_link 'Leave Project' click_link 'Leave project'
expect(current_path).to eq(dashboard_projects_path) expect(current_path).to eq(dashboard_projects_path)
expect(project.users.exists?(user.id)).to be_falsey expect(project.users.exists?(user.id)).to be_falsey
......
...@@ -8,7 +8,7 @@ feature 'Projects > Members > Owner cannot leave project', feature: true do ...@@ -8,7 +8,7 @@ feature 'Projects > Members > Owner cannot leave project', feature: true do
visit namespace_project_path(project.namespace, project) visit namespace_project_path(project.namespace, project)
end end
scenario 'user does not see a "Leave Project" link' do scenario 'user does not see a "Leave project" link' do
expect(page).not_to have_content 'Leave Project' expect(page).not_to have_content 'Leave project'
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment