summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-01-11 19:16:29 -0500
committerRubén Dávila <rdavila84@gmail.com>2016-01-20 00:14:58 -0500
commitb2e5b57fab4d73a5ad043d82457268fdb3864a89 (patch)
tree0af9e6ba08d6d119ed34f84a9635a65088f85287
parent2b05bf4be5c01c2b6b09a8c0792d1c9dd8afe6e7 (diff)
downloadgitlab-ce-b2e5b57fab4d73a5ad043d82457268fdb3864a89.tar.gz
Add fork button and implement ability to distinguish between public and protected forks. #2406
-rw-r--r--app/controllers/projects/forks_controller.rb5
-rw-r--r--app/views/projects/forks/index.html.haml23
2 files changed, 26 insertions, 2 deletions
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 2e01352169d..bcb64479cbf 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -4,7 +4,10 @@ class Projects::ForksController < Projects::ApplicationController
before_action :authorize_download_code!
def index
- @forked_projects = project.forks.includes(:creator)
+ @all_forks = project.forks.includes(:creator)
+ @public_forks, @protected_forks = @all_forks.partition do |project|
+ can?(current_user, :read_project, project)
+ end
end
def new
diff --git a/app/views/projects/forks/index.html.haml b/app/views/projects/forks/index.html.haml
index 8ae7fe22e1e..d050b2f735a 100644
--- a/app/views/projects/forks/index.html.haml
+++ b/app/views/projects/forks/index.html.haml
@@ -1,3 +1,24 @@
+.gray-content-block.top-block.white
+ - if current_user.already_forked?(@project) && current_user.manageable_namespaces.size < 2
+ = link_to namespace_project_path(current_user, current_user.fork_of(@project)), title: 'Go to your fork', class: 'pull-right btn btn-new' do
+ = icon('code-fork fw')
+ Fork
+ - else
+ = link_to new_namespace_project_fork_path(@project.namespace, @project), title: "Fork project", class: 'pull-right btn btn-new' do
+ = icon('code-fork fw')
+ Fork
+
+ .oneline
+ - public_count = @public_forks.size
+ - protected_count = @protected_forks.size
+ - full_count_title = ["#{public_count} public", "#{protected_count} protected"].join(' and ')
+ == #{pluralize(@all_forks.size, 'fork')}: #{full_count_title}
+
.projects-list-holder
+ = render 'shared/projects/list', projects: @public_forks, use_creator_avatar: true
- = render 'shared/projects/list', projects: @forked_projects, use_creator_avatar: true
+ - if protected_count > 0
+ %ul.projects-list
+ %li.project-row
+ %strong= pluralize(protected_count, 'protected fork')
+ %span you have no access to.