Skip to content
Snippets Groups Projects
Commit 6813ce83 authored by Ruben Alexis's avatar Ruben Alexis
Browse files

Show a header message when current license is a trial

parent 013a1c8b
No related branches found
No related tags found
1 merge request!2158WIP: Resolve "GitLab CE features to work with unlicensed EE instance"
This commit is part of merge request !2158. Comments created here will be created in the context of that merge request.
......@@ -12,39 +12,60 @@ def max_historical_user_count
HistoricalData.max_historical_user_count
end
# in_html is set to false from an initializer, which shouldn't try to render
# HTML links.
#
def license_message(signed_in: signed_in?, is_admin: (current_user && current_user.admin?), in_html: true)
@license_message =
if License.current
yes_license_message(signed_in, is_admin)
end
def license_message(signed_in: signed_in?, is_admin: (current_user && current_user.admin?))
yes_license_message(signed_in, is_admin) if current_license
end
def trial_license_message
if signed_in? && current_license&.trial?
status = current_license.expired? ? :expired : :active
message =
if current_user.admin?
buy_now_link = link_to('Buy now!', '#')
if status == :active
remaining_days = (current_license.expires_at - Date.today).to_i
"Your GitLab Enterprise Edition trial license remains #{pluralize(remaining_days, 'day')}. #{buy_now_link}".html_safe
else
"Your GitLab Enterprise Edition trial license expired. #{buy_now_link}".html_safe
end
elsif status == :expired
"Your GitLab Enterprise Edition trial license expired. Please contact your administrator."
end
end
message
end
private
def yes_license_message(signed_in, is_admin)
license = License.current
def current_license
return @current_license if defined?(@current_license)
return unless signed_in
@current_license = License.current
end
return unless (is_admin && license.notify_admins?) || license.notify_users?
def yes_license_message(signed_in, is_admin)
return if current_license.trial?
return unless signed_in
return unless (is_admin && current_license.notify_admins?) || current_license.notify_users?
message = []
message << 'The GitLab Enterprise Edition license'
message << (license.expired? ? 'expired' : 'will expire')
message << "on #{license.expires_at}."
message << (current_license.expired? ? 'expired' : 'will expire')
message << "on #{current_license.expires_at}."
if license.expired? && license.will_block_changes?
if current_license.expired? && current_license.will_block_changes?
message << 'Pushing code and creation of issues and merge requests'
message <<
if license.block_changes?
if current_license.block_changes?
'has been disabled.'
else
"will be disabled on #{license.block_changes_at}."
"will be disabled on #{current_license.block_changes_at}."
end
message <<
......@@ -55,7 +76,7 @@ def yes_license_message(signed_in, is_admin)
end
message << 'to'
message << (license.block_changes? ? 'restore' : 'ensure uninterrupted')
message << (current_license.block_changes? ? 'restore' : 'ensure uninterrupted')
message << 'service.'
end
......
......@@ -2,6 +2,8 @@
.navbar-border
%a.sr-only.gl-accessibility{ href: "#content-body", tabindex: "1" } Skip to content
.container-fluid
- if trial_license_message.present?
%p.text-center= trial_license_message
.header-content
.dropdown.global-dropdown
%button.global-dropdown-toggle{ type: 'button', 'data-toggle' => 'dropdown' }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment