Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
594a95f6
Commit
594a95f6
authored
Jun 23, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show a header message when current license is a trial
parent
68c9640a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
18 deletions
+41
-18
app/helpers/license_helper.rb
app/helpers/license_helper.rb
+39
-18
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+2
-0
No files found.
app/helpers/license_helper.rb
View file @
594a95f6
...
...
@@ -12,39 +12,60 @@ module LicenseHelper
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 @@ module LicenseHelper
end
message
<<
'to'
message
<<
(
license
.
block_changes?
?
'restore'
:
'ensure uninterrupted'
)
message
<<
(
current_
license
.
block_changes?
?
'restore'
:
'ensure uninterrupted'
)
message
<<
'service.'
end
...
...
app/views/layouts/header/_default.html.haml
View file @
594a95f6
...
...
@@ -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'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment