1# frozen_string_literal: true
2
3module VersionCheckHelper
4  def version_status_badge
5    return unless Rails.env.production?
6    return unless Gitlab::CurrentSettings.version_check_enabled
7    return if User.single_user&.requires_usage_stats_consent?
8
9    image_tag VersionCheck.image_url, class: 'js-version-status-badge'
10  end
11
12  def link_to_version
13    if Gitlab.pre_release?
14      commit_link = link_to(Gitlab.revision, source_host_url + namespace_project_commits_path(source_code_group, source_code_project, Gitlab.revision))
15      [Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
16    else
17      link_to Gitlab::VERSION, source_host_url + namespace_project_tag_path(source_code_group, source_code_project, "v#{Gitlab::VERSION}")
18    end
19  end
20
21  def source_host_url
22    Gitlab::Saas.com_url
23  end
24
25  def source_code_group
26    'gitlab-org'
27  end
28
29  def source_code_project
30    'gitlab-foss'
31  end
32end
33
34VersionCheckHelper.prepend_mod
35