Skip to content

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

Fix the design patch to respond to bim config

Oliver Güntherb259e2051ec6
diff --git a/lib/open_project/custom_styles/design.rb b/lib/open_project/custom_styles/design.rb
index 085fdb79fab..94131b140c8 100644
--- a/lib/open_project/custom_styles/design.rb
+++ b/lib/open_project/custom_styles/design.rb
@@ -246,16 +246,16 @@ module OpenProject::CustomStyles
##
# Return the value after resolving all variables to values.
def self.resolved_variables
- resolved_variables = DEFAULTS.dup
+ resolved_variables = variables.dup
- DEFAULTS.each do |var_name, value|
+ variables.each do |var_name, value|
resolved_variables[var_name] = resolve_value(value)
end
resolved_variables
end
def self.resolve_value(variable_value)
- variable_value.gsub(VARIABLE_NAME_RGX) { resolve_value(DEFAULTS[$1]) }
+ variable_value.gsub(VARIABLE_NAME_RGX) { resolve_value(variables[$1]) }
end
##
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index a3291b539b4..edd4b0b530b 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -87,6 +87,7 @@ module OpenProject::Bim
patches %i[WorkPackage Type Journal RootSeeder Project]
+ patch_with_namespace :OpenProject, :CustomStyles, :Design
patch_with_namespace :BasicData, :SettingSeeder
patch_with_namespace :BasicData, :RoleSeeder
patch_with_namespace :API, :V3, :Activities, :ActivityRepresenter
@@ -161,10 +162,6 @@ module OpenProject::Bim
config.to_prepare do
require_relative 'hooks'
-
- # The DesignPatch is not a typical method patch, as it replaces a constant and thus needs to be applied without the
- # standard patch logic for plugins.
- require_relative "patches/design_patch"
end
initializer 'bim.bcf.register_hooks' do
diff --git a/modules/bim/lib/open_project/bim/patches/design_patch.rb b/modules/bim/lib/open_project/bim/patches/design_patch.rb
index 9c3cf67aeae..dd14e86b45d 100644
--- a/modules/bim/lib/open_project/bim/patches/design_patch.rb
+++ b/modules/bim/lib/open_project/bim/patches/design_patch.rb
@@ -3,24 +3,31 @@ require 'open_project/custom_styles/design'
module OpenProject::Bim
module Patches
module DesignPatch
- DEFAULTS = OpenProject::CustomStyles::Design::DEFAULTS.merge(
- {
- 'primary-color' => "#3270DB",
- 'primary-color-dark' => "#163473",
- 'alternative-color' => "#349939",
- 'header-bg-color' => "#05002C",
- 'header-item-bg-hover-color' => "#163473",
- 'content-link-color' => "#275BB5",
- 'main-menu-bg-color' => "#0E2045",
- 'main-menu-bg-selected-background' => "#3270DB",
- 'main-menu-bg-hover-background' => "#163473",
- 'header-home-link-bg' => '#{image-url("bim/logo_openproject_bim_big.png") no-repeat 20px 0}',
- 'new-feature-teaser-image' => '#{image-url("bim/new_feature_teaser.jpg")}'
- }
- ).freeze
+ def self.included(base)
+ class << base
+ prepend ClassMethods
+ end
+ end
+
+ module ClassMethods
+ def variables
+ if OpenProject::Configuration.bim?
+ super.merge 'primary-color' => "#3270DB",
+ 'primary-color-dark' => "#163473",
+ 'alternative-color' => "#349939",
+ 'header-bg-color' => "#05002C",
+ 'header-item-bg-hover-color' => "#163473",
+ 'content-link-color' => "#275BB5",
+ 'main-menu-bg-color' => "#0E2045",
+ 'main-menu-bg-selected-background' => "#3270DB",
+ 'main-menu-bg-hover-background' => "#163473",
+ 'header-home-link-bg' => '#{image-url("bim/logo_openproject_bim_big.png") no-repeat 20px 0}',
+ 'new-feature-teaser-image' => '#{image-url("bim/new_feature_teaser.jpg")}'
+ else
+ super
+ end
+ end
+ end
end
end
end
-
-OpenProject::CustomStyles::Design.send(:remove_const, 'DEFAULTS')
-OpenProject::CustomStyles::Design.const_set('DEFAULTS', OpenProject::Bim::Patches::DesignPatch::DEFAULTS)