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
Add trial teaser component
Mir Bhatia77853f379304
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erbindex 513c7900f98..623fe25cc4b 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? || teaser?- concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }+ unless large?+ concat render(Primer::Beta::Text.new(tag: :p)) { plan_text }+ endend- endif features.present?flex.with_row do@@ -68,14 +68,14 @@endend- flex.with_row(mt: 1) do- render EnterpriseEdition::UpsellButtonsComponent.new(- feature_key,- justify_content: (large? ? :center : :flex_start)- )+ flex.with_row(mt: 1) do+ render EnterpriseEdition::UpsellButtonsComponent.new(+ feature_key,+ justify_content: (large? ? :center : :flex_start)+ )+ 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 2173ebcab55..80be876e196 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -107,10 +107,6 @@ module EnterpriseEdition@variant == :inlineend- def teaser?- feature_key == :teaser- end-def wrapper_key"enterprise_banner_#{@dismiss_key}"end@@ -128,8 +124,7 @@ module EnterpriseEdition"op-enterprise-banner","op-enterprise-banner_medium" => @variant == :medium,"op-enterprise-banner_large" => @variant == :large,- "op-enterprise-banner_trial" => trial_feature?,- "op-enterprise-banner_teaser" => teaser?+ "op-enterprise-banner_trial" => trial_feature?)end@@ -140,7 +135,6 @@ 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/plan_for_feature.rb b/app/components/enterprise_edition/plan_for_feature.rbindex 5b3cf342680..6341e5e29d1 100644--- a/app/components/enterprise_edition/plan_for_feature.rb+++ b/app/components/enterprise_edition/plan_for_feature.rb@@ -37,29 +37,15 @@ module EnterpriseEditionattr_accessor :i18n_scopeend- def teaser?- feature_key == :teaser- end-- def token- @token ||= EnterpriseToken.active_trial_tokens.last- end-def titleI18n.t(:title, scope: i18n_scope, default: default_title)enddef default_title- teaser? ? teaser_title : I18n.t(feature_key, scope: :"ee.features")- end-- def teaser_title- I18n.t("ee.teaser.title", count: token.days_left || 365, trial_plan: token.plan)+ I18n.t(feature_key, scope: :"ee.features")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@@ -77,10 +63,6 @@ module EnterpriseEdition)end- def teaser_description- I18n.t("ee.teaser.description", trial_plan: plan_name(token.plan)).html_safe- end-def featuresdefined?(@features) || begin@features = I18n.t(:features, scope: i18n_scope, default: nil)&.values@@ -99,13 +81,11 @@ module EnterpriseEditionenddef plan_text- 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")) do+ plan_name = 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/app/components/enterprise_edition/trial_teaser_component.html.erb b/app/components/enterprise_edition/trial_teaser_component.html.erbnew file mode 100644index 00000000000..e6f765eb068--- /dev/null+++ b/app/components/enterprise_edition/trial_teaser_component.html.erb@@ -0,0 +1,31 @@+<%=+ render(Primer::BaseComponent.new(tag: :div, classes: "op-enterprise-banner-container")) do+ grid_layout(+ "op-enterprise-banner",+ **@system_arguments+ ) do |grid|+ grid.with_area(:visual) do+ render(Primer::Beta::Octicon.new(icon: :"op-enterprise-addons", classes: "op-enterprise-banner--icon"))+ end++ grid.with_area(:content) do+ flex_layout do |flex|+ flex.with_row do+ render(Primer::Beta::Text.new(font_weight: :bold)) { title }+ end++ flex.with_row(classes: "op-enterprise-banner--description") do+ concat render(Primer::Beta::Text.new(tag: :p)) { description }+ end++ flex.with_row(mt: 1) do+ render EnterpriseEdition::UpsellButtonsComponent.new(+ :teaser,+ justify_content: :flex_start+ )+ end+ end+ end+ end+ end+%>diff --git a/app/components/enterprise_edition/trial_teaser_component.rb b/app/components/enterprise_edition/trial_teaser_component.rbnew file mode 100644index 00000000000..8962cf8d69d--- /dev/null+++ b/app/components/enterprise_edition/trial_teaser_component.rb@@ -0,0 +1,79 @@+# 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 TrialTeaserComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers++ def initialize(**system_arguments)+ set_system_arguments(system_arguments)++ super+ end++ private++ def set_system_arguments(system_arguments)+ @system_arguments = system_arguments+ @system_arguments[:tag] = :div+ @system_arguments[:mx] = 2+ @system_arguments[:mt] = 2+ @system_arguments[:mb] = 3+ @system_arguments[:id] = "op-enterprise-banner-teaser"+ @system_arguments[:test_selector] = "op-enterprise-banner"+ @system_arguments[:classes] = class_names(+ @system_arguments[:classes],+ "op-enterprise-banner"+ )+ end++ def render?+ User.current.admin? && EnterpriseToken.trial_only?+ end++ def token+ @token ||= EnterpriseToken.active_trial_tokens.last+ end++ def title+ I18n.t("ee.teaser.title", count: token.days_left, trial_plan: token.plan)+ end++ def description+ I18n.t("ee.teaser.description", trial_plan: plan_name).html_safe+ end++ def plan_name+ render(Primer::Beta::Text.new(font_weight: :bold, classes: "upsell-colored")) do+ I18n.t("ee.upsell.plan_name", plan: token.plan.capitalize)+ end+ end+ end+enddiff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erbindex f989fbd8177..bf8f00021e7 100644--- a/app/views/layouts/base.html.erb+++ b/app/views/layouts/base.html.erb@@ -105,11 +105,9 @@ See COPYRIGHT and LICENSE files for more details.<%= main_menu %><%= content_for :main_menu %><%= call_hook :view_layouts_base_main_menu %>- <% if current_user.admin? && EnterpriseToken.trial_only? %>- <%=- render(EnterpriseEdition::BannerComponent.new(:teaser, mx: 2, mt: 2, mb: 3))- %>- <% end %>+ <%=+ render(EnterpriseEdition::TrialTeaserComponent.new)+ %><!-- Sidebar --><div id="sidebar" data-menus--main-target="sidebar"><%= content_for :sidebar %>