Commit acb402a1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Ability to leave group from profile area

parent 7a42dece
......@@ -420,3 +420,8 @@ img.emoji {
@extend .light;
margin-bottom: 10px;
}
.group-name {
font-size: 14px;
line-height: 24px;
}
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
.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
.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
......
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