Commit b2e5b57f authored by Rubén Dávila's avatar Rubén Dávila

Add fork button and implement ability to distinguish between public and protected forks. #2406

parent 2b05bf4b
...@@ -4,7 +4,10 @@ class Projects::ForksController < Projects::ApplicationController ...@@ -4,7 +4,10 @@ class Projects::ForksController < Projects::ApplicationController
before_action :authorize_download_code! before_action :authorize_download_code!
def index 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 end
def new def new
......
.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 .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.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment