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
f54f9cb5
Commit
f54f9cb5
authored
Apr 20, 2020
by
Roger Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to add custom profile image guidelines
parent
8b279be5
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
97 additions
and
12 deletions
+97
-12
app/controllers/admin/appearances_controller.rb
app/controllers/admin/appearances_controller.rb
+1
-0
app/helpers/appearances_helper.rb
app/helpers/appearances_helper.rb
+4
-0
app/models/appearance.rb
app/models/appearance.rb
+3
-0
app/views/admin/appearances/_form.html.haml
app/views/admin/appearances/_form.html.haml
+26
-9
app/views/profiles/show.html.haml
app/views/profiles/show.html.haml
+3
-0
changelogs/unreleased/feat-profile-image-guidelines.yml
changelogs/unreleased/feat-profile-image-guidelines.yml
+5
-0
db/migrate/20200420092011_add_profile_image_guidelines_to_appearances.rb
...0420092011_add_profile_image_guidelines_to_appearances.rb
+21
-0
db/structure.sql
db/structure.sql
+5
-1
doc/api/appearance.md
doc/api/appearance.md
+3
-0
lib/api/appearance.rb
lib/api/appearance.rb
+2
-1
lib/api/entities/appearance.rb
lib/api/entities/appearance.rb
+1
-0
spec/factories/appearances.rb
spec/factories/appearances.rb
+1
-0
spec/features/admin/admin_appearance_spec.rb
spec/features/admin/admin_appearance_spec.rb
+18
-0
spec/requests/api/appearance_spec.rb
spec/requests/api/appearance_spec.rb
+4
-1
No files found.
app/controllers/admin/appearances_controller.rb
View file @
f54f9cb5
...
...
@@ -73,6 +73,7 @@ class Admin::AppearancesController < Admin::ApplicationController
favicon
favicon_cache
new_project_guidelines
profile_image_guidelines
updated_by
header_message
footer_message
...
...
app/helpers/appearances_helper.rb
View file @
f54f9cb5
...
...
@@ -25,6 +25,10 @@ module AppearancesHelper
markdown_field
(
current_appearance
,
:new_project_guidelines
)
end
def
brand_profile_image_guidelines
markdown_field
(
current_appearance
,
:profile_image_guidelines
)
end
def
current_appearance
strong_memoize
(
:current_appearance
)
do
Appearance
.
current
...
...
app/models/appearance.rb
View file @
f54f9cb5
...
...
@@ -8,6 +8,7 @@ class Appearance < ApplicationRecord
cache_markdown_field
:description
cache_markdown_field
:new_project_guidelines
cache_markdown_field
:profile_image_guidelines
cache_markdown_field
:header_message
,
pipeline: :broadcast_message
cache_markdown_field
:footer_message
,
pipeline: :broadcast_message
...
...
@@ -15,12 +16,14 @@ class Appearance < ApplicationRecord
validates
:header_logo
,
file_size:
{
maximum:
1
.
megabyte
}
validates
:message_background_color
,
allow_blank:
true
,
color:
true
validates
:message_font_color
,
allow_blank:
true
,
color:
true
validates
:profile_image_guidelines
,
length:
{
maximum:
4096
}
validate
:single_appearance_row
,
on: :create
default_value_for
:title
,
''
default_value_for
:description
,
''
default_value_for
:new_project_guidelines
,
''
default_value_for
:profile_image_guidelines
,
''
default_value_for
:header_message
,
''
default_value_for
:footer_message
,
''
default_value_for
:message_background_color
,
'#E75E40'
...
...
app/views/admin/appearances/_form.html.haml
View file @
f54f9cb5
-
parsed_with_gfm
=
"Content parsed with
#{
link_to
(
'GitLab Flavored Markdown'
,
help_page_path
(
'user/markdown'
),
target:
'_blank'
)
}
."
.
html_safe
=
form_for
@appearance
,
url:
admin_appearances_path
,
html:
{
class:
'prepend-top-default'
}
do
|
f
|
=
form_errors
(
@appearance
)
...
...
@@ -57,7 +59,7 @@
=
f
.
label
:description
,
class:
'col-form-label label-bold'
=
f
.
text_area
:description
,
class:
"form-control"
,
rows:
10
.hint
Description parsed with
#{
link_to
"GitLab Flavored Markdown"
,
help_page_path
(
'user/markdown'
),
target:
'_blank'
}
.
=
parsed_with_gfm
.form-group
=
f
.
label
:logo
,
class:
'col-form-label label-bold pt-0'
%p
...
...
@@ -83,15 +85,30 @@
%p
=
f
.
text_area
:new_project_guidelines
,
class:
"form-control"
,
rows:
10
.hint
Guidelines parsed with
#{
link_to
"GitLab Flavored Markdown"
,
help_page_path
(
'user/markdown'
),
target:
'_blank'
}
.
=
parsed_with_gfm
%hr
.row
.col-lg-4.profile-settings-sidebar
%h4
.prepend-top-0
Profile image guideline
.col-lg-8
.form-group
=
f
.
label
:profile_image_guidelines
,
class:
'col-form-label label-bold'
%p
=
f
.
text_area
:profile_image_guidelines
,
class:
"form-control"
,
rows:
10
.hint
=
parsed_with_gfm
.prepend-top-default.append-bottom-default
=
f
.
submit
'Update appearance settings'
,
class:
'btn btn-success'
-
if
@appearance
.
persisted?
Preview last save:
=
link_to
'Sign-in page'
,
preview_sign_in_admin_appearances_path
,
class:
'btn'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
=
link_to
'New project page'
,
new_project_path
,
class:
'btn'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
-
if
@appearance
.
persisted?
||
@appearance
.
updated_at
.mt-4
-
if
@appearance
.
persisted?
Preview last save:
=
link_to
'Sign-in page'
,
preview_sign_in_admin_appearances_path
,
class:
'btn'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
=
link_to
'New project page'
,
new_project_path
,
class:
'btn'
,
target:
'_blank'
,
rel:
'noopener noreferrer'
-
if
@appearance
.
updated_at
%span
.float-right
Last edit
#{
time_ago_with_tooltip
(
@appearance
.
updated_at
)
}
-
if
@appearance
.
updated_at
%span
.float-right
Last edit
#{
time_ago_with_tooltip
(
@appearance
.
updated_at
)
}
app/views/profiles/show.html.haml
View file @
f54f9cb5
...
...
@@ -20,6 +20,9 @@
=
s_
(
"Profiles|You can upload your avatar here or change it at %{gravatar_link}"
).
html_safe
%
{
gravatar_link:
gravatar_link
}
-
else
=
s_
(
"Profiles|You can upload your avatar here"
)
-
if
current_appearance
&
.
profile_image_guidelines?
.md
=
brand_profile_image_guidelines
.col-lg-8
.clearfix.avatar-image.append-bottom-default
=
link_to
avatar_icon_for_user
(
@user
,
400
),
target:
'_blank'
,
rel:
'noopener noreferrer'
do
...
...
changelogs/unreleased/feat-profile-image-guidelines.yml
0 → 100644
View file @
f54f9cb5
---
title
:
Add option to add custom profile image guidelines
merge_request
:
29894
author
:
Roger Meier
type
:
added
db/migrate/20200420092011_add_profile_image_guidelines_to_appearances.rb
0 → 100644
View file @
f54f9cb5
# frozen_string_literal: true
class
AddProfileImageGuidelinesToAppearances
<
ActiveRecord
::
Migration
[
6.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column
:appearances
,
:profile_image_guidelines
,
:text
,
null:
true
add_column
:appearances
,
:profile_image_guidelines_html
,
:text
,
null:
true
# rubocop:disable Migration/AddLimitToTextColumns
add_text_limit
:appearances
,
:profile_image_guidelines
,
4096
,
constraint_name:
'appearances_profile_image_guidelines'
end
def
down
remove_column
:appearances
,
:profile_image_guidelines
remove_column
:appearances
,
:profile_image_guidelines_html
end
end
db/structure.sql
View file @
f54f9cb5
...
...
@@ -171,7 +171,10 @@ CREATE TABLE public.appearances (
message_background_color
text
,
message_font_color
text
,
favicon
character
varying
,
email_header_and_footer_enabled
boolean
DEFAULT
false
NOT
NULL
email_header_and_footer_enabled
boolean
DEFAULT
false
NOT
NULL
,
profile_image_guidelines
text
,
profile_image_guidelines_html
text
,
CONSTRAINT
appearances_profile_image_guidelines
CHECK
((
char_length
(
profile_image_guidelines
)
<=
4096
))
);
CREATE
SEQUENCE
public
.
appearances_id_seq
...
...
@@ -13511,6 +13514,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200416120354
20200417044453
20200417145946
20200420092011
20200420104303
20200420104323
20200420162730
...
...
doc/api/appearance.md
View file @
f54f9cb5
...
...
@@ -27,6 +27,7 @@ Example response:
"header_logo"
:
"/uploads/-/system/appearance/header_logo/1/header.png"
,
"favicon"
:
"/uploads/-/system/appearance/favicon/1/favicon.png"
,
"new_project_guidelines"
:
"Please read the FAQs for help."
,
"profile_image_guidelines"
:
"Custom profile image guidelines"
,
"header_message"
:
""
,
"footer_message"
:
""
,
"message_background_color"
:
"#e75e40"
,
...
...
@@ -51,6 +52,7 @@ PUT /application/appearance
|
`header_logo`
| mixed | no | Instance image used for the main navigation bar
|
`favicon`
| mixed | no | Instance favicon in .ico/.png format
|
`new_project_guidelines`
| string | no | Markdown text shown on the new project page
|
`profile_image_guidelines`
| string | no | Markdown text shown on the profile page below Public Avatar
|
`header_message`
| string | no | Message within the system header bar
|
`footer_message`
| string | no | Message within the system footer bar
|
`message_background_color`
| string | no | Background color for the system header / footer bar
...
...
@@ -71,6 +73,7 @@ Example response:
"header_logo"
:
"/uploads/-/system/appearance/header_logo/1/header.png"
,
"favicon"
:
"/uploads/-/system/appearance/favicon/1/favicon.png"
,
"new_project_guidelines"
:
"Please read the FAQs for help."
,
"profile_image_guidelines"
:
"Custom profile image guidelines"
,
"header_message"
:
"test"
,
"footer_message"
:
""
,
"message_background_color"
:
"#e75e40"
,
...
...
lib/api/appearance.rb
View file @
f54f9cb5
...
...
@@ -27,7 +27,8 @@ module API
optional
:logo
,
type:
File
,
desc:
'Instance image used on the sign in / sign up page'
# rubocop:disable Scalability/FileUploads
optional
:header_logo
,
type:
File
,
desc:
'Instance image used for the main navigation bar'
# rubocop:disable Scalability/FileUploads
optional
:favicon
,
type:
File
,
desc:
'Instance favicon in .ico/.png format'
# rubocop:disable Scalability/FileUploads
optional
:new_project_guidelines
,
type:
String
,
desc:
'Markmarkdown text shown on the new project page'
optional
:new_project_guidelines
,
type:
String
,
desc:
'Markdown text shown on the new project page'
optional
:profile_image_guidelines
,
type:
String
,
desc:
'Markdown text shown on the profile page below Public Avatar'
optional
:header_message
,
type:
String
,
desc:
'Message within the system header bar'
optional
:footer_message
,
type:
String
,
desc:
'Message within the system footer bar'
optional
:message_background_color
,
type:
String
,
desc:
'Background color for the system header / footer bar'
...
...
lib/api/entities/appearance.rb
View file @
f54f9cb5
...
...
@@ -19,6 +19,7 @@ module API
end
expose
:new_project_guidelines
expose
:profile_image_guidelines
expose
:header_message
expose
:footer_message
expose
:message_background_color
...
...
spec/factories/appearances.rb
View file @
f54f9cb5
...
...
@@ -7,6 +7,7 @@ FactoryBot.define do
title
{
"GitLab Community Edition"
}
description
{
"Open source software to collaborate on code"
}
new_project_guidelines
{
"Custom project guidelines"
}
profile_image_guidelines
{
"Custom profile image guidelines"
}
end
trait
:with_logo
do
...
...
spec/features/admin/admin_appearance_spec.rb
View file @
f54f9cb5
...
...
@@ -12,6 +12,7 @@ describe 'Admin Appearance' do
fill_in
'appearance_title'
,
with:
'MyCompany'
fill_in
'appearance_description'
,
with:
'dev server'
fill_in
'appearance_new_project_guidelines'
,
with:
'Custom project guidelines'
fill_in
'appearance_profile_image_guidelines'
,
with:
'Custom profile image guidelines'
click_button
'Update appearance settings'
expect
(
current_path
).
to
eq
admin_appearances_path
...
...
@@ -20,6 +21,7 @@ describe 'Admin Appearance' do
expect
(
page
).
to
have_field
(
'appearance_title'
,
with:
'MyCompany'
)
expect
(
page
).
to
have_field
(
'appearance_description'
,
with:
'dev server'
)
expect
(
page
).
to
have_field
(
'appearance_new_project_guidelines'
,
with:
'Custom project guidelines'
)
expect
(
page
).
to
have_field
(
'appearance_profile_image_guidelines'
,
with:
'Custom profile image guidelines'
)
expect
(
page
).
to
have_content
'Last edit'
end
...
...
@@ -86,6 +88,22 @@ describe 'Admin Appearance' do
expect_custom_new_project_appearance
(
appearance
)
end
context
'Profile page with custom profile image guidelines'
do
before
do
sign_in
(
create
(
:admin
))
visit
admin_appearances_path
fill_in
'appearance_profile_image_guidelines'
,
with:
'Custom profile image guidelines, please :smile:!'
click_button
'Update appearance settings'
end
it
'renders guidelines when set'
do
sign_in
create
(
:user
)
visit
profile_path
expect
(
page
).
to
have_content
'Custom profile image guidelines, please 😄!'
end
end
it
'Appearance logo'
do
sign_in
(
create
(
:admin
))
visit
admin_appearances_path
...
...
spec/requests/api/appearance_spec.rb
View file @
f54f9cb5
...
...
@@ -31,6 +31,7 @@ describe API::Appearance, 'Appearance' do
expect
(
json_response
[
'message_background_color'
]).
to
eq
(
'#E75E40'
)
expect
(
json_response
[
'message_font_color'
]).
to
eq
(
'#FFFFFF'
)
expect
(
json_response
[
'new_project_guidelines'
]).
to
eq
(
''
)
expect
(
json_response
[
'profile_image_guidelines'
]).
to
eq
(
''
)
expect
(
json_response
[
'title'
]).
to
eq
(
''
)
end
end
...
...
@@ -51,7 +52,8 @@ describe API::Appearance, 'Appearance' do
put
api
(
"/application/appearance"
,
admin
),
params:
{
title:
"GitLab Test Instance"
,
description:
"gitlab-test.example.com"
,
new_project_guidelines:
"Please read the FAQs for help."
new_project_guidelines:
"Please read the FAQs for help."
,
profile_image_guidelines:
"Custom profile image guidelines"
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
...
...
@@ -66,6 +68,7 @@ describe API::Appearance, 'Appearance' do
expect
(
json_response
[
'message_background_color'
]).
to
eq
(
'#E75E40'
)
expect
(
json_response
[
'message_font_color'
]).
to
eq
(
'#FFFFFF'
)
expect
(
json_response
[
'new_project_guidelines'
]).
to
eq
(
'Please read the FAQs for help.'
)
expect
(
json_response
[
'profile_image_guidelines'
]).
to
eq
(
'Custom profile image guidelines'
)
expect
(
json_response
[
'title'
]).
to
eq
(
'GitLab Test Instance'
)
end
end
...
...
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