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
Léo-Paul Géneau
gitlab-ce
Commits
2afa5fcb
Commit
2afa5fcb
authored
May 29, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to leave project
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
907bbb2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+5
-1
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+12
-0
app/views/projects/_aside.html.haml
app/views/projects/_aside.html.haml
+12
-0
No files found.
app/controllers/projects/project_members_controller.rb
View file @
2afa5fcb
...
...
@@ -73,10 +73,14 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
def
leave
if
@project
.
namespace
==
current_user
.
namespace
return
redirect_to
(
:back
,
alert:
'You can not leave your own project. Transfer or delete the project.'
)
end
@project
.
project_members
.
find_by
(
user_id:
current_user
).
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
html
{
redirect_to
dashboard_path
}
format
.
js
{
render
nothing:
true
}
end
end
...
...
app/helpers/projects_helper.rb
View file @
2afa5fcb
...
...
@@ -294,4 +294,16 @@ module ProjectsHelper
nil
end
end
def
user_max_access_in_project
(
user
,
project
)
level
=
project
.
team
.
max_member_access
(
user
)
if
level
Gitlab
::
Access
.
options_with_owner
.
key
(
level
)
end
end
def
leave_project_message
(
project
)
"Are you sure you want to leave
\"
#{
project
.
name
}
\"
project?"
end
end
app/views/projects/_aside.html.haml
View file @
2afa5fcb
...
...
@@ -94,3 +94,15 @@
=
icon
(
"exclamation-triangle fw"
)
Archived project!
%p
Repository is read-only
-
if
current_user
-
access
=
user_max_access_in_project
(
current_user
,
@project
)
-
if
access
.light-well.light.prepend-top-20
%small
You have
#{
access
}
access to this project.
-
if
@project
.
project_member_by_id
(
current_user
)
%br
=
link_to
leave_namespace_project_project_members_path
(
@project
.
namespace
,
@project
),
data:
{
confirm:
leave_project_message
(
@project
)
},
method: :delete
,
title:
'Leave project'
do
Leave this project
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