OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Allow themes to define a logo (dark vs. light) when there is no custom logo defined
Henriette Dinger46eeaadd8e9c
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex 6ce8f384d9b..ea8457624f0 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -96,8 +96,12 @@ class CustomStylesController < ApplicationControllerenddef update_themes- variable_params = OpenProject::CustomStyles::ColorThemes::THEMES.find { |theme| theme[:name] == params[:theme] }[:colors]- set_colors(variable_params)+ theme = OpenProject::CustomStyles::ColorThemes::THEMES.find { |t| t[:name] == params[:theme] }+ color_params = theme[:colors]+ logo = theme[:logo]++ set_logo(logo)+ set_colors(color_params)set_theme(params)redirect_to action: :show@@ -116,6 +120,10 @@ class CustomStylesController < ApplicationControlleroptionsend+ def set_logo(logo)+ CustomStyle.current.update(theme_logo: logo)+ end+def set_colors(variable_params)variable_params.each do |param_variable, param_hexcode|if design_color = DesignColor.find_by(variable: param_variable)diff --git a/app/views/custom_styles/_inline_css.erb b/app/views/custom_styles/_inline_css.erbindex 511b48e988f..e8c9242cb30 100644--- a/app/views/custom_styles/_inline_css.erb+++ b/app/views/custom_styles/_inline_css.erb@@ -32,6 +32,10 @@ See docs/COPYRIGHT.rdoc for more details.#logo .home-link {background-image: url("<%= custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier) %>");}+ <% elsif CustomStyle.current.theme_logo %>+ #logo .home-link {+ background-image: url("<%= asset_path(CustomStyle.current.theme_logo) %>");+ }<% end %>:root {diff --git a/db/migrate/20200206101135_add_theme_logo_to_custom_style.rb b/db/migrate/20200206101135_add_theme_logo_to_custom_style.rbnew file mode 100644index 00000000000..6cbfb7ba005--- /dev/null+++ b/db/migrate/20200206101135_add_theme_logo_to_custom_style.rb@@ -0,0 +1,5 @@+class AddThemeLogoToCustomStyle < ActiveRecord::Migration[6.0]+ def change+ add_column :custom_styles, :theme_logo, :string, default: nil+ end+enddiff --git a/lib/open_project/custom_styles/color_themes.rb b/lib/open_project/custom_styles/color_themes.rbindex 243b1b68847..040929356b3 100644--- a/lib/open_project/custom_styles/color_themes.rb+++ b/lib/open_project/custom_styles/color_themes.rb@@ -70,7 +70,8 @@ module OpenProject::CustomStyles'main-menu-hover-font-color' => "#000000",'main-menu-selected-font-color' => "#000000",'main-menu-border-color' => "#EAEAEA"- }+ },+ logo: 'logo_openproject.png'},{name: 'OpenProject Dark',