2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-13 04:31:55 +00:00
|
|
|
module VersionCheckHelper
|
2022-01-07 18:16:06 +00:00
|
|
|
def show_version_check?
|
|
|
|
return false unless Gitlab::CurrentSettings.version_check_enabled
|
|
|
|
return false if User.single_user&.requires_usage_stats_consent?
|
2018-09-07 14:32:28 +00:00
|
|
|
|
2022-01-07 18:16:06 +00:00
|
|
|
current_user&.can_read_all_resources?
|
2015-02-13 04:31:55 +00:00
|
|
|
end
|
2018-10-01 13:59:44 +00:00
|
|
|
|
|
|
|
def link_to_version
|
|
|
|
if Gitlab.pre_release?
|
2021-05-17 18:10:42 +00:00
|
|
|
commit_link = link_to(Gitlab.revision, source_host_url + namespace_project_commits_path(source_code_group, source_code_project, Gitlab.revision))
|
2018-10-01 13:59:44 +00:00
|
|
|
[Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
|
|
|
|
else
|
2021-05-17 18:10:42 +00:00
|
|
|
link_to Gitlab::VERSION, source_host_url + namespace_project_tag_path(source_code_group, source_code_project, "v#{Gitlab::VERSION}")
|
2018-10-01 13:59:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 18:10:42 +00:00
|
|
|
def source_host_url
|
2021-06-14 03:09:53 +00:00
|
|
|
Gitlab::Saas.com_url
|
2021-05-17 18:10:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_code_group
|
|
|
|
'gitlab-org'
|
|
|
|
end
|
|
|
|
|
2018-10-01 13:59:44 +00:00
|
|
|
def source_code_project
|
2019-09-17 14:16:34 +00:00
|
|
|
'gitlab-foss'
|
2018-10-01 13:59:44 +00:00
|
|
|
end
|
2015-02-13 04:31:55 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
2021-05-17 18:10:42 +00:00
|
|
|
VersionCheckHelper.prepend_mod
|