2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-12 23:31:55 -05:00
|
|
|
module VersionCheckHelper
|
|
|
|
def version_status_badge
|
2018-09-07 10:32:28 -04:00
|
|
|
return unless Rails.env.production?
|
|
|
|
return unless Gitlab::CurrentSettings.version_check_enabled
|
|
|
|
return if User.single_user&.requires_usage_stats_consent?
|
|
|
|
|
2018-12-14 12:47:49 -05:00
|
|
|
image_tag VersionCheck.url, class: 'js-version-status-badge'
|
2015-02-12 23:31:55 -05:00
|
|
|
end
|
2018-10-01 09:59:44 -04:00
|
|
|
|
|
|
|
def link_to_version
|
|
|
|
if Gitlab.pre_release?
|
2021-05-17 14:10:42 -04: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 09:59:44 -04:00
|
|
|
[Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
|
|
|
|
else
|
2021-05-17 14:10:42 -04:00
|
|
|
link_to Gitlab::VERSION, source_host_url + namespace_project_tag_path(source_code_group, source_code_project, "v#{Gitlab::VERSION}")
|
2018-10-01 09:59:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 14:10:42 -04:00
|
|
|
def source_host_url
|
2021-06-13 23:09:53 -04:00
|
|
|
Gitlab::Saas.com_url
|
2021-05-17 14:10:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def source_code_group
|
|
|
|
'gitlab-org'
|
|
|
|
end
|
|
|
|
|
2018-10-01 09:59:44 -04:00
|
|
|
def source_code_project
|
2019-09-17 10:16:34 -04:00
|
|
|
'gitlab-foss'
|
2018-10-01 09:59:44 -04:00
|
|
|
end
|
2015-02-12 23:31:55 -05:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-17 14:10:42 -04:00
|
|
|
VersionCheckHelper.prepend_mod
|