debian-mirror-gitlab/app/helpers/version_check_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
839 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-09-11 14:41:01 +05:30
module VersionCheckHelper
2023-03-04 22:38:38 +05:30
include Gitlab::Utils::StrongMemoize
2022-03-02 08:16:31 +05:30
def show_version_check?
return false unless Gitlab::CurrentSettings.version_check_enabled
return false if User.single_user&.requires_usage_stats_consent?
2018-11-20 20:47:30 +05:30
2022-03-02 08:16:31 +05:30
current_user&.can_read_all_resources?
2015-09-11 14:41:01 +05:30
end
2018-12-05 23:21:45 +05:30
2023-03-04 22:38:38 +05:30
def gitlab_version_check
VersionCheck.new.response
end
strong_memoize_attr :gitlab_version_check
def show_security_patch_upgrade_alert?
2023-03-17 16:20:25 +05:30
return false unless show_version_check? && gitlab_version_check
2023-03-04 22:38:38 +05:30
2023-03-17 16:20:25 +05:30
Gitlab::Utils.to_boolean(gitlab_version_check['critical_vulnerability'])
2023-03-04 22:38:38 +05:30
end
2018-12-05 23:21:45 +05:30
def link_to_version
2023-07-09 08:55:56 +05:30
link = link_to(Gitlab::Source.ref, Gitlab::Source.release_url)
2018-12-05 23:21:45 +05:30
if Gitlab.pre_release?
2023-07-09 08:55:56 +05:30
[Gitlab::VERSION, content_tag(:small, link)].join(' ').html_safe
2018-12-05 23:21:45 +05:30
else
2023-07-09 08:55:56 +05:30
link
2018-12-05 23:21:45 +05:30
end
end
2015-09-11 14:41:01 +05:30
end