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

Dynamic buttons

Oliver Güntherb474818f437f
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erb
index 7bc4c1f1399..e1c762b0c22 100644
--- a/app/components/enterprise_edition/banner_component.html.erb
+++ b/app/components/enterprise_edition/banner_component.html.erb
@@ -20,26 +20,10 @@
end
end
- flex.with_row(mt: 2, flex_layout: true, align_items: :center) do |buttons|
- buttons.with_column do
- helpers.angular_component_tag("opce-free-trial-button")
- end
-
- buttons.with_column(ml: 1) do
- render(Primer::Beta::Button.new(
- tag: :a,
- href: OpenProject::Static::Links.links[:pricing][:href],
- target: "_blank",
- classes: "upsale-colored-background",
- title: t("admin.enterprise.buttons.upgrade"),
- aria_label: t("admin.enterprise.buttons.upgrade"),
- )) { t("admin.enterprise.buttons.upgrade") }
- end
-
- buttons.with_column(ml: 1) do
- render(Primer::Beta::Link.new(href:)) do |link|
- link.with_trailing_visual_icon(icon: "link-external")
- link_title
+ flex.with_row(mt: 2, flex_layout: true, align_items: :center) do |button_layout|
+ buttons.each_with_index do |button, i|
+ button_layout.with_column(ml: (i == 0 ? 0 : 2)) do
+ button
end
end
end
diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rb
index 39c2c586320..3e9c85b71ae 100644
--- a/app/components/enterprise_edition/banner_component.rb
+++ b/app/components/enterprise_edition/banner_component.rb
@@ -98,6 +98,31 @@ module EnterpriseEdition
@features = I18n.t("ee.upsale.#{feature_key}.features", default: nil)&.values
end
+ def buttons
+ [
+ free_trial_button,
+ upgrade_now_button,
+ more_info_button
+ ].compact
+ end
+
+ def free_trial_button
+ return if EnterpriseToken.active?
+ helpers.angular_component_tag("opce-free-trial-button")
+ end
+
+ # Allow providing a custom upgrade now button
+ def upgrade_now_button
+ nil
+ end
+
+ def more_info_button
+ render(Primer::Beta::Link.new(href:)) do |link|
+ link.with_trailing_visual_icon(icon: "link-external")
+ link_title
+ end
+ end
+
def plan
@plan ||= OpenProject::Token.lowest_plan_for(feature_key)&.capitalize
end