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
d798a739
Commit
d798a739
authored
Dec 01, 2020
by
Aakriti Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display read-only mode message when in maintenance
parent
0e357760
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
7 deletions
+80
-7
app/assets/javascripts/maintenance_mode_settings/components/app.vue
.../javascripts/maintenance_mode_settings/components/app.vue
+3
-1
ee/app/helpers/ee/application_helper.rb
ee/app/helpers/ee/application_helper.rb
+23
-2
ee/spec/features/read_only_spec.rb
ee/spec/features/read_only_spec.rb
+1
-1
ee/spec/helpers/application_helper_spec.rb
ee/spec/helpers/application_helper_spec.rb
+50
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-3
No files found.
app/assets/javascripts/maintenance_mode_settings/components/app.vue
View file @
d798a739
...
...
@@ -34,7 +34,9 @@ export default {
<gl-form-textarea
id=
"maintenanceBannerMessage"
v-model=
"bannerMessage"
:placeholder=
"__(`GitLab is undergoing maintenance and is operating in a read-only mode.`)"
:placeholder=
"
__('This GitLab instance is undergoing maintenance and is operating in read-only mode.')
"
/>
</gl-form-group>
<div
class=
"mt-4"
>
...
...
ee/app/helpers/ee/application_helper.rb
View file @
d798a739
...
...
@@ -11,10 +11,26 @@ module EE
override
:read_only_message
def
read_only_message
return
_
(
'You are on a read-only GitLab instance.'
)
if
maintenance_mode?
message
=
::
Gitlab
::
Geo
.
secondary?
?
geo_secondary_read_only_message
:
super
return
super
unless
::
Gitlab
::
Geo
.
secondary?
return
message
unless
maintenance_mode?
return
maintenance_mode_message
.
concat
(
message
)
if
message
maintenance_mode_message
end
def
maintenance_mode_message
html
=
tag
.
div
do
tag
.
p
(
class:
'gl-mb-3'
)
do
concat
(
sprite_icon
(
'information-o'
,
css_class:
'gl-icon gl-mr-3'
))
concat
(
custom_maintenance_mode_message
)
end
end
html
end
def
geo_secondary_read_only_message
message
=
@limited_actions_message
?
s_
(
'Geo|You may be able to make a limited amount of changes or perform a limited amount of actions on this page.'
)
:
s_
(
'Geo|If you want to make changes, you must visit the primary site.'
)
message
=
"
#{
message
}
#{
lag_message
}
"
.
html_safe
if
lag_message
...
...
@@ -114,6 +130,11 @@ module EE
private
def
custom_maintenance_mode_message
::
Gitlab
::
CurrentSettings
.
maintenance_mode_message
&
.
html_safe
||
s_
(
'This GitLab instance is undergoing maintenance and is operating in read-only mode.'
)
end
def
appearance
::
Appearance
.
current
end
...
...
ee/spec/features/read_only_spec.rb
View file @
d798a739
...
...
@@ -26,6 +26,6 @@ RSpec.describe 'Geo read-only message', :geo do
stub_application_setting
(
maintenance_mode:
true
)
end
it_behaves_like
'Read-only instance'
,
/
You are on a read\-only GitLab instanc
e./
it_behaves_like
'Read-only instance'
,
/
This GitLab instance is undergoing maintenance and is operating in read\-only mod
e./
end
end
ee/spec/helpers/application_helper_spec.rb
View file @
d798a739
...
...
@@ -6,6 +6,8 @@ RSpec.describe ApplicationHelper do
include
EE
::
GeoHelpers
describe
'#read_only_message'
,
:geo
do
let
(
:default_maintenance_mode_message
)
{
'This GitLab instance is undergoing maintenance and is operating in read-only mode.'
}
context
'when not in a Geo secondary'
do
it
'returns a fallback message if database is readonly'
do
expect
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
...
...
@@ -16,6 +18,54 @@ RSpec.describe ApplicationHelper do
it
'returns nil when database is not read_only'
do
expect
(
helper
.
read_only_message
).
to
be_nil
end
context
'maintenance mode'
do
context
'enabled'
do
before
do
stub_application_setting
(
maintenance_mode:
true
)
end
it
'returns default message'
do
expect
(
helper
.
read_only_message
).
to
match
(
default_maintenance_mode_message
)
end
it
'returns user set custom maintenance mode message'
do
custom_message
=
'Maintenance window ends at 00:00.'
stub_application_setting
(
maintenance_mode_message:
custom_message
)
expect
(
helper
.
read_only_message
).
to
match
(
/
#{
custom_message
}
/
)
end
context
'when database is read-only'
do
it
'stacks read-only and maintenance mode messages'
do
expect
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
twice
{
true
}
expect
(
helper
.
read_only_message
).
to
match
(
'You are on a read-only GitLab instance'
)
expect
(
helper
.
read_only_message
).
to
match
(
/
#{
default_maintenance_mode_message
}
/
)
end
end
end
context
'disabled'
do
it
'returns nil'
do
stub_application_setting
(
maintenance_mode:
false
)
expect
(
helper
.
read_only_message
).
to
be_nil
end
end
end
end
context
'on a geo secondary'
do
context
'maintenance mode on'
do
it
'returns messages for both'
do
expect
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
twice
{
true
}
stub_application_setting
(
maintenance_mode:
true
)
expect
(
helper
.
read_only_message
).
to
match
(
/you must visit the primary site/
)
expect
(
helper
.
read_only_message
).
to
match
(
/
#{
default_maintenance_mode_message
}
/
)
end
end
end
context
'when in a Geo Secondary'
do
...
...
locale/gitlab.pot
View file @
d798a739
...
...
@@ -12802,9 +12802,6 @@ msgstr ""
msgid "GitLab is obtaining a Let's Encrypt SSL certificate for this domain. This process can take some time. Please try again later."
msgstr ""
msgid "GitLab is undergoing maintenance and is operating in a read-only mode."
msgstr ""
msgid "GitLab member or Email address"
msgstr ""
...
...
@@ -27710,6 +27707,9 @@ msgstr ""
msgid "This GitLab instance is licensed at the %{insufficient_license} tier. Geo is only available for users who have at least a Premium license."
msgstr ""
msgid "This GitLab instance is undergoing maintenance and is operating in read-only mode."
msgstr ""
msgid "This Project is currently archived and read-only. Please unarchive the project first if you want to resume Pull mirroring"
msgstr ""
...
...
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