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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Extract buttons
Oliver Güntherdb4fa073f015
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erbindex b553eb23b41..0d03f3b591e 100644--- a/app/components/enterprise_edition/banner_component.html.erb+++ b/app/components/enterprise_edition/banner_component.html.erb@@ -23,12 +23,8 @@endend- 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+ flex.with_row(mt: 2) do |button_layout|+ render EnterpriseEdition::UpsaleButtonsComponent.new(feature_key)endendenddiff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rbindex 2f258cd11ea..cb0bf30112e 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -110,51 +110,10 @@ module EnterpriseEdition@features = I18n.t("ee.upsale.#{feature_key}.features", default: nil)&.valuesend- 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)&.capitalizeend- def link_title- @link_title || I18n.t("ee.upsale.#{feature_key}.link_title", default: I18n.t("ee.upsale.link_title"))- end-- def href- href_value = @href || OpenProject::Static::Links.links.dig(:enterprise_docs, feature_key, :href)-- unless href_value- raise "Neither a custom href is provided nor is a value set " \- "in OpenProject::Static::Links.enterprise_docs[#{feature_key}][:href]"- end-- href_value- end-def render?!(skip_render || dismissed?)enddiff --git a/app/components/enterprise_edition/upsale_buttons_component.rb b/app/components/enterprise_edition/upsale_buttons_component.rbnew file mode 100644index 00000000000..405e52d62c8--- /dev/null+++ b/app/components/enterprise_edition/upsale_buttons_component.rb@@ -0,0 +1,98 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module EnterpriseEdition+ class UpsaleButtonsComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers++ # @param feature_key [Symbol, NilClass] The key of the feature to show the banner for.+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>+ def initialize(feature_key, **system_arguments)+ super++ @feature_key = feature_key+ end++ def call+ flex_layout(align_items: :center) do |flex|+ buttons.each_with_index do |button, i|+ flex.with_column(ml: (i == 0 ? 0 : 2)) do+ button+ end+ end+ end+ end++ private++ attr_reader :feature_key++ 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 link_title+ I18n.t("ee.upsale.#{feature_key}.link_title", default: I18n.t("ee.upsale.link_title"))+ end++ def href+ href_value = OpenProject::Static::Links.links.dig(:enterprise_docs, feature_key, :href)++ unless href_value+ raise "A link for this feature needs to be provided " \+ "in OpenProject::Static::Links.enterprise_docs[#{feature_key}][:href]"+ end++ href_value+ end+ end+end