From edc0a2a47e642cf80e982cd3a170a3a96c06fdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 26 Mar 2025 16:31:57 +0100 Subject: [PATCH] Replace show_banners with hide_banners Encode features in the configuration API, instead of relying on a boolean yes/no flag --- .../enterprise_edition/banner_component.rb | 2 +- .../subject_configuration_component.html.erb | 2 +- app/helpers/application_helper.rb | 4 +- app/helpers/homescreen_helper.rb | 2 +- app/models/enterprise_token.rb | 9 +- .../projects/settings/modules/_form.html.erb | 3 +- .../types/form/_form_configuration.html.erb | 2 +- config/initializers/homescreen.rb | 4 +- config/locales/en.yml | 2 +- config/static_links.yml | 2 +- .../app/core/config/configuration.service.ts | 4 + .../app/core/enterprise/banners.service.ts | 24 ++- .../types/group-edit-in-place.component.ts | 1 + .../admin/types/type-banner.service.ts | 17 +- .../type-form-configuration.component.ts | 4 +- .../admin/types/type-form-configuration.html | 2 +- .../board-actions-registry.service.ts | 2 +- .../board-list-container.component.ts | 4 +- .../project-selection.component.ts | 2 +- .../notifications-settings-page.component.ts | 2 +- .../notification-settings-table.component.ts | 2 +- .../query-filter/query-filter.component.ts | 2 - .../baseline/baseline.component.ts | 2 +- .../wp-share-button.component.ts | 2 +- .../wp-custom-actions.component.html | 2 +- .../wp-custom-actions.component.ts | 2 + .../tabs/columns-tab.component.ts | 2 +- .../tabs/filters-tab.component.ts | 25 ++- .../tabs/highlighting-tab.component.ts | 2 +- .../wp-table-configuration.service.ts | 4 +- .../openproject-work-packages.module.ts | 6 +- .../wp-view-highlighting.service.ts | 23 ++- .../components/grids/widgets/add/add.modal.ts | 2 +- .../configuration_representer.rb | 5 + .../menu_manager/top_menu/help_menu.rb | 8 +- .../banner_component_preview.rb | 3 - .../lib/open_project/plugins/auth_plugin.rb | 2 +- .../switch_display_representations_spec.rb | 1 - .../lib/open_project/team_planner/engine.rb | 4 +- .../banner_component_spec.rb | 23 --- spec/features/menu_items/help_menu_spec.rb | 1 - ..._display_representations_on_mobile_spec.rb | 1 - .../work_packages/highlighting_spec.rb | 1 - .../configuration_representer_spec.rb | 18 ++ spec/models/enterprise_token_spec.rb | 166 +++++++----------- .../users/register_user_service_spec.rb | 5 +- spec/support/shared/with_ee.rb | 15 +- 47 files changed, 217 insertions(+), 206 deletions(-) diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rb index 516106a3579..03927661f38 100644 --- a/app/components/enterprise_edition/banner_component.rb +++ b/app/components/enterprise_edition/banner_component.rb @@ -46,7 +46,7 @@ module EnterpriseEdition description: nil, link_title: nil, href: nil, - skip_render: !EnterpriseToken.show_banners?(feature: feature_key), + skip_render: EnterpriseToken.hide_banners?, **system_arguments) @system_arguments = system_arguments @system_arguments[:test_selector] = "op-enterprise-banner-#{feature_key.to_s.tr('_', '-')}" diff --git a/app/components/work_packages/types/subject_configuration_component.html.erb b/app/components/work_packages/types/subject_configuration_component.html.erb index 062014b3d7e..2e21afe60ff 100644 --- a/app/components/work_packages/types/subject_configuration_component.html.erb +++ b/app/components/work_packages/types/subject_configuration_component.html.erb @@ -28,7 +28,7 @@ See COPYRIGHT and LICENSE files for more details. ++#%> <%= - render(EnterpriseEdition::BannerComponent.new(:automatic_subject_generation, mb: 3)) + render(EnterpriseEdition::BannerComponent.new(:work_package_subject_generation, mb: 3)) %> <%= diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1a1ad14f73d..8146e13e3b0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -242,7 +242,9 @@ module ApplicationHelper css << ("action-#{action_name}") end - css << "ee-banners-#{EnterpriseToken.show_banners? ? 'visible' : 'hidden'}" + if EnterpriseToken.hide_banners? + css << "ee-banners-hidden" + end css << "env-#{Rails.env}" diff --git a/app/helpers/homescreen_helper.rb b/app/helpers/homescreen_helper.rb index c828f5a6623..cd0ebf088e3 100644 --- a/app/helpers/homescreen_helper.rb +++ b/app/helpers/homescreen_helper.rb @@ -54,7 +54,7 @@ module HomescreenHelper ## # Determine whether we should render the links on homescreen? def show_homescreen_links? - EnterpriseToken.show_banners? || OpenProject::Configuration.show_community_links? + OpenProject::Configuration.show_community_links? end ## diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rb index 55b2d0c44f8..5b84725c92f 100644 --- a/app/models/enterprise_token.rb +++ b/app/models/enterprise_token.rb @@ -45,12 +45,8 @@ class EnterpriseToken < ApplicationRecord current && !current.expired? end - def show_banners?(feature: nil) - if feature - OpenProject::Configuration.ee_manager_visible? && (!active? || !allows_to?(feature)) - else - OpenProject::Configuration.ee_manager_visible? && !active? - end + def hide_banners? + !OpenProject::Configuration.ee_manager_visible? end def banner_type_for(feature:) @@ -88,6 +84,7 @@ class EnterpriseToken < ApplicationRecord :reprieve_days, :reprieve_days_left, :restrictions, + :available_features, :plan, :features, :version, diff --git a/app/views/projects/settings/modules/_form.html.erb b/app/views/projects/settings/modules/_form.html.erb index da66258b55d..8c0bc3a5294 100644 --- a/app/views/projects/settings/modules/_form.html.erb +++ b/app/views/projects/settings/modules/_form.html.erb @@ -33,7 +33,8 @@ See COPYRIGHT and LICENSE files for more details.