summaryrefslogtreecommitdiff
path: root/app/helpers/version_check_helper.rb
blob: 9e1204738c158ba6ce9b578b10d58c1604ba9013 (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
# frozen_string_literal: true

module VersionCheckHelper
  def version_status_badge
    return unless Rails.env.production?
    return unless Gitlab::CurrentSettings.version_check_enabled
    return if User.single_user&.requires_usage_stats_consent?

    image_tag VersionCheck.url, class: 'js-version-status-badge'
  end

  def link_to_version
    if Gitlab.pre_release?
      commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', source_code_project, Gitlab.revision))
      [Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
    else
      link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', source_code_project, "v#{Gitlab::VERSION}")
    end
  end

  def source_code_project
    'gitlab-ce'
  end
end

VersionCheckHelper.prepend_if_ee('EE::VersionCheckHelper')