diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 06:07:57 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-09 06:07:57 +0000 |
commit | 8bda404e2919234c299f088b7d8d04f8449125de (patch) | |
tree | cec81ff8bb6dbc77c3ae9b3580bb40c247599afd /lib | |
parent | afa0ab923d697a3e737b04d078d3f28e0d573901 (diff) | |
download | gitlab-ce-8bda404e2919234c299f088b7d8d04f8449125de.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/appearance.rb | 47 | ||||
-rw-r--r-- | lib/api/entities.rb | 24 |
3 files changed, 72 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index eae10738f32..555639a4b62 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -104,6 +104,7 @@ module API # Keep in alphabetical order mount ::API::AccessRequests + mount ::API::Appearance mount ::API::Applications mount ::API::Avatar mount ::API::AwardEmoji diff --git a/lib/api/appearance.rb b/lib/api/appearance.rb new file mode 100644 index 00000000000..a775102e87d --- /dev/null +++ b/lib/api/appearance.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module API + class Appearance < Grape::API + before { authenticated_as_admin! } + + helpers do + def current_appearance + @current_appearance ||= (::Appearance.current || ::Appearance.new) + end + end + + desc 'Get the current appearance' do + success Entities::Appearance + end + get "application/appearance" do + present current_appearance, with: Entities::Appearance + end + + desc 'Modify appearance' do + success Entities::Appearance + end + params do + optional :title, type: String, desc: 'Instance title on the sign in / sign up page' + optional :description, type: String, desc: 'Markdown text shown on the sign in / sign up page' + # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 + 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 :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' + optional :message_font_color, type: String, desc: 'Font color for the system header / footer bar' + optional :email_header_and_footer_enabled, type: Boolean, desc: 'Add header and footer to all outgoing emails if enabled' + end + put "application/appearance" do + attrs = declared_params(include_missing: false) + + if current_appearance.update(attrs) + present current_appearance, with: Entities::Appearance + else + render_validation_error!(current_appearance) + end + end + end +end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e6803d48a47..9433edb20b0 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1343,6 +1343,30 @@ module API expose :allow_local_requests_from_web_hooks_and_services, as: :allow_local_requests_from_hooks_and_services end + class Appearance < Grape::Entity + expose :title + expose :description + + expose :logo do |appearance, options| + appearance.logo.url + end + + expose :header_logo do |appearance, options| + appearance.header_logo.url + end + + expose :favicon do |appearance, options| + appearance.favicon.url + end + + expose :new_project_guidelines + expose :header_message + expose :footer_message + expose :message_background_color + expose :message_font_color + expose :email_header_and_footer_enabled + end + # deprecated old Release representation class TagRelease < Grape::Entity expose :tag, as: :tag_name |