diff options
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r-- | app/helpers/tree_helper.rb | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 7644ed783eb..563450159b5 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true module TreeHelper + include BlobHelper + include WebIdeButtonHelper + FILE_LIMIT = 1_000 # Sorts a repository's tree so that folders are before files and renders @@ -31,7 +34,7 @@ module TreeHelper # mode - File unix mode # name - File name def tree_icon(type, mode, name) - icon([file_type_icon_class(type, mode, name), 'fw']) + sprite_icon(file_type_icon_class(type, mode, name)) end # Using Rails `*_path` methods can be slow, especially when generating @@ -199,38 +202,26 @@ module TreeHelper } end - def ide_base_path(project) - can_push_code = current_user&.can?(:push_code, project) - fork_path = current_user&.fork_of(project)&.full_path + def web_ide_button_data(options = {}) + { + project_path: project_to_use.full_path, + ref: ActionDispatch::Journey::Router::Utils.escape_path(@ref), - if can_push_code - project.full_path - else - fork_path || project.full_path - end - end + is_fork: fork?, + needs_to_fork: needs_to_fork?, + gitpod_enabled: !current_user.nil? && current_user.gitpod_enabled, + is_blob: !options[:blob].nil?, - def vue_ide_link_data(project, ref) - can_collaborate = can_collaborate_with_project?(project) - can_create_mr_from_fork = can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project) - show_web_ide_button = (can_collaborate || current_user&.already_forked?(project) || can_create_mr_from_fork) + show_edit_button: show_edit_button?, + show_web_ide_button: show_web_ide_button?, + show_gitpod_button: show_gitpod_button?, - { - ide_base_path: ide_base_path(project), - needs_to_fork: !can_collaborate && !current_user&.already_forked?(project), - show_web_ide_button: show_web_ide_button, - show_gitpod_button: show_web_ide_button && Gitlab::Gitpod.feature_and_settings_enabled?(project), - gitpod_url: full_gitpod_url(project, ref), - gitpod_enabled: current_user&.gitpod_enabled + web_ide_url: web_ide_url, + edit_url: edit_url, + gitpod_url: gitpod_url } end - def full_gitpod_url(project, ref) - return "" unless Gitlab::Gitpod.feature_and_settings_enabled?(project) - - "#{Gitlab::CurrentSettings.gitpod_url}##{project_tree_url(project, tree_join(ref, @path || ''))}" - end - def directory_download_links(project, ref, archive_prefix) Gitlab::Workhorse::ARCHIVE_FORMATS.map do |fmt| { |