Commit bff1b8f8 authored by Douwe Maan's avatar Douwe Maan

More code cleanup.

parent 257f8057
module LicenseHelper
# better text
def license_message(signed_in: signed_in?, is_admin: (current_user && current_user.is_admin?))
if License.current
yes_license_message(signed_in, is_admin)
else
no_license_message(signed_in, is_admin)
end
end
private
def no_license_message(signed_in, is_admin)
message = []
message << "No GitLab Enterprise Edition license has been provided yet."
message << "Pushing code and creation of issues and merge requests has been disabled."
message <<
if is_admin
"Upload a license in the admin area"
else
"Ask an admin to upload a license"
end
message << "to activate this functionality."
message.join(" ")
end
def yes_license_message(signed_in, is_admin)
license = License.current
if license
return unless signed_in
return unless (license.notify_admins? && is_admin) || license.notify_users?
return unless signed_in
message << "The GitLab Enterprise Edition license"
message << (license.expired? ? "expired" : "will expire")
message << "on #{license.expires_at}."
return unless (license.notify_admins? && is_admin) || license.notify_users?
if license.expired? && license.will_block_changes?
message << "Pushing code and creation of issues and merge requests"
message = []
message << "The GitLab Enterprise Edition license"
message << (license.expired? ? "expired" : "will expire")
message << "on #{license.expires_at}."
if license.expired? && license.will_block_changes?
message << "Pushing code and creation of issues and merge requests"
message <<
if license.block_changes?
message << "has been disabled."
"has been disabled."
else
message << "will be disabled on #{license.block_changes_at}."
"will be disabled on #{license.block_changes_at}."
end
end
end
message <<
if is_admin
message << "Upload a new license in the admin area"
"Upload a new license in the admin area"
else
message << "Ask an admin to upload a new license"
"Ask an admin to upload a new license"
end
if license.block_changes?
message << "to restore service."
else
message << "to ensure uninterrupted service."
end
else
message << "No GitLab Enterprise Edition license has been provided yet."
message << "Pushing code and creation of issues and merge requests has been disabled."
if signed_in && is_admin
message << "Upload a license in the admin area"
else
message << "Ask an admin to upload a license"
end
message << "to restore service."
end
message << "to"
message << (license.block_changes? ? "restore" : "ensure uninterrupted")
message << "service."
message.join(" ")
end
......
......@@ -7,28 +7,34 @@ class Ability
abilities =
case subject.class.name
when "Project" then project_abilities(user, subject)
when "Issue" then issue_abilities(user, subject)
when "Note" then note_abilities(user, subject)
when "ProjectSnippet" then project_snippet_abilities(user, subject)
when "PersonalSnippet" then personal_snippet_abilities(user, subject)
when "MergeRequest" then merge_request_abilities(user, subject)
when "Group" then group_abilities(user, subject)
when "Namespace" then namespace_abilities(user, subject)
when "GroupMember" then group_member_abilities(user, subject)
when "Project" then project_abilities(user, subject)
when "Issue" then issue_abilities(user, subject)
when "Note" then note_abilities(user, subject)
when "ProjectSnippet" then project_snippet_abilities(user, subject)
when "PersonalSnippet" then personal_snippet_abilities(user, subject)
when "MergeRequest" then merge_request_abilities(user, subject)
when "Group" then group_abilities(user, subject)
when "Namespace" then namespace_abilities(user, subject)
when "GroupMember" then group_member_abilities(user, subject)
else []
end.concat(global_abilities(user))
end
if License.block_changes?
abilities.delete(:push_code)
abilities.delete(:push_code_to_protected_branches)
abilities.delete(:write_issue)
abilities.delete(:write_merge_request)
end
abilities.concat(global_abilities(user))
abilities -= license_blocked_abilities if License.block_changes?
abilities
end
def license_blocked_abilities
[
:push_code,
:push_code_to_protected_branches,
:write_issue,
:write_merge_request
]
end
# List of possible abilities
# for non-authenticated user
def not_auth_abilities(user, subject)
......
- # page_title "Upload License"
%h3.page-title Upload License
%p.light
To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file you have received from GitLab B.V.
To #{License.current ? "continue" : "start"} using GitLab Enterprise Edition, upload the <code>.gitlab-license</code> file you have received from GitLab B.V..
%hr
= form_for @license, url: admin_license_path, html: { multipart: true, class: 'form-horizontal fieldset-form' } do |f|
......
- # page_title "License"
%h3.page-title
Your License
= link_to 'Upload New License', new_admin_license_path, class: "btn btn-new pull-right"
......@@ -71,7 +72,7 @@
Download license
.panel-body
%p Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your <code>.gitlab-license</code> file.
%p Still, we recommend keeping it save somewhere. Otherwise, if you ever need it and have lost it, you will need to request GitLab B.V. to send it to you again.
%p Still, we recommend keeping a backup saved somewhere. Otherwise, if you ever need it and have lost it, you will need to request GitLab B.V. to send it to you again.
%br
= link_to 'Download license', download_admin_license_path, class: "btn btn-info"
......
- if broadcast_message.present?
.broadcast-message{ style: broadcast_styling(broadcast_message) }
%i.fa.fa-bullhorn
= icon('bullhorn')
= broadcast_message.message
- if (message = license_message) && message.present?
.broadcast-message
%i.fa.fa-bullhorn
= icon('bullhorn')
= message
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment