Show buttons in the banner above

This commit is contained in:
Oliver Günther
2025-06-13 11:14:13 +02:00
parent c0fbb745b6
commit 4127b50ca6
6 changed files with 33 additions and 59 deletions
@@ -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
@@ -42,7 +42,7 @@
<% end %>
</p>
<%= render EnterpriseEdition::UpsellButtonsComponent.new(nil) %>
<%= render EnterpriseEdition::UpsellButtonsComponent.new(nil, show_buy_now: true) %>
</div>
<div class="widget-box--blocks--upsell-image"
style="background-image: url(<%= image_path("enterprise/homescreen.png") %>)"></div>
@@ -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
@@ -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
%>
+1 -2
View File
@@ -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."
@@ -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")