Ability to leave group from profile area
This commit is contained in:
parent
7a42decec7
commit
acb402a1c1
|
@ -420,3 +420,8 @@ img.emoji {
|
|||
@extend .light;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.group-name {
|
||||
font-size: 14px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
class Profiles::GroupsController < ApplicationController
|
||||
layout "profile"
|
||||
|
||||
def index
|
||||
@groups = current_user.authorized_groups.all
|
||||
end
|
||||
|
||||
def leave
|
||||
@users_group = group.users_groups.where(user_id: current_user.id).first
|
||||
|
||||
if group.owner == current_user
|
||||
redirect_to(profile_groups_path, alert: "You can't leave group. You must transfer it to another owner before leaving.")
|
||||
else
|
||||
@users_group.destroy
|
||||
redirect_to(profile_groups_path, info: "You left #{group.name} group.")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def group
|
||||
@group ||= Group.find_by_path(params[:id])
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
.flash-container
|
||||
- if alert
|
||||
.alert
|
||||
.alert.alert-error
|
||||
%span= alert
|
||||
|
||||
- elsif notice
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
%span.count= current_user.keys.count
|
||||
= nav_link(path: 'profiles#design') do
|
||||
= link_to "Design", design_profile_path
|
||||
= nav_link(controller: :groups) do
|
||||
= link_to "Groups", profile_groups_path
|
||||
= nav_link(path: 'profiles#history') do
|
||||
= link_to "History", history_profile_path
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
.ui-box
|
||||
%h5.title Groups
|
||||
%ul.well-list
|
||||
- @groups.each do |group|
|
||||
%li
|
||||
.pull-right
|
||||
- if can?(current_user, :manage_group, group)
|
||||
= link_to edit_group_path(group), class: "btn-small btn grouped" do
|
||||
%i.icon-cogs
|
||||
Settings
|
||||
|
||||
= link_to leave_profile_group_path(group), confirm: "Are you sure you want to leave #{group.name} group?", method: :delete, class: "btn-small btn grouped", title: 'Remove user from group' do
|
||||
%i.icon-signout
|
||||
Leave
|
||||
|
||||
= link_to group, class: 'group-name' do
|
||||
= group.name
|
|
@ -13,6 +13,7 @@
|
|||
- else
|
||||
= member.human_access
|
||||
|
||||
- if show_controls && user != current_user && user != @group.owner
|
||||
- if show_controls && user != @group.owner && user != current_user
|
||||
= link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
|
||||
%i.icon-minus.icon-white
|
||||
|
||||
|
|
|
@ -116,6 +116,11 @@ Gitlab::Application.routes.draw do
|
|||
resource :notifications, only: [:show, :update]
|
||||
resource :password, only: [:new, :create]
|
||||
resources :keys
|
||||
resources :groups, only: [:index] do
|
||||
member do
|
||||
delete :leave
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue