Skip to content
Snippets Groups Projects

WIP: Resolve "GitLab CE features to work with unlicensed EE instance"

Closed Rubén Dávila requested to merge 2500-dont-block-changes-for-unlicensed-ee into master
2 files
+ 41
18
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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
Loading