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
Primerize SaaS teaser components
Mir Bhatiaba14469d1abe
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erbindex 623fe25cc4b..24df82dec02 100644--- a/app/components/enterprise_edition/banner_component.html.erb+++ b/app/components/enterprise_edition/banner_component.html.erb@@ -42,10 +42,10 @@flex.with_row(classes: "op-enterprise-banner--description") doconcat render(Primer::Beta::Text.new(tag: :p)) { description }- unless large?- concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }- end+ unless large? || teaser?+ concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }end+ endif features.present?flex.with_row do@@ -68,7 +68,10 @@endend- flex.with_row(mt: 1) do+ flex.with_row(mt: 1) do+ if teaser?+ render(EnterpriseEdition::BuyNowButtonComponent.new)+ elserender EnterpriseEdition::UpsellButtonsComponent.new(feature_key,justify_content: (large? ? :center : :flex_start)@@ -76,6 +79,7 @@endendend+ endif medium?grid.with_area(:image, **@image_arguments)diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rbindex 80be876e196..864a0110720 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -107,6 +107,10 @@ module EnterpriseEdition@variant == :inlineend+ def teaser?+ feature_key == :teaser+ end+def wrapper_key"enterprise_banner_#{@dismiss_key}"end@@ -135,6 +139,7 @@ module EnterpriseEditionenddef render?+ return true if teaser?return true if @show_alwaysreturn false if dismissed?return true if feature_available? && trial_feature?diff --git a/app/components/enterprise_edition/buy_now_button_component.rb b/app/components/enterprise_edition/buy_now_button_component.rbnew file mode 100644index 00000000000..6e371c4ba1d--- /dev/null+++ b/app/components/enterprise_edition/buy_now_button_component.rb@@ -0,0 +1,48 @@+# 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 BuyNowButtonComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers++ def call+ render(Primer::Beta::Button.new(+ classes: "upsell-colored-background hidden-for-mobile",+ tag: :a,+ href: "/admin/subscriptions/new",+ align_self: :center+ )) do+ I18n.t(:button_buy_now)+ end+ end+ end+enddiff --git a/app/components/enterprise_edition/plan_for_feature.rb b/app/components/enterprise_edition/plan_for_feature.rbindex 6341e5e29d1..2d30dcbe304 100644--- a/app/components/enterprise_edition/plan_for_feature.rb+++ b/app/components/enterprise_edition/plan_for_feature.rb@@ -37,15 +37,29 @@ module EnterpriseEditionattr_accessor :i18n_scopeend+ def teaser?+ feature_key == :teaser+ end++ def current_subscription+ @current_subscription ||= Subscription.current+ end+def titleI18n.t(:title, scope: i18n_scope, default: default_title)enddef default_title- I18n.t(feature_key, scope: :"ee.features")+ teaser? ? teaser_title : I18n.t(feature_key, scope: :"ee.features")+ end++ def teaser_title+ I18n.t("ee.teaser.title", count: current_subscription.trial_days_left, trial_plan: current_subscription.enterprise_plan)enddef description+ return teaser_description if teaser?+@description || beginif I18n.exists?(:description_html, scope: i18n_scope)I18n.t(:description_html, scope: i18n_scope).html_safe@@ -63,6 +77,10 @@ module EnterpriseEdition)end+ def teaser_description+ I18n.t("ee.teaser.description", trial_plan: plan_name(current_subscription.enterprise_plan)).html_safe+ end+def featuresdefined?(@features) || begin@features = I18n.t(:features, scope: i18n_scope, default: nil)&.values@@ -81,11 +99,13 @@ module EnterpriseEditionenddef plan_text- plan_name = render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored")) do+ I18n.t("ee.upsell.plan_text_html", plan_name: plan_name(plan)).html_safe+ end++ def plan_name(plan)+ render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored")) doI18n.t("ee.upsell.plan_name", plan: plan.capitalize)end-- I18n.t("ee.upsell.plan_text_html", plan_name:).html_safeendendenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 73fa5122ddd..3cd9526bdd0 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2216,6 +2216,11 @@ en:internal_comments_inline:title: "Write internal comments only a small group can see"description: " "+ teaser:+ title:+ one: "One day left of %{trial_plan} trial token"+ other: "%{count} days left of %{trial_plan} trial token"+ description: "You have access to all %{trial_plan} features."trial:not_found: "You have requested a trial token, but that request is no longer available. Please try again."wait_for_confirmation: "We sent you an email to confirm your address in order to retrieve a trial token."