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
df415198
Commit
df415198
authored
Jan 05, 2022
by
Martin Wortschack
Committed by
Bob Van Landuyt
Jan 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make strings in user preferences translatable
Changelog: changed
parent
05b048ca
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
40 deletions
+110
-40
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+5
-5
app/views/profiles/preferences/show.html.haml
app/views/profiles/preferences/show.html.haml
+1
-1
lib/gitlab/color_schemes.rb
lib/gitlab/color_schemes.rb
+15
-13
lib/gitlab/themes.rb
lib/gitlab/themes.rb
+21
-19
locale/gitlab.pot
locale/gitlab.pot
+66
-0
spec/lib/gitlab/color_schemes_spec.rb
spec/lib/gitlab/color_schemes_spec.rb
+1
-1
spec/lib/gitlab/themes_spec.rb
spec/lib/gitlab/themes_spec.rb
+1
-1
No files found.
app/helpers/preferences_helper.rb
View file @
df415198
...
...
@@ -4,8 +4,8 @@
module
PreferencesHelper
def
layout_choices
[
[
'Fixed'
,
:fixed
],
[
'Fluid'
,
:fluid
]
[
s_
(
'Layout|Fixed'
)
,
:fixed
],
[
s_
(
'Layout|Fluid'
)
,
:fluid
]
]
end
...
...
@@ -40,9 +40,9 @@ module PreferencesHelper
def
project_view_choices
[
[
'Files and Readme (default)'
,
:files
],
[
'Activity'
,
:activity
],
[
'Readme'
,
:readme
]
[
s_
(
'ProjectView|Files and Readme (default)'
)
,
:files
],
[
s_
(
'ProjectView|Activity'
)
,
:activity
],
[
s_
(
'ProjectView|Readme'
)
,
:readme
]
]
end
...
...
app/views/profiles/preferences/show.html.haml
View file @
df415198
...
...
@@ -2,7 +2,7 @@
-
@content_class
=
"limit-container-width"
unless
fluid_layout
-
user_theme_id
=
Gitlab
::
Themes
.
for_user
(
@user
).
id
-
user_fields
=
{
theme:
user_theme_id
,
gitpod_enabled:
@user
.
gitpod_enabled
,
sourcegraph_enabled:
@user
.
sourcegraph_enabled
}.
to_json
-
@themes
=
Gitlab
::
Themes
::
THEMES
.
to_json
-
@themes
=
Gitlab
::
Themes
::
available_themes
.
to_json
-
data_attributes
=
{
themes:
@themes
,
integration_views:
integration_views
.
to_json
,
user_fields:
user_fields
,
body_classes:
Gitlab
::
Themes
.
body_classes
,
profile_preferences_path:
profile_preferences_path
}
-
Gitlab
::
Themes
.
each
do
|
theme
|
...
...
lib/gitlab/color_schemes.rb
View file @
df415198
...
...
@@ -7,21 +7,23 @@ module Gitlab
# Struct class representing a single Scheme
Scheme
=
Struct
.
new
(
:id
,
:name
,
:css_class
)
SCHEMES
=
[
Scheme
.
new
(
1
,
'White'
,
'white'
),
Scheme
.
new
(
2
,
'Dark'
,
'dark'
),
Scheme
.
new
(
3
,
'Solarized Light'
,
'solarized-light'
),
Scheme
.
new
(
4
,
'Solarized Dark'
,
'solarized-dark'
),
Scheme
.
new
(
5
,
'Monokai'
,
'monokai'
),
Scheme
.
new
(
6
,
'None'
,
'none'
)
].
freeze
def
self
.
available_schemes
[
Scheme
.
new
(
1
,
s_
(
'SynthaxHighlightingTheme|Light'
),
'white'
),
Scheme
.
new
(
2
,
s_
(
'SynthaxHighlightingTheme|Dark'
),
'dark'
),
Scheme
.
new
(
3
,
s_
(
'SynthaxHighlightingTheme|Solarized Light'
),
'solarized-light'
),
Scheme
.
new
(
4
,
s_
(
'SynthaxHighlightingTheme|Solarized Dark'
),
'solarized-dark'
),
Scheme
.
new
(
5
,
s_
(
'SynthaxHighlightingTheme|Monokai'
),
'monokai'
),
Scheme
.
new
(
6
,
s_
(
'SynthaxHighlightingTheme|None'
),
'none'
)
]
end
# Convenience method to get a space-separated String of all the color scheme
# classes that might be applied to a code block.
#
# Returns a String
def
self
.
body_classes
SCHEMES
.
collect
(
&
:css_class
).
uniq
.
join
(
' '
)
available_schemes
.
collect
(
&
:css_class
).
uniq
.
join
(
' '
)
end
# Get a Scheme by its ID
...
...
@@ -32,12 +34,12 @@ module Gitlab
#
# Returns a Scheme
def
self
.
by_id
(
id
)
SCHEMES
.
detect
{
|
s
|
s
.
id
==
id
}
||
default
available_schemes
.
detect
{
|
s
|
s
.
id
==
id
}
||
default
end
# Returns the number of defined Schemes
def
self
.
count
SCHEMES
.
size
available_schemes
.
size
end
# Get the default Scheme
...
...
@@ -51,7 +53,7 @@ module Gitlab
#
# Yields the Scheme object
def
self
.
each
(
&
block
)
SCHEMES
.
each
(
&
block
)
available_schemes
.
each
(
&
block
)
end
# Get the Scheme for the specified user, or the default
...
...
@@ -68,7 +70,7 @@ module Gitlab
end
def
self
.
valid_ids
SCHEMES
.
map
(
&
:id
)
available_schemes
.
map
(
&
:id
)
end
end
end
lib/gitlab/themes.rb
View file @
df415198
...
...
@@ -13,26 +13,28 @@ module Gitlab
Theme
=
Struct
.
new
(
:id
,
:name
,
:css_class
,
:css_filename
,
:primary_color
)
# All available Themes
THEMES
=
[
Theme
.
new
(
1
,
'Indigo'
,
'ui-indigo'
,
'theme_indigo'
,
'#292961'
),
Theme
.
new
(
6
,
'Light Indigo'
,
'ui-light-indigo'
,
'theme_light_indigo'
,
'#4b4ba3'
),
Theme
.
new
(
4
,
'Blue'
,
'ui-blue'
,
'theme_blue'
,
'#1a3652'
),
Theme
.
new
(
7
,
'Light Blue'
,
'ui-light-blue'
,
'theme_light_blue'
,
'#2261a1'
),
Theme
.
new
(
5
,
'Green'
,
'ui-green'
,
'theme_green'
,
'#0d4524'
),
Theme
.
new
(
8
,
'Light Green'
,
'ui-light-green'
,
'theme_light_green'
,
'#156b39'
),
Theme
.
new
(
9
,
'Red'
,
'ui-red'
,
'theme_red'
,
'#691a16'
),
Theme
.
new
(
10
,
'Light Red'
,
'ui-light-red'
,
'theme_light_red'
,
'#a62e21'
),
Theme
.
new
(
2
,
'Dark'
,
'ui-dark'
,
'theme_dark'
,
'#303030'
),
Theme
.
new
(
3
,
'Light'
,
'ui-light'
,
'theme_light'
,
'#666'
),
Theme
.
new
(
11
,
'Dark Mode (alpha)'
,
'gl-dark'
,
nil
,
'#303030'
)
].
freeze
def
available_themes
[
Theme
.
new
(
1
,
s_
(
'NavigationTheme|Indigo'
),
'ui-indigo'
,
'theme_indigo'
,
'#292961'
),
Theme
.
new
(
6
,
s_
(
'NavigationTheme|Light Indigo'
),
'ui-light-indigo'
,
'theme_light_indigo'
,
'#4b4ba3'
),
Theme
.
new
(
4
,
s_
(
'NavigationTheme|Blue'
),
'ui-blue'
,
'theme_blue'
,
'#1a3652'
),
Theme
.
new
(
7
,
s_
(
'NavigationTheme|Light Blue'
),
'ui-light-blue'
,
'theme_light_blue'
,
'#2261a1'
),
Theme
.
new
(
5
,
s_
(
'NavigationTheme|Green'
),
'ui-green'
,
'theme_green'
,
'#0d4524'
),
Theme
.
new
(
8
,
s_
(
'NavigationTheme|Light Green'
),
'ui-light-green'
,
'theme_light_green'
,
'#156b39'
),
Theme
.
new
(
9
,
s_
(
'NavigationTheme|Red'
),
'ui-red'
,
'theme_red'
,
'#691a16'
),
Theme
.
new
(
10
,
s_
(
'NavigationTheme|Light Red'
),
'ui-light-red'
,
'theme_light_red'
,
'#a62e21'
),
Theme
.
new
(
2
,
s_
(
'NavigationTheme|Dark'
),
'ui-dark'
,
'theme_dark'
,
'#303030'
),
Theme
.
new
(
3
,
s_
(
'NavigationTheme|Light'
),
'ui-light'
,
'theme_light'
,
'#666'
),
Theme
.
new
(
11
,
s_
(
'NavigationTheme|Dark Mode (alpha)'
),
'gl-dark'
,
nil
,
'#303030'
)
]
end
# Convenience method to get a space-separated String of all the theme
# classes that might be applied to the `body` element
#
# Returns a String
def
body_classes
THEMES
.
collect
(
&
:css_class
).
uniq
.
join
(
' '
)
available_themes
.
collect
(
&
:css_class
).
uniq
.
join
(
' '
)
end
# Get a Theme by its ID
...
...
@@ -43,12 +45,12 @@ module Gitlab
#
# Returns a Theme
def
by_id
(
id
)
THEMES
.
detect
{
|
t
|
t
.
id
==
id
}
||
default
available_themes
.
detect
{
|
t
|
t
.
id
==
id
}
||
default
end
# Returns the number of defined Themes
def
count
THEMES
.
size
available_themes
.
size
end
# Get the default Theme
...
...
@@ -62,7 +64,7 @@ module Gitlab
#
# Yields the Theme object
def
each
(
&
block
)
THEMES
.
each
(
&
block
)
available_themes
.
each
(
&
block
)
end
# Get the Theme for the specified user, or the default
...
...
@@ -79,7 +81,7 @@ module Gitlab
end
def
self
.
valid_ids
THEMES
.
map
(
&
:id
)
available_themes
.
map
(
&
:id
)
end
private
...
...
@@ -87,7 +89,7 @@ module Gitlab
def
default_id
@default_id
||=
begin
id
=
Gitlab
.
config
.
gitlab
.
default_theme
.
to_i
theme_ids
=
THEMES
.
map
(
&
:id
)
theme_ids
=
available_themes
.
map
(
&
:id
)
theme_ids
.
include?
(
id
)
?
id
:
APPLICATION_DEFAULT
end
...
...
locale/gitlab.pot
View file @
df415198
...
...
@@ -20830,6 +20830,12 @@ msgstr ""
msgid "Launch a ready-to-code development environment for your project."
msgstr ""
msgid "Layout|Fixed"
msgstr ""
msgid "Layout|Fluid"
msgstr ""
msgid "Lead Time"
msgstr ""
...
...
@@ -23277,6 +23283,39 @@ msgstr ""
msgid "Navigation bar"
msgstr ""
msgid "NavigationTheme|Blue"
msgstr ""
msgid "NavigationTheme|Dark"
msgstr ""
msgid "NavigationTheme|Dark Mode (alpha)"
msgstr ""
msgid "NavigationTheme|Green"
msgstr ""
msgid "NavigationTheme|Indigo"
msgstr ""
msgid "NavigationTheme|Light"
msgstr ""
msgid "NavigationTheme|Light Blue"
msgstr ""
msgid "NavigationTheme|Light Green"
msgstr ""
msgid "NavigationTheme|Light Indigo"
msgstr ""
msgid "NavigationTheme|Light Red"
msgstr ""
msgid "NavigationTheme|Red"
msgstr ""
msgid "Nav|Help"
msgstr ""
...
...
@@ -28120,6 +28159,15 @@ msgstr ""
msgid "ProjectTemplates|iOS (Swift)"
msgstr ""
msgid "ProjectView|Activity"
msgstr ""
msgid "ProjectView|Files and Readme (default)"
msgstr ""
msgid "ProjectView|Readme"
msgstr ""
msgid "Projects"
msgstr ""
...
...
@@ -34498,6 +34546,24 @@ msgstr ""
msgid "Syntax is incorrect."
msgstr ""
msgid "SynthaxHighlightingTheme|Dark"
msgstr ""
msgid "SynthaxHighlightingTheme|Light"
msgstr ""
msgid "SynthaxHighlightingTheme|Monokai"
msgstr ""
msgid "SynthaxHighlightingTheme|None"
msgstr ""
msgid "SynthaxHighlightingTheme|Solarized Dark"
msgstr ""
msgid "SynthaxHighlightingTheme|Solarized Light"
msgstr ""
msgid "System"
msgstr ""
...
...
spec/lib/gitlab/color_schemes_spec.rb
View file @
df415198
...
...
@@ -15,7 +15,7 @@ RSpec.describe Gitlab::ColorSchemes do
describe
'.by_id'
do
it
'returns a scheme by its ID'
do
expect
(
described_class
.
by_id
(
1
).
name
).
to
eq
'
White
'
expect
(
described_class
.
by_id
(
1
).
name
).
to
eq
'
Light
'
expect
(
described_class
.
by_id
(
4
).
name
).
to
eq
'Solarized Dark'
end
end
...
...
spec/lib/gitlab/themes_spec.rb
View file @
df415198
...
...
@@ -28,7 +28,7 @@ RSpec.describe Gitlab::Themes, lib: true do
it
'prevents an infinite loop when configuration default is invalid'
do
default
=
described_class
::
APPLICATION_DEFAULT
themes
=
described_class
::
THEMES
themes
=
described_class
.
available_themes
config
=
double
(
default_theme:
0
).
as_null_object
allow
(
Gitlab
).
to
receive
(
:config
).
and_return
(
config
)
...
...
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