diff options
author | Robert Speicher <robert@gitlab.com> | 2018-09-06 00:05:20 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-09-06 00:05:20 +0000 |
commit | ab22dae917cc38d6d9573fca472d09950fac8d08 (patch) | |
tree | f5380f2e973dc1ec179bfc33d6110b7d26f33a0a /app/helpers | |
parent | e7cb8a4195ce0b22dc7173aff0e56b9e322a8882 (diff) | |
parent | d65e31ab72b09c539fac4bac391d1f6ff3152c58 (diff) | |
download | gitlab-ce-ab22dae917cc38d6d9573fca472d09950fac8d08.tar.gz |
Merge branch 'ce-5306-more-custom-templates' into 'master'
CE backport of changes that introduce custom instance-level templates to EE
See merge request gitlab-org/gitlab-ce!21530
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..96f7415ae98 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 ||= template_dropdown_names(TemplateFinder.build(:licenses).execute) end def ref_project @ref_project ||= @target_project || @project end + def template_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 :template_dropdown_names + def gitignore_names - @gitignore_names ||= Gitlab::Template::GitignoreTemplate.dropdown_names + @gitignore_names ||= template_dropdown_names(TemplateFinder.build(:gitignores).execute) end def gitlab_ci_ymls - @gitlab_ci_ymls ||= Gitlab::Template::GitlabCiYmlTemplate.dropdown_names(params[:context]) + @gitlab_ci_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_ymls).execute) end def dockerfile_names - @dockerfile_names ||= Gitlab::Template::DockerfileTemplate.dropdown_names + @dockerfile_names ||= template_dropdown_names(TemplateFinder.build(:dockerfiles).execute) end def blob_editor_paths |