Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tags_helper.rb « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bfc8803f5147630f4583b91f1b43f1a19c7061a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

module TagsHelper
  def tag_path(tag)
    "/tags/#{tag}"
  end

  def filter_tags_path(options = {})
    exist_opts = {
      search: params[:search],
      sort: params[:sort]
    }

    options = exist_opts.merge(options)
    project_tags_path(@project, @id, options)
  end

  def tag_list(project)
    html = []

    project.tag_list.each do |tag|
      html << link_to(tag, tag_path(tag))
    end

    html.join.html_safe
  end

  def protected_tag?(project, tag)
    ProtectedTag.protected?(project, tag.name)
  end

  def tag_description_help_text
    text = s_('TagsPage|Optionally, add a message to the tag. Leaving this blank creates '\
              'a %{link_start}lightweight tag.%{link_end}') % {
      link_start: '<a href="https://git-scm.com/book/en/v2/Git-Basics-Tagging\" target="_blank" rel="noopener noreferrer">',
      link_end: '</a>'
    }

    text.html_safe
  end

  def delete_tag_modal_attributes(tag_name)
    {
      title: s_('TagsPage|Delete tag'),
      message: s_('TagsPage|Deleting the %{tag_name} tag cannot be undone. Are you sure?') % { tag_name: tag_name },
      okVariant: 'danger',
      okTitle: s_('TagsPage|Delete tag')
    }.to_json
  end
end