Commit acb402a1c1cfb23613be0f988b60884c352de37c
1 parent
7a42dece
Exists in
master
and in
4 other branches
Ability to leave group from profile area
Showing
7 changed files
with
56 additions
and
2 deletions
Show diff stats
app/assets/stylesheets/common.scss
| @@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
| 1 | +class Profiles::GroupsController < ApplicationController | ||
| 2 | + layout "profile" | ||
| 3 | + | ||
| 4 | + def index | ||
| 5 | + @groups = current_user.authorized_groups.all | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + def leave | ||
| 9 | + @users_group = group.users_groups.where(user_id: current_user.id).first | ||
| 10 | + | ||
| 11 | + if group.owner == current_user | ||
| 12 | + redirect_to(profile_groups_path, alert: "You can't leave group. You must transfer it to another owner before leaving.") | ||
| 13 | + else | ||
| 14 | + @users_group.destroy | ||
| 15 | + redirect_to(profile_groups_path, info: "You left #{group.name} group.") | ||
| 16 | + end | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | + private | ||
| 20 | + | ||
| 21 | + def group | ||
| 22 | + @group ||= Group.find_by_path(params[:id]) | ||
| 23 | + end | ||
| 24 | +end |
app/views/layouts/_flash.html.haml
app/views/layouts/nav/_profile.html.haml
| @@ -12,6 +12,8 @@ | @@ -12,6 +12,8 @@ | ||
| 12 | %span.count= current_user.keys.count | 12 | %span.count= current_user.keys.count |
| 13 | = nav_link(path: 'profiles#design') do | 13 | = nav_link(path: 'profiles#design') do |
| 14 | = link_to "Design", design_profile_path | 14 | = link_to "Design", design_profile_path |
| 15 | + = nav_link(controller: :groups) do | ||
| 16 | + = link_to "Groups", profile_groups_path | ||
| 15 | = nav_link(path: 'profiles#history') do | 17 | = nav_link(path: 'profiles#history') do |
| 16 | = link_to "History", history_profile_path | 18 | = link_to "History", history_profile_path |
| 17 | 19 |
| @@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
| 1 | +.ui-box | ||
| 2 | + %h5.title Groups | ||
| 3 | + %ul.well-list | ||
| 4 | + - @groups.each do |group| | ||
| 5 | + %li | ||
| 6 | + .pull-right | ||
| 7 | + - if can?(current_user, :manage_group, group) | ||
| 8 | + = link_to edit_group_path(group), class: "btn-small btn grouped" do | ||
| 9 | + %i.icon-cogs | ||
| 10 | + Settings | ||
| 11 | + | ||
| 12 | + = 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 | ||
| 13 | + %i.icon-signout | ||
| 14 | + Leave | ||
| 15 | + | ||
| 16 | + = link_to group, class: 'group-name' do | ||
| 17 | + = group.name |
app/views/users_groups/_users_group.html.haml
| @@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
| 13 | - else | 13 | - else |
| 14 | = member.human_access | 14 | = member.human_access |
| 15 | 15 | ||
| 16 | - - if show_controls && user != current_user && user != @group.owner | 16 | + - if show_controls && user != @group.owner && user != current_user |
| 17 | = 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 | 17 | = 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 |
| 18 | %i.icon-minus.icon-white | 18 | %i.icon-minus.icon-white |
| 19 | + |
config/routes.rb
| @@ -116,6 +116,11 @@ Gitlab::Application.routes.draw do | @@ -116,6 +116,11 @@ Gitlab::Application.routes.draw do | ||
| 116 | resource :notifications, only: [:show, :update] | 116 | resource :notifications, only: [:show, :update] |
| 117 | resource :password, only: [:new, :create] | 117 | resource :password, only: [:new, :create] |
| 118 | resources :keys | 118 | resources :keys |
| 119 | + resources :groups, only: [:index] do | ||
| 120 | + member do | ||
| 121 | + delete :leave | ||
| 122 | + end | ||
| 123 | + end | ||
| 119 | end | 124 | end |
| 120 | end | 125 | end |
| 121 | 126 |