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

Move trial teasers from SaaS

Mir Bhatia1b6c571e0128
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erb
index 24df82dec02..513c7900f98 100644
--- a/app/components/enterprise_edition/banner_component.html.erb
+++ b/app/components/enterprise_edition/banner_component.html.erb
@@ -69,14 +69,10 @@
end
flex.with_row(mt: 1) do
- if teaser?
- render(EnterpriseEdition::BuyNowButtonComponent.new)
- else
- render EnterpriseEdition::UpsellButtonsComponent.new(
- feature_key,
- justify_content: (large? ? :center : :flex_start)
- )
- end
+ render EnterpriseEdition::UpsellButtonsComponent.new(
+ feature_key,
+ justify_content: (large? ? :center : :flex_start)
+ )
end
end
end
diff --git a/app/components/enterprise_edition/buy_now_button_component.rb b/app/components/enterprise_edition/buy_now_button_component.rb
index 6e371c4ba1d..49cf12bf830 100644
--- a/app/components/enterprise_edition/buy_now_button_component.rb
+++ b/app/components/enterprise_edition/buy_now_button_component.rb
@@ -38,7 +38,7 @@ module EnterpriseEdition
render(Primer::Beta::Button.new(
classes: "upsell-colored-background hidden-for-mobile",
tag: :a,
- href: "/admin/subscriptions/new",
+ href: OpenProject::Enterprise.upgrade_path,
align_self: :center
)) do
I18n.t(:button_buy_now)
diff --git a/app/components/enterprise_edition/plan_for_feature.rb b/app/components/enterprise_edition/plan_for_feature.rb
index 5ec1f3244f8..7bff4abcf0f 100644
--- a/app/components/enterprise_edition/plan_for_feature.rb
+++ b/app/components/enterprise_edition/plan_for_feature.rb
@@ -41,9 +41,8 @@ module EnterpriseEdition
feature_key == :teaser
end
- # Allow providing a subscription
- def current_subscription
- nil
+ def token
+ @token ||= EnterpriseToken.active_trial_tokens.last
end
def title
@@ -54,9 +53,8 @@ module EnterpriseEdition
teaser? ? teaser_title : I18n.t(feature_key, scope: :"ee.features")
end
- # Allow providing a title based on the subscription
def teaser_title
- nil
+ I18n.t("ee.teaser.title", count: token.days_left, trial_plan: token.plan)
end
def description
@@ -79,9 +77,8 @@ module EnterpriseEdition
)
end
- # Allow providing a description based on the subscription
def teaser_description
- nil
+ I18n.t("ee.teaser.description", trial_plan: plan_name(token.plan)).html_safe
end
def features
diff --git a/app/components/enterprise_edition/upsell_buttons_component.rb b/app/components/enterprise_edition/upsell_buttons_component.rb
index aec2538fd2b..5b34e32a19e 100644
--- a/app/components/enterprise_edition/upsell_buttons_component.rb
+++ b/app/components/enterprise_edition/upsell_buttons_component.rb
@@ -75,14 +75,7 @@ module EnterpriseEdition
return unless EnterpriseToken.active?
return unless User.current.admin?
- render(Primer::Beta::Button.new(
- classes: "upsell-colored-background",
- tag: :a,
- href: OpenProject::Enterprise.upgrade_path,
- align_self: :center
- )) do
- I18n.t("ee.upsell.buy_now_button")
- end
+ render(EnterpriseEdition::BuyNowButtonComponent.new)
end
# Allow providing a custom upgrade now button
diff --git a/app/models/enterprise_token.rb b/app/models/enterprise_token.rb
index b6a159fdbe4..c27a2661959 100644
--- a/app/models/enterprise_token.rb
+++ b/app/models/enterprise_token.rb
@@ -61,6 +61,10 @@ class EnterpriseToken < ApplicationRecord
active_tokens.any?
end
+ def trial_only?
+ active_non_trial_tokens.empty? && active_trial_tokens.any?
+ end
+
def available_features
active_tokens.map(&:available_features).flatten.uniq
end
@@ -218,6 +222,10 @@ class EnterpriseToken < ApplicationRecord
[expires_at || FAR_FUTURE_DATE, starts_at || FAR_FUTURE_DATE]
end
+ def days_left
+ (valid_until.to_date - Time.zone.today).to_i
+ end
+
private
def strip_encoded_token
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index 16f75e741a1..f989fbd8177 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -105,6 +105,11 @@ See COPYRIGHT and LICENSE files for more details.
<%= main_menu %>
<%= content_for :main_menu %>
<%= call_hook :view_layouts_base_main_menu %>
+ <% if current_user.admin? && EnterpriseToken.trial_only? %>
+ <%=
+ render(EnterpriseEdition::BannerComponent.new(:teaser, mx: 2, mt: 2, mb: 3))
+ %>
+ <% end %>
<!-- Sidebar -->
<div id="sidebar" data-menus--main-target="sidebar">
<%= content_for :sidebar %>
diff --git a/config/initializers/homescreen.rb b/config/initializers/homescreen.rb
index 288cbfc5b92..0126b0b345b 100644
--- a/config/initializers/homescreen.rb
+++ b/config/initializers/homescreen.rb
@@ -64,7 +64,7 @@ OpenProject::Static::Homescreen.manage :blocks do |blocks|
},
{
partial: "upsell",
- if: Proc.new { !(EnterpriseToken.active? || EnterpriseToken.hide_banners?) }
+ if: Proc.new { !(EnterpriseToken.active? || EnterpriseToken.hide_banners?) || EnterpriseToken.trial_only? }
}
)
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3cd9526bdd0..46e1c8d486c 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1932,6 +1932,7 @@ en:
button_unwatch: "Unwatch"
button_update: "Update"
button_upgrade: "Upgrade"
+ button_buy_now: "Buy now"
button_upload: "Upload"
button_view: "View"
button_watch: "Watch"
diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb
index 059b72f2b60..33e719b93fa 100644
--- a/lib/redmine/menu_manager/top_menu_helper.rb
+++ b/lib/redmine/menu_manager/top_menu_helper.rb
@@ -58,6 +58,10 @@ module Redmine::MenuManager::TopMenuHelper
end
end
+ def render_top_menu_teaser
+ render EnterpriseEdition::UpsellButtonsComponent.new(:teaser)
+ end
+
def render_global_search_input
angular_component_tag "opce-global-search",
inputs: {
@@ -67,6 +71,7 @@ module Redmine::MenuManager::TopMenuHelper
def render_top_menu_right
capture do
+ concat render_top_menu_teaser
concat render_top_menu_search
concat top_menu_right_node
end