Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
84371de0
Commit
84371de0
authored
Mar 13, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move group leave action from dashboard/groups to groups/group_members.
parent
224187ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
25 deletions
+18
-25
app/controllers/dashboard/groups_controller.rb
app/controllers/dashboard/groups_controller.rb
+1
-17
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+11
-0
app/views/dashboard/groups/index.html.haml
app/views/dashboard/groups/index.html.haml
+1
-1
app/views/groups/group_members/_group_member.html.haml
app/views/groups/group_members/_group_member.html.haml
+3
-2
config/routes.rb
config/routes.rb
+2
-5
No files found.
app/controllers/dashboard/groups_controller.rb
View file @
84371de0
class
Dashboard::GroupsController
<
ApplicationController
class
Dashboard::GroupsController
<
ApplicationController
def
index
def
index
@user_groups
=
current_user
.
group_members
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
@group_members
=
current_user
.
group_members
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
def
leave
@users_group
=
group
.
group_members
.
where
(
user_id:
current_user
.
id
).
first
if
can?
(
current_user
,
:destroy
,
@users_group
)
@users_group
.
destroy
redirect_to
(
dashboard_groups_path
,
info:
"You left
#{
group
.
name
}
group."
)
else
return
render_403
end
end
private
def
group
@group
||=
Group
.
find_by
(
path:
params
[
:id
])
end
end
end
end
app/controllers/groups/group_members_controller.rb
View file @
84371de0
...
@@ -46,6 +46,17 @@ class Groups::GroupMembersController < Groups::ApplicationController
...
@@ -46,6 +46,17 @@ class Groups::GroupMembersController < Groups::ApplicationController
end
end
end
end
def
leave
@group_member
=
@group
.
group_members
.
where
(
user_id:
current_user
.
id
).
first
if
can?
(
current_user
,
:destroy_group_member
,
@group_member
)
@group_member
.
destroy
redirect_to
(
dashboard_groups_path
,
info:
"You left
#{
group
.
name
}
group."
)
else
return
render_403
end
end
protected
protected
def
group
def
group
...
...
app/views/dashboard/groups/index.html.haml
View file @
84371de0
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
Settings
Settings
-
if
can?
(
current_user
,
:destroy_group_member
,
group_member
)
-
if
can?
(
current_user
,
:destroy_group_member
,
group_member
)
=
link_to
leave_
dashboard_group
_path
(
group
),
data:
{
confirm:
leave_group_message
(
group
.
name
)
},
method: :delete
,
class:
"btn-sm btn btn-grouped"
,
title:
'Remove user from group'
do
=
link_to
leave_
group_group_members
_path
(
group
),
data:
{
confirm:
leave_group_message
(
group
.
name
)
},
method: :delete
,
class:
"btn-sm btn btn-grouped"
,
title:
'Remove user from group'
do
%i
.fa.fa-sign-out
%i
.fa.fa-sign-out
Leave
Leave
...
...
app/views/groups/group_members/_group_member.html.haml
View file @
84371de0
-
user
=
member
.
user
-
user
=
member
.
user
-
return
unless
user
-
return
unless
user
-
show_roles
=
true
if
show_roles
.
nil?
-
show_roles
=
true
if
show_roles
.
nil?
%li
{
class:
"#{dom_class(member)} js-toggle-container"
,
id:
dom_id
(
member
)}
%li
{
class:
"#{dom_class(member)} js-toggle-container"
,
id:
dom_id
(
member
)}
%span
{
class:
(
"list-item-name"
if
show_controls
)}
%span
{
class:
(
"list-item-name"
if
show_controls
)}
=
image_tag
avatar_icon
(
user
.
email
,
16
),
class:
"avatar s16"
=
image_tag
avatar_icon
(
user
.
email
,
16
),
class:
"avatar s16"
...
@@ -21,8 +22,8 @@
...
@@ -21,8 +22,8 @@
title:
'Edit access level'
,
type:
'button'
do
title:
'Edit access level'
,
type:
'button'
do
%i
.fa.fa-pencil-square-o
%i
.fa.fa-pencil-square-o
-
if
can?
(
current_user
,
:destroy_group_member
,
member
)
-
if
can?
(
current_user
,
:destroy_group_member
,
member
)
-
if
current_user
==
member
.
user
-
if
current_user
==
user
=
link_to
leave_
dashboard_group
_path
(
@group
),
data:
{
confirm:
leave_group_message
(
@group
.
name
)},
method: :delete
,
class:
"btn-xs btn btn-remove"
,
title:
'Remove user from group'
do
=
link_to
leave_
group_group_members
_path
(
@group
),
data:
{
confirm:
leave_group_message
(
@group
.
name
)},
method: :delete
,
class:
"btn-xs btn btn-remove"
,
title:
'Remove user from group'
do
%i
.fa.fa-minus.fa-inverse
%i
.fa.fa-minus.fa-inverse
-
else
-
else
=
link_to
group_group_member_path
(
@group
,
member
),
data:
{
confirm:
remove_user_from_group_message
(
@group
,
user
)
},
method: :delete
,
remote:
true
,
class:
"btn-xs btn btn-remove"
,
title:
'Remove user from group'
do
=
link_to
group_group_member_path
(
@group
,
member
),
data:
{
confirm:
remove_user_from_group_message
(
@group
,
user
)
},
method: :delete
,
remote:
true
,
class:
"btn-xs btn btn-remove"
,
title:
'Remove user from group'
do
...
...
config/routes.rb
View file @
84371de0
...
@@ -215,11 +215,7 @@ Gitlab::Application.routes.draw do
...
@@ -215,11 +215,7 @@ Gitlab::Application.routes.draw do
scope
module: :dashboard
do
scope
module: :dashboard
do
resources
:milestones
,
only:
[
:index
,
:show
]
resources
:milestones
,
only:
[
:index
,
:show
]
resources
:groups
,
only:
[
:index
]
do
resources
:groups
,
only:
[
:index
]
member
do
delete
:leave
end
end
resources
:projects
,
only:
[]
do
resources
:projects
,
only:
[]
do
collection
do
collection
do
...
@@ -241,6 +237,7 @@ Gitlab::Application.routes.draw do
...
@@ -241,6 +237,7 @@ Gitlab::Application.routes.draw do
scope
module: :groups
do
scope
module: :groups
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
delete
:leave
,
on: :collection
end
end
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment