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

Update trial banner handling for sharing modals

Mir Bhatia9f1b2ebb3265
diff --git a/app/components/shares/modal_body_component.html.erb b/app/components/shares/modal_body_component.html.erb
index d2da46e0b2a..7612091818c 100644
--- a/app/components/shares/modal_body_component.html.erb
+++ b/app/components/shares/modal_body_component.html.erb
@@ -7,9 +7,8 @@
end
end
- render(Shares::ProjectQueries::UpsellComponent.new(modal_content:))
-
- render(strategy.manage_shares_component(modal_content:, errors:)) if EnterpriseToken.allows_to?(:project_list_sharing)
+ render(strategy.upsell_banner(modal_content:))
+ render(strategy.manage_shares_component(modal_content:, errors:)) if strategy.allow_feature?
end
end
%>
diff --git a/app/components/shares/work_packages/modal_upsell_component.html.erb b/app/components/shares/work_packages/modal_upsell_component.html.erb
index b283aba4e06..f10285902d1 100644
--- a/app/components/shares/work_packages/modal_upsell_component.html.erb
+++ b/app/components/shares/work_packages/modal_upsell_component.html.erb
@@ -1,5 +1,7 @@
<%=
component_wrapper(tag: "turbo-frame") do
- render(EnterpriseEdition::BannerComponent.new(:work_package_sharing))
+ modal_content.with_row do
+ render(EnterpriseEdition::BannerComponent.new(:work_package_sharing))
+ end
end
%>
diff --git a/app/components/shares/work_packages/modal_upsell_component.rb b/app/components/shares/work_packages/modal_upsell_component.rb
index 3b9efbb5a81..a26e98f422c 100644
--- a/app/components/shares/work_packages/modal_upsell_component.rb
+++ b/app/components/shares/work_packages/modal_upsell_component.rb
@@ -33,6 +33,14 @@ module Shares
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
+ def initialize(modal_content:)
+ super
+
+ @modal_content = modal_content
+ end
+
+ attr_reader :modal_content
+
def self.wrapper_key
"share_modal_body"
end
diff --git a/app/models/sharing_strategies/project_query_strategy.rb b/app/models/sharing_strategies/project_query_strategy.rb
index da6428bca5b..cd30bb88804 100644
--- a/app/models/sharing_strategies/project_query_strategy.rb
+++ b/app/models/sharing_strategies/project_query_strategy.rb
@@ -109,6 +109,15 @@ module SharingStrategies
I18n.t(:label_share_project_list)
end
+ def upsell_banner(modal_content:)
+ Shares::ProjectQueries::UpsellComponent.new(modal_content:)
+ end
+
+ def allow_feature?
+ EnterpriseToken.allows_to?(:project_list_sharing) ||
+ EnterpriseToken.trialling?(:project_list_sharing)
+ end
+
private
def virtual_owner_share
diff --git a/app/models/sharing_strategies/work_package_strategy.rb b/app/models/sharing_strategies/work_package_strategy.rb
index d51c3be999f..e398663d0e9 100644
--- a/app/models/sharing_strategies/work_package_strategy.rb
+++ b/app/models/sharing_strategies/work_package_strategy.rb
@@ -99,18 +99,19 @@ module SharingStrategies
Shares::WorkPackages::DeleteContract
end
- def modal_body_component(errors)
- if EnterpriseToken.allows_to?(:work_package_sharing)
- super
- else
- Shares::WorkPackages::ModalUpsellComponent.new
- end
- end
-
def title
I18n.t(:label_share_work_package)
end
+ def upsell_banner(modal_content:)
+ Shares::WorkPackages::ModalUpsellComponent.new(modal_content:)
+ end
+
+ def allow_feature?
+ EnterpriseToken.allows_to?(:work_package_sharing) ||
+ EnterpriseToken.trialling?(:work_package_sharing)
+ end
+
private
def project_member?(share)