diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-12 19:22:03 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-12 19:22:03 +0400 |
commit | acb402a1c1cfb23613be0f988b60884c352de37c (patch) | |
tree | 5b2edb93552e1fc032e1386d572a2c8bf3e6f563 | |
parent | 7a42decec7a58c4824a1b951368d19b4ba3336dd (diff) |
Ability to leave group from profile area
-rw-r--r-- | app/assets/stylesheets/common.scss | 5 | ||||
-rw-r--r-- | app/controllers/profiles/groups_controller.rb | 24 | ||||
-rw-r--r-- | app/views/layouts/_flash.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/nav/_profile.html.haml | 2 | ||||
-rw-r--r-- | app/views/profiles/groups/index.html.haml | 17 | ||||
-rw-r--r-- | app/views/users_groups/_users_group.html.haml | 3 | ||||
-rw-r--r-- | config/routes.rb | 5 |
7 files changed, 56 insertions, 2 deletions
diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 16d14a3c9e2..d6386dbb6fc 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -420,3 +420,8 @@ img.emoji { @extend .light; margin-bottom: 10px; } + +.group-name { + font-size: 14px; + line-height: 24px; +} diff --git a/app/controllers/profiles/groups_controller.rb b/app/controllers/profiles/groups_controller.rb new file mode 100644 index 00000000000..ac635f61feb --- /dev/null +++ b/app/controllers/profiles/groups_controller.rb @@ -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 diff --git a/app/views/layouts/_flash.html.haml b/app/views/layouts/_flash.html.haml index a3bed593e1c..f9ef068d18d 100644 --- a/app/views/layouts/_flash.html.haml +++ b/app/views/layouts/_flash.html.haml @@ -1,6 +1,6 @@ .flash-container - if alert - .alert + .alert.alert-error %span= alert - elsif notice diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index c2db7067e44..7c3acfc398a 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -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 diff --git a/app/views/profiles/groups/index.html.haml b/app/views/profiles/groups/index.html.haml new file mode 100644 index 00000000000..c07c0355b4b --- /dev/null +++ b/app/views/profiles/groups/index.html.haml @@ -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 diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml index 3a1e32dd79d..d3d08dd5dea 100644 --- a/app/views/users_groups/_users_group.html.haml +++ b/app/views/users_groups/_users_group.html.haml @@ -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 + diff --git a/config/routes.rb b/config/routes.rb index f319ef221df..53476e6b241 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 |