Add fork button and implement ability to distinguish between public and protected forks. #2406
This commit is contained in:
parent
2b05bf4be5
commit
b2e5b57fab
2 changed files with 27 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
.projects-list-holder
|
||||
.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
|
||||
|
||||
= render 'shared/projects/list', projects: @forked_projects, use_creator_avatar: true
|
||||
.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
|
||||
|
||||
- if protected_count > 0
|
||||
%ul.projects-list
|
||||
%li.project-row
|
||||
%strong= pluralize(protected_count, 'protected fork')
|
||||
%span you have no access to.
|
||||
|
|
Loading…
Reference in a new issue