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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
6c49a628
Commit
6c49a628
authored
Aug 17, 2017
by
Rubén Dávila
Committed by
Ruben Davila
Sep 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore some changes from !9199
parent
8d1321d6
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
197 additions
and
8 deletions
+197
-8
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-0
app/controllers/profiles/preferences_controller.rb
app/controllers/profiles/preferences_controller.rb
+2
-1
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+4
-0
app/models/user.rb
app/models/user.rb
+1
-0
config/gitlab.yml.example
config/gitlab.yml.example
+9
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
doc/api/keys.md
doc/api/keys.md
+1
-0
doc/api/session.md
doc/api/session.md
+1
-0
doc/api/users.md
doc/api/users.md
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/gitlab/themes.rb
lib/gitlab/themes.rb
+87
-0
spec/controllers/profiles/preferences_controller_spec.rb
spec/controllers/profiles/preferences_controller_spec.rb
+4
-2
spec/fixtures/api/schemas/public_api/v4/user/login.json
spec/fixtures/api/schemas/public_api/v4/user/login.json
+1
-0
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+26
-0
spec/lib/gitlab/themes_spec.rb
spec/lib/gitlab/themes_spec.rb
+48
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
spec/support/gitlab_stubs/session.json
spec/support/gitlab_stubs/session.json
+1
-1
spec/support/gitlab_stubs/user.json
spec/support/gitlab_stubs/user.json
+2
-2
No files found.
app/controllers/admin/users_controller.rb
View file @
6c49a628
...
@@ -211,6 +211,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -211,6 +211,7 @@ class Admin::UsersController < Admin::ApplicationController
:provider
,
:provider
,
:remember_me
,
:remember_me
,
:skype
,
:skype
,
:theme_id
,
:twitter
,
:twitter
,
:username
,
:username
,
:website_url
:website_url
...
...
app/controllers/profiles/preferences_controller.rb
View file @
6c49a628
...
@@ -35,7 +35,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
...
@@ -35,7 +35,8 @@ class Profiles::PreferencesController < Profiles::ApplicationController
:color_scheme_id
,
:color_scheme_id
,
:layout
,
:layout
,
:dashboard
,
:dashboard
,
:project_view
:project_view
,
:theme_id
)
)
end
end
end
end
app/helpers/preferences_helper.rb
View file @
6c49a628
...
@@ -40,6 +40,10 @@ module PreferencesHelper
...
@@ -40,6 +40,10 @@ module PreferencesHelper
]
]
end
end
def
user_application_theme
Gitlab
::
Themes
.
for_user
(
current_user
).
css_class
end
def
user_color_scheme
def
user_color_scheme
Gitlab
::
ColorSchemes
.
for_user
(
current_user
).
css_class
Gitlab
::
ColorSchemes
.
for_user
(
current_user
).
css_class
end
end
...
...
app/models/user.rb
View file @
6c49a628
...
@@ -35,6 +35,7 @@ class User < ActiveRecord::Base
...
@@ -35,6 +35,7 @@ class User < ActiveRecord::Base
default_value_for
:project_view
,
:files
default_value_for
:project_view
,
:files
default_value_for
:notified_of_own_activity
,
false
default_value_for
:notified_of_own_activity
,
false
default_value_for
:preferred_language
,
I18n
.
default_locale
default_value_for
:preferred_language
,
I18n
.
default_locale
default_value_for
:theme_id
,
gitlab_config
.
default_theme
attr_encrypted
:otp_secret
,
attr_encrypted
:otp_secret
,
key:
Gitlab
::
Application
.
secrets
.
otp_key_base
,
key:
Gitlab
::
Application
.
secrets
.
otp_key_base
,
...
...
config/gitlab.yml.example
View file @
6c49a628
...
@@ -76,6 +76,14 @@ production: &base
...
@@ -76,6 +76,14 @@ production: &base
# default_can_create_group: false # default: true
# default_can_create_group: false # default: true
# username_changing_enabled: false # default: true - User can change her username/namespace
# username_changing_enabled: false # default: true - User can change her username/namespace
## Default theme ID
## 1 - Graphite
## 2 - Charcoal
## 3 - Green
## 4 - Gray
## 5 - Violet
## 6 - Blue
# default_theme: 2 # default: 2
## Automatic issue closing
## Automatic issue closing
# If a commit message matches this regular expression, all issues referenced from the matched text will be closed.
# If a commit message matches this regular expression, all issues referenced from the matched text will be closed.
...
@@ -741,4 +749,4 @@ test:
...
@@ -741,4 +749,4 @@ test:
admin_group: ''
admin_group: ''
staging:
staging:
<<: *base
<<: *base
\ No newline at end of file
config/initializers/1_settings.rb
View file @
6c49a628
...
@@ -232,6 +232,7 @@ Settings['gitlab'] ||= Settingslogic.new({})
...
@@ -232,6 +232,7 @@ Settings['gitlab'] ||= Settingslogic.new({})
Settings
.
gitlab
[
'default_projects_limit'
]
||=
100000
Settings
.
gitlab
[
'default_projects_limit'
]
||=
100000
Settings
.
gitlab
[
'default_branch_protection'
]
||=
2
Settings
.
gitlab
[
'default_branch_protection'
]
||=
2
Settings
.
gitlab
[
'default_can_create_group'
]
=
true
if
Settings
.
gitlab
[
'default_can_create_group'
].
nil?
Settings
.
gitlab
[
'default_can_create_group'
]
=
true
if
Settings
.
gitlab
[
'default_can_create_group'
].
nil?
Settings
.
gitlab
[
'default_theme'
]
=
Gitlab
::
Themes
::
APPLICATION_DEFAULT
if
Settings
.
gitlab
[
'default_theme'
].
nil?
Settings
.
gitlab
[
'host'
]
||=
ENV
[
'GITLAB_HOST'
]
||
'localhost'
Settings
.
gitlab
[
'host'
]
||=
ENV
[
'GITLAB_HOST'
]
||
'localhost'
Settings
.
gitlab
[
'ssh_host'
]
||=
Settings
.
gitlab
.
host
Settings
.
gitlab
[
'ssh_host'
]
||=
Settings
.
gitlab
.
host
Settings
.
gitlab
[
'https'
]
=
false
if
Settings
.
gitlab
[
'https'
].
nil?
Settings
.
gitlab
[
'https'
]
=
false
if
Settings
.
gitlab
[
'https'
].
nil?
...
...
doc/api/keys.md
View file @
6c49a628
...
@@ -32,6 +32,7 @@ Parameters:
...
@@ -32,6 +32,7 @@ Parameters:
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"email"
:
"john@example.com"
,
"email"
:
"john@example.com"
,
"theme_id"
:
2
,
"color_scheme_id"
:
1
,
"color_scheme_id"
:
1
,
"projects_limit"
:
10
,
"projects_limit"
:
10
,
"current_sign_in_at"
:
null
,
"current_sign_in_at"
:
null
,
...
...
doc/api/session.md
View file @
6c49a628
...
@@ -39,6 +39,7 @@ Example response:
...
@@ -39,6 +39,7 @@ Example response:
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"email"
:
"john@example.com"
,
"email"
:
"john@example.com"
,
"theme_id"
:
1
,
"color_scheme_id"
:
1
,
"color_scheme_id"
:
1
,
"projects_limit"
:
10
,
"projects_limit"
:
10
,
"current_sign_in_at"
:
"2015-07-07T07:10:58.392Z"
,
"current_sign_in_at"
:
"2015-07-07T07:10:58.392Z"
,
...
...
doc/api/users.md
View file @
6c49a628
...
@@ -72,6 +72,7 @@ GET /users
...
@@ -72,6 +72,7 @@ GET /users
"organization"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"last_activity_on"
:
"2012-05-23"
,
"last_activity_on"
:
"2012-05-23"
,
"color_scheme_id"
:
2
,
"color_scheme_id"
:
2
,
"projects_limit"
:
100
,
"projects_limit"
:
100
,
...
@@ -105,6 +106,7 @@ GET /users
...
@@ -105,6 +106,7 @@ GET /users
"organization"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
null
,
"last_sign_in_at"
:
null
,
"confirmed_at"
:
"2012-05-30T16:53:06.148Z"
,
"confirmed_at"
:
"2012-05-30T16:53:06.148Z"
,
"theme_id"
:
1
,
"last_activity_on"
:
"2012-05-23"
,
"last_activity_on"
:
"2012-05-23"
,
"color_scheme_id"
:
3
,
"color_scheme_id"
:
3
,
"projects_limit"
:
100
,
"projects_limit"
:
100
,
...
@@ -215,6 +217,7 @@ Parameters:
...
@@ -215,6 +217,7 @@ Parameters:
"organization"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"last_activity_on"
:
"2012-05-23"
,
"last_activity_on"
:
"2012-05-23"
,
"color_scheme_id"
:
2
,
"color_scheme_id"
:
2
,
"projects_limit"
:
100
,
"projects_limit"
:
100
,
...
@@ -341,6 +344,7 @@ GET /user
...
@@ -341,6 +344,7 @@ GET /user
"organization"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"last_activity_on"
:
"2012-05-23"
,
"last_activity_on"
:
"2012-05-23"
,
"color_scheme_id"
:
2
,
"color_scheme_id"
:
2
,
"projects_limit"
:
100
,
"projects_limit"
:
100
,
...
@@ -387,6 +391,7 @@ GET /user
...
@@ -387,6 +391,7 @@ GET /user
"organization"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"last_activity_on"
:
"2012-05-23"
,
"last_activity_on"
:
"2012-05-23"
,
"color_scheme_id"
:
2
,
"color_scheme_id"
:
2
,
"projects_limit"
:
100
,
"projects_limit"
:
100
,
...
...
lib/api/entities.rb
View file @
6c49a628
...
@@ -35,7 +35,7 @@ module API
...
@@ -35,7 +35,7 @@ module API
expose
:confirmed_at
expose
:confirmed_at
expose
:last_activity_on
expose
:last_activity_on
expose
:email
expose
:email
expose
:color_scheme_id
,
:projects_limit
,
:current_sign_in_at
expose
:
theme_id
,
:
color_scheme_id
,
:projects_limit
,
:current_sign_in_at
expose
:identities
,
using:
Entities
::
Identity
expose
:identities
,
using:
Entities
::
Identity
expose
:can_create_group?
,
as: :can_create_group
expose
:can_create_group?
,
as: :can_create_group
expose
:can_create_project?
,
as: :can_create_project
expose
:can_create_project?
,
as: :can_create_project
...
...
lib/gitlab/themes.rb
0 → 100644
View file @
6c49a628
module
Gitlab
# Module containing GitLab's application theme definitions and helper methods
# for accessing them.
module
Themes
extend
self
# Theme ID used when no `default_theme` configuration setting is provided.
APPLICATION_DEFAULT
=
2
# Struct class representing a single Theme
Theme
=
Struct
.
new
(
:id
,
:name
,
:css_class
)
# All available Themes
THEMES
=
[
Theme
.
new
(
1
,
'Graphite'
,
'ui_graphite'
),
Theme
.
new
(
2
,
'Charcoal'
,
'ui_charcoal'
),
Theme
.
new
(
3
,
'Green'
,
'ui_green'
),
Theme
.
new
(
4
,
'Black'
,
'ui_black'
),
Theme
.
new
(
5
,
'Violet'
,
'ui_violet'
),
Theme
.
new
(
6
,
'Blue'
,
'ui_blue'
)
].
freeze
# 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
(
' '
)
end
# Get a Theme by its ID
#
# If the ID is invalid, returns the default Theme.
#
# id - Integer ID
#
# Returns a Theme
def
by_id
(
id
)
THEMES
.
detect
{
|
t
|
t
.
id
==
id
}
||
default
end
# Returns the number of defined Themes
def
count
THEMES
.
size
end
# Get the default Theme
#
# Returns a Theme
def
default
by_id
(
default_id
)
end
# Iterate through each Theme
#
# Yields the Theme object
def
each
(
&
block
)
THEMES
.
each
(
&
block
)
end
# Get the Theme for the specified user, or the default
#
# user - User record
#
# Returns a Theme
def
for_user
(
user
)
if
user
by_id
(
user
.
theme_id
)
else
default
end
end
private
def
default_id
id
=
Gitlab
.
config
.
gitlab
.
default_theme
.
to_i
# Prevent an invalid configuration setting from causing an infinite loop
if
id
<
THEMES
.
first
.
id
||
id
>
THEMES
.
last
.
id
APPLICATION_DEFAULT
else
id
end
end
end
end
spec/controllers/profiles/preferences_controller_spec.rb
View file @
6c49a628
...
@@ -25,7 +25,8 @@ describe Profiles::PreferencesController do
...
@@ -25,7 +25,8 @@ describe Profiles::PreferencesController do
def
go
(
params:
{},
format: :js
)
def
go
(
params:
{},
format: :js
)
params
.
reverse_merge!
(
params
.
reverse_merge!
(
color_scheme_id:
'1'
,
color_scheme_id:
'1'
,
dashboard:
'stars'
dashboard:
'stars'
,
theme_id:
'1'
)
)
patch
:update
,
user:
params
,
format:
format
patch
:update
,
user:
params
,
format:
format
...
@@ -40,7 +41,8 @@ describe Profiles::PreferencesController do
...
@@ -40,7 +41,8 @@ describe Profiles::PreferencesController do
it
"changes the user's preferences"
do
it
"changes the user's preferences"
do
prefs
=
{
prefs
=
{
color_scheme_id:
'1'
,
color_scheme_id:
'1'
,
dashboard:
'stars'
dashboard:
'stars'
,
theme_id:
'2'
}.
with_indifferent_access
}.
with_indifferent_access
expect
(
user
).
to
receive
(
:assign_attributes
).
with
(
prefs
)
expect
(
user
).
to
receive
(
:assign_attributes
).
with
(
prefs
)
...
...
spec/fixtures/api/schemas/public_api/v4/user/login.json
View file @
6c49a628
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
"organization"
,
"organization"
,
"last_sign_in_at"
,
"last_sign_in_at"
,
"confirmed_at"
,
"confirmed_at"
,
"theme_id"
,
"color_scheme_id"
,
"color_scheme_id"
,
"projects_limit"
,
"projects_limit"
,
"current_sign_in_at"
,
"current_sign_in_at"
,
...
...
spec/helpers/preferences_helper_spec.rb
View file @
6c49a628
...
@@ -26,6 +26,32 @@ describe PreferencesHelper do
...
@@ -26,6 +26,32 @@ describe PreferencesHelper do
end
end
end
end
describe
'user_application_theme'
do
context
'with a user'
do
it
"returns user's theme's css_class"
do
stub_user
(
theme_id:
3
)
expect
(
helper
.
user_application_theme
).
to
eq
'ui_green'
end
it
'returns the default when id is invalid'
do
stub_user
(
theme_id:
Gitlab
::
Themes
.
count
+
5
)
allow
(
Gitlab
.
config
.
gitlab
).
to
receive
(
:default_theme
).
and_return
(
2
)
expect
(
helper
.
user_application_theme
).
to
eq
'ui_charcoal'
end
end
context
'without a user'
do
it
'returns the default theme'
do
stub_user
expect
(
helper
.
user_application_theme
).
to
eq
Gitlab
::
Themes
.
default
.
css_class
end
end
end
describe
'user_color_scheme'
do
describe
'user_color_scheme'
do
context
'with a user'
do
context
'with a user'
do
it
"returns user's scheme's css_class"
do
it
"returns user's scheme's css_class"
do
...
...
spec/lib/gitlab/themes_spec.rb
0 → 100644
View file @
6c49a628
require
'spec_helper'
describe
Gitlab
::
Themes
,
lib:
true
do
describe
'.body_classes'
do
it
'returns a space-separated list of class names'
do
css
=
described_class
.
body_classes
expect
(
css
).
to
include
(
'ui_graphite'
)
expect
(
css
).
to
include
(
' ui_charcoal '
)
expect
(
css
).
to
include
(
' ui_blue'
)
end
end
describe
'.by_id'
do
it
'returns a Theme by its ID'
do
expect
(
described_class
.
by_id
(
1
).
name
).
to
eq
'Graphite'
expect
(
described_class
.
by_id
(
6
).
name
).
to
eq
'Blue'
end
end
describe
'.default'
do
it
'returns the default application theme'
do
allow
(
described_class
).
to
receive
(
:default_id
).
and_return
(
2
)
expect
(
described_class
.
default
.
id
).
to
eq
2
end
it
'prevents an infinite loop when configuration default is invalid'
do
default
=
described_class
::
APPLICATION_DEFAULT
themes
=
described_class
::
THEMES
config
=
double
(
default_theme:
0
).
as_null_object
allow
(
Gitlab
).
to
receive
(
:config
).
and_return
(
config
)
expect
(
described_class
.
default
.
id
).
to
eq
default
config
=
double
(
default_theme:
themes
.
size
+
5
).
as_null_object
allow
(
Gitlab
).
to
receive
(
:config
).
and_return
(
config
)
expect
(
described_class
.
default
.
id
).
to
eq
default
end
end
describe
'.each'
do
it
'passes the block to the THEMES Array'
do
ids
=
[]
described_class
.
each
{
|
theme
|
ids
<<
theme
.
id
}
expect
(
ids
).
not_to
be_empty
end
end
end
spec/models/user_spec.rb
View file @
6c49a628
...
@@ -716,6 +716,7 @@ describe User do
...
@@ -716,6 +716,7 @@ describe User do
it
"applies defaults to user"
do
it
"applies defaults to user"
do
expect
(
user
.
projects_limit
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_projects_limit
)
expect
(
user
.
projects_limit
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_projects_limit
)
expect
(
user
.
can_create_group
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_can_create_group
)
expect
(
user
.
can_create_group
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_can_create_group
)
expect
(
user
.
theme_id
).
to
eq
(
Gitlab
.
config
.
gitlab
.
default_theme
)
expect
(
user
.
external
).
to
be_falsey
expect
(
user
.
external
).
to
be_falsey
end
end
end
end
...
@@ -726,6 +727,7 @@ describe User do
...
@@ -726,6 +727,7 @@ describe User do
it
"applies defaults to user"
do
it
"applies defaults to user"
do
expect
(
user
.
projects_limit
).
to
eq
(
123
)
expect
(
user
.
projects_limit
).
to
eq
(
123
)
expect
(
user
.
can_create_group
).
to
be_falsey
expect
(
user
.
can_create_group
).
to
be_falsey
expect
(
user
.
theme_id
).
to
eq
(
1
)
end
end
end
end
...
...
spec/support/gitlab_stubs/session.json
View file @
6c49a628
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"skype"
:
"aertert"
,
"skype"
:
"aertert"
,
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"color_scheme_id"
:
2
,
"
theme_id"
:
2
,
"
color_scheme_id"
:
2
,
"state"
:
"active"
,
"state"
:
"active"
,
"created_at"
:
"2012-12-21T13:02:20Z"
,
"created_at"
:
"2012-12-21T13:02:20Z"
,
"extern_uid"
:
null
,
"extern_uid"
:
null
,
...
...
spec/support/gitlab_stubs/user.json
View file @
6c49a628
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"skype"
:
"aertert"
,
"skype"
:
"aertert"
,
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"color_scheme_id"
:
2
,
"
theme_id"
:
2
,
"
color_scheme_id"
:
2
,
"state"
:
"active"
,
"state"
:
"active"
,
"created_at"
:
"2012-12-21T13:02:20Z"
,
"created_at"
:
"2012-12-21T13:02:20Z"
,
"extern_uid"
:
null
,
"extern_uid"
:
null
,
...
@@ -17,4 +17,4 @@
...
@@ -17,4 +17,4 @@
"can_create_project"
:
false
,
"can_create_project"
:
false
,
"private_token"
:
"Wvjy2Krpb7y8xi93owUz"
,
"private_token"
:
"Wvjy2Krpb7y8xi93owUz"
,
"access_token"
:
"Wvjy2Krpb7y8xi93owUz"
"access_token"
:
"Wvjy2Krpb7y8xi93owUz"
}
}
\ No newline at end of file
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