Commit e028276d authored by Kia Mei Somabes's avatar Kia Mei Somabes Committed by Patrick Bajao

Add download directory in menu

Add subdirectory params for RepositoriesController#archive
parent 8b9da458
......@@ -23,7 +23,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
append_sha = false if @filename == shortname
end
send_git_archive @repository, ref: @ref, format: params[:format], append_sha: append_sha
send_git_archive @repository, ref: @ref, subdirectory: params[:subdirectory], format: params[:format], append_sha: append_sha
rescue => ex
logger.error("#{self.class.name}: #{ex}")
git_not_found!
......
......@@ -26,6 +26,14 @@ module ProjectsHelper
image_tag(src, width: opts[:size], class: classes, alt: '', "data-src" => avatar)
end
def is_directory
@path.empty? ? false : true
end
def get_directory_path
@path ? "#{@path}/" : ''
end
def author_content_tag(author, opts = {})
default_opts = { author_class: 'author', tooltip: false, by_username: false }
......
......@@ -31,6 +31,7 @@ module WorkhorseHelper
# Archive a Git repository and send it through Workhorse
def send_git_archive(repository, **kwargs)
kwargs.delete(:subdirectory) if kwargs[:subdirectory].nil?
headers.store(*Gitlab::Workhorse.send_git_archive(repository, **kwargs))
head :ok
end
......
......@@ -8,8 +8,14 @@
%span.sr-only= _('Select Archive Format')
= sprite_icon("arrow-down")
%ul.dropdown-menu.dropdown-menu-right{ role: 'menu' }
- if is_directory
%li.dropdown-header
#{ _('Directory') }
%li
= link_to project_archive_path(project, subdirectory: get_directory_path, id: tree_join(ref, archive_prefix), format: 'zip'), rel: 'nofollow', download: '' do
%span= _('Download zip')
%li.dropdown-header
#{ _('Source code') }
#{ _('Repository') }
%li
= link_to project_archive_path(project, id: tree_join(ref, archive_prefix), format: 'zip'), rel: 'nofollow', download: '' do
%span= _('Download zip')
......
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