From 4127b50ca609cf44656ca8a07c086b0a203119bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oliver=20G=C3=BCnther?=
Date: Fri, 13 Jun 2025 11:14:13 +0200
Subject: [PATCH] Show buttons in the banner above
---
.../upsell_buttons_component.rb | 23 +++++++++++--
.../banner_component.html.erb | 2 +-
.../trial_button_component.rb | 27 ++++++---------
app/views/enterprise_tokens/_info.html.erb | 34 -------------------
config/locales/en.yml | 3 +-
.../admin/enterprise/enterprise_spec.rb | 3 --
6 files changed, 33 insertions(+), 59 deletions(-)
diff --git a/app/components/enterprise_edition/upsell_buttons_component.rb b/app/components/enterprise_edition/upsell_buttons_component.rb
index 79206a9c553..aec2538fd2b 100644
--- a/app/components/enterprise_edition/upsell_buttons_component.rb
+++ b/app/components/enterprise_edition/upsell_buttons_component.rb
@@ -33,13 +33,15 @@ module EnterpriseEdition
include OpPrimer::ComponentHelpers
# @param feature_key [Symbol, NilClass] The key of the feature to show the banner for.
+ # @param show_buy_now [Boolean] Whether to show the "Buy now" button.
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
- def initialize(feature_key, **system_arguments)
+ def initialize(feature_key, show_buy_now: false, **system_arguments)
super
@system_arguments = system_arguments
@system_arguments[:align_items] ||= :center
@feature_key = feature_key
+ @show_buy_now = show_buy_now
end
def call
@@ -85,7 +87,24 @@ module EnterpriseEdition
# Allow providing a custom upgrade now button
def upgrade_now_button
- nil
+ if @show_buy_now
+ button_title = t("admin.enterprise.book_now")
+ render(
+ Primer::Beta::Button.new(
+ tag: :a,
+ size: :medium,
+ href: "#",
+ aria: { label: button_title },
+ classes: "upsell-colored-background",
+ role: "button",
+ data: {
+ "cb-type": "checkout",
+ "cb-plan-id": OpenProject::Configuration.enterprise_plan
+ },
+ title: button_title
+ )
+ ) { button_title }
+ end
end
def more_info_button
diff --git a/app/components/enterprise_trials/banner_component.html.erb b/app/components/enterprise_trials/banner_component.html.erb
index 87b3381c639..fea750b1116 100644
--- a/app/components/enterprise_trials/banner_component.html.erb
+++ b/app/components/enterprise_trials/banner_component.html.erb
@@ -42,7 +42,7 @@
<% end %>
- <%= render EnterpriseEdition::UpsellButtonsComponent.new(nil) %>
+ <%= render EnterpriseEdition::UpsellButtonsComponent.new(nil, show_buy_now: true) %>
)">
diff --git a/app/components/enterprise_trials/trial_button_component.rb b/app/components/enterprise_trials/trial_button_component.rb
index 661df6efdf4..3e6833a09cd 100644
--- a/app/components/enterprise_trials/trial_button_component.rb
+++ b/app/components/enterprise_trials/trial_button_component.rb
@@ -41,23 +41,16 @@ module EnterpriseTrials
end
def call
- if @trial_key
- render(
- Primer::Beta::Button.new(
- tag: :a,
- href: enterprise_tokens_path
- )
- ) do
- I18n.t(:button_try_again)
- end
- else
- render(
- Primer::Beta::Button.new(
- tag: :a,
- href: trial_dialog_enterprise_trial_path,
- data: { turbo_stream: true }
- )
- ) do
+ render(
+ Primer::Beta::Button.new(
+ tag: :a,
+ href: trial_dialog_enterprise_trial_path,
+ data: { turbo_stream: true }
+ )
+ ) do
+ if @trial_key
+ I18n.t("ee.trial.request_again")
+ else
I18n.t("admin.enterprise.start_trial")
end
end
diff --git a/app/views/enterprise_tokens/_info.html.erb b/app/views/enterprise_tokens/_info.html.erb
index 135f2357a72..9c3c42b7cbb 100644
--- a/app/views/enterprise_tokens/_info.html.erb
+++ b/app/views/enterprise_tokens/_info.html.erb
@@ -65,40 +65,6 @@ See COPYRIGHT and LICENSE files for more details.
button_title
end
end
-
- button_row.with_column(ml: 1) do
- button_title = t("admin.enterprise.book_now")
- render(
- Primer::Beta::Button.new(
- tag: :a,
- size: :medium,
- href: '#',
- aria: { label: button_title },
- role: "button",
- data: {
- "cb-type": "checkout",
- "cb-plan-id": OpenProject::Configuration.enterprise_plan,
- },
- title: button_title
- )
- ) { button_title }
- end
-
- button_row.with_column(ml: 1) do
- quote_link = OpenProject::Static::Links.links.fetch :upsell_get_quote
- button_title = t(quote_link[:label])
- render(
- Primer::Beta::Button.new(
- tag: :a,
- size: :medium,
- href: quote_link[:href],
- aria: { label: button_title },
- target: "_blank",
- title: button_title
- )
- ) { button_title }
- end
-
end
%>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 59ee0f9b54c..8ed060ddaaf 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1910,7 +1910,6 @@ en:
button_sort: "Sort"
button_submit: "Submit"
button_test: "Test"
- button_try_again: "Try again"
button_unarchive: "Unarchive"
button_uncheck_all: "Uncheck all"
button_unlock: "Unlock"
@@ -2196,7 +2195,7 @@ en:
already_retrieved: "Your trial enterprise token was already retrieved. Please reach out to our support team if you need a new one."
successfully_saved: "Your trial enterprise token has been successfully retrieved."
token_sent: "Trial token requested"
- start_over: "Start over trial request"
+ request_again: "Request again"
resend_action: "Resend confirmation email"
welcome_title: "Quick feature overview"
welcome_description: "Get a quick overview of project management and team collaboration with OpenProject Enterprise edition."
diff --git a/spec/features/admin/enterprise/enterprise_spec.rb b/spec/features/admin/enterprise/enterprise_spec.rb
index 8580fde6d11..62d7ddb2b4b 100644
--- a/spec/features/admin/enterprise/enterprise_spec.rb
+++ b/spec/features/admin/enterprise/enterprise_spec.rb
@@ -54,10 +54,7 @@ RSpec.describe "Enterprise token", :js do
end
it "shows a teaser page and has a button to add a token" do
- # The teaser page is displayed
- # TODO: this will likely change, adapt to the new teaser page
expect(page).to have_link("Start free trial")
- expect(page).to have_css(".button", text: "Book now")
# Try adding invalid enterprise token data
expect(page).to have_button("Add Enterprise token")