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

version_check_helper.rb « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1fec0a916b81ae44bbe502c449ad8c3cdf677ee1 (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
# frozen_string_literal: true

module VersionCheckHelper
  include Gitlab::Utils::StrongMemoize

  def show_version_check?
    return false unless Gitlab::CurrentSettings.version_check_enabled
    return false if User.single_user&.requires_usage_stats_consent?

    current_user&.can_read_all_resources?
  end

  def gitlab_version_check
    VersionCheck.new.response
  end
  strong_memoize_attr :gitlab_version_check

  def show_security_patch_upgrade_alert?
    return false unless show_version_check? && gitlab_version_check

    Gitlab::Utils.to_boolean(gitlab_version_check['critical_vulnerability'])
  end

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

  def source_host_url
    Gitlab::Saas.com_url
  end

  def source_code_group
    'gitlab-org'
  end

  def source_code_project
    'gitlab-foss'
  end
end

VersionCheckHelper.prepend_mod