diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-28 15:14:39 +0200 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-09-05 15:10:39 +0100 |
commit | 03c733849c1fad9885b0b947e60744633b7f5bd6 (patch) | |
tree | 013bd8a1a0470f053178e51f22f517907c58bb8b /app/helpers | |
parent | db28db414c8ab3d253294e430cd99d14499fad2e (diff) | |
download | gitlab-ce-03c733849c1fad9885b0b947e60744633b7f5bd6.tar.gz |
Convert global templates to vendored templates via a ::TemplateFinder
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/blob_helper.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 00ebafd177b..c9f2f1e3caf 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -158,32 +158,35 @@ module BlobHelper end def licenses_for_select - return @licenses_for_select if defined?(@licenses_for_select) - - grouped_licenses = LicenseTemplateFinder.new.execute.group_by(&:category) - categories = grouped_licenses.keys - - @licenses_for_select = categories.each_with_object({}) do |category, hash| - hash[category] = grouped_licenses[category].map do |license| - { name: license.name, id: license.id } - end - end + @licenses_for_select ||= dropdown_names(LicenseTemplateFinder.new.execute) end def ref_project @ref_project ||= @target_project || @project end + def dropdown_names(items) + grouped = items.group_by(&:category) + categories = grouped.keys + + categories.each_with_object({}) do |category, hash| + hash[category] = grouped[category].map do |item| + { name: item.name, id: item.id } + end + end + end + private :dropdown_names + def gitignore_names - @gitignore_names ||= Gitlab::Template::GitignoreTemplate.dropdown_names + @gitignore_names ||= dropdown_names(TemplateFinder.new(:gitignores).execute) end def gitlab_ci_ymls - @gitlab_ci_ymls ||= Gitlab::Template::GitlabCiYmlTemplate.dropdown_names(params[:context]) + @gitlab_ci_ymls ||= dropdown_names(TemplateFinder.new(:gitlab_ci_ymls).execute) end def dockerfile_names - @dockerfile_names ||= Gitlab::Template::DockerfileTemplate.dropdown_names + @dockerfile_names ||= dropdown_names(TemplateFinder.new(:dockerfiles).execute) end def blob_editor_paths |