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 medium variant of enterprise banner
Oliver Günther4f2951877177
diff --git a/app/assets/images/enterprise/internal-comments.png b/app/assets/images/enterprise/internal-comments.pngnew file mode 100644index 00000000000..111493ebd5fBinary files /dev/null and b/app/assets/images/enterprise/internal-comments.png differdiff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erbindex 9e1464a8c80..547da3295f2 100644--- a/app/components/enterprise_edition/banner_component.html.erb+++ b/app/components/enterprise_edition/banner_component.html.erb@@ -2,17 +2,34 @@component_wrapper(tag: "turbo-frame") dogrid_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"))++ if inline?+ grid.with_area(:visual) do+ render(Primer::Beta::Octicon.new(icon: :"op-enterprise-addons", classes: "op-enterprise-banner--icon"))+ endendgrid.with_area(:content) do- flex_layout do |flex|+ flex_layout(classes: "op-enterprise-banner--content-wrapper") do |flex|flex.with_row do- render(Primer::Beta::Text.new(font_weight: :bold)) { title }+ if medium?+ flex_layout(align_items: :center, mb: 3) do |title_flex|+ title_flex.with_column do+ render(Primer::Beta::Octicon.new(icon: :"op-enterprise-addons",+ size: :medium,+ classes: "upsale-colored"))+ end++ title_flex.with_column(ml: 2) do+ render(Primer::Beta::Heading.new(tag: :h2)) { title }+ end+ end+ else+ render(Primer::Beta::Text.new(font_weight: :bold)) { title }+ endend- flex.with_row(mt: 1) do+ flex.with_row(mt: 1, classes: "op-enterprise-banner--description") doconcat render(Primer::Beta::Text.new) { description }concat " "concat render(Primer::Beta::Text.new) { plan_text }@@ -30,6 +47,14 @@endend++ if medium?+ grid.with_area(:graphic) do+ image_tag @image,+ class: "op-enterprise-banner--graphic"+ end+ end+if @dismissablegrid.with_area(:dismiss) dorender(diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rbindex 0ad9914b4d5..ecfbd876a35 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -33,32 +33,67 @@ module EnterpriseEdition# This component uses conventional names for translation keys or URL look-ups based on the feature_key passed in.# It will only be rendered if necessary.class BannerComponent < ApplicationComponent+ include Primer::FetchOrFallbackHelper+ include Primer::ClassNameHelperinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamableinclude PlanForFeature+ DEFAULT_VARIANT = :inline+ VARIANT_OPTIONS = %i[inline medium].freeze+# @param feature_key [Symbol, NilClass] The key of the feature to show the banner for.+ # @param variant [Symbol, NilClass] The variant of the banner comopnent.+ # @param image [String, NilClass] Path to the image to show on the banner, or nil.+ # Required when variant is :medium.# @param i18n_scope [String] Provide the i18n scope to look for title, description, and features.# Defaults to "ee.upsale.{feature_key}"# @param dismissable [boolean] Allow this banner to be dismissed.+ # @param show_always [boolean] Always show the banner, regardless of the dismissed or feature state.# @param dismiss_key [String] Provide a string to identify this banner when being dismissed. Defaults to feature_key# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>def initialize(feature_key,+ variant: DEFAULT_VARIANT,+ image: nil,i18n_scope: "ee.upsale.#{feature_key}",dismissable: false,+ show_always: false,dismiss_key: feature_key,**system_arguments)+ @variant = fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)+ @image = image+ @dismissable = dismissable+ @dismiss_key = dismiss_key+ @show_always = show_always++ self.feature_key = feature_key+ self.i18n_scope = i18n_scope++ if @variant == :medium+ raise ArgumentError, "The 'image' parameter is required when the variant is :medium." if @image.nil?+ raise ArgumentError, "Banners with variant :medium can not be 'dismissable'." if @dismissable+ end+@system_arguments = system_arguments@system_arguments[:tag] = :div@system_arguments[:mb] ||= 2@system_arguments[:id] = "op-enterprise-banner-#{feature_key.to_s.tr('_', '-')}"@system_arguments[:test_selector] = "op-enterprise-banner"+ @system_arguments[:classes] = class_names(+ @system_arguments[:classes],+ "op-enterprise-banner",+ @variant == :medium ? "op-enterprise-banner_medium" : nil+ )+super+ end- self.feature_key = feature_key- self.i18n_scope = i18n_scope- @dismissable = dismissable- @dismiss_key = dismiss_key+ def medium?+ @variant == :medium+ end++ def inline?+ @variant == :inlineenddef wrapper_key@@ -68,6 +103,8 @@ module EnterpriseEditionprivatedef render?+ return true if @show_always+!(EnterpriseToken.hide_banners? || feature_available? || dismissed?)enddiff --git a/app/components/enterprise_edition/banner_component.sass b/app/components/enterprise_edition/banner_component.sassindex 38cdf67fbde..4d4638c5508 100644--- a/app/components/enterprise_edition/banner_component.sass+++ b/app/components/enterprise_edition/banner_component.sass@@ -40,6 +40,31 @@background: var(--body-background)padding: var(--base-size-8)+ &_medium+ padding: 0+ grid-template-areas: "content graphic"+ grid-template-columns: 1fr 1fr++ &_medium &+ padding: 0+ grid-template-areas: "content graphic"+ grid-template-columns: 1fr 1fr++ &--content+ padding: var(--base-size-16)++ &--content-wrapper+ height: 100%++ &--description+ flex: 1++ &--graphic+ min-height: 240px+ width: 100%+ height: 100%+ object-fit: cover+&--visualdisplay: gridalign-self: startdiff --git a/app/components/enterprise_edition/upsale_buttons_component.rb b/app/components/enterprise_edition/upsale_buttons_component.rbindex 2e7f427debe..f07f3e54a45 100644--- a/app/components/enterprise_edition/upsale_buttons_component.rb+++ b/app/components/enterprise_edition/upsale_buttons_component.rb@@ -66,6 +66,7 @@ module EnterpriseEditiondef free_trial_buttonreturn if EnterpriseToken.active?+ return unless User.current.admin?helpers.angular_component_tag("opce-free-trial-button")enddiff --git a/lookbook/docs/components/enterprise.md.erb b/lookbook/docs/components/enterprise.md.erbindex 951550ef8cd..744b7d97ae6 100644--- a/lookbook/docs/components/enterprise.md.erb+++ b/lookbook/docs/components/enterprise.md.erb@@ -79,3 +79,16 @@ render EnterpriseEdition::BannerComponent.new(:enterprise_feature, dismissable:```<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :dismissable, panels: %i[] %>+++Use when: You want to show content below the banners, e.g. in administrative setting pages.++## Medium variant banners++Use when: You want to show a feature with some more context, and an image on the right hand side++```ruby+render EnterpriseEdition::BannerComponent.new(:enterprise_feature, variant: :medium, image: "enterprise/some-image.png")+```++<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :medium, panels: %i[] %>diff --git a/lookbook/previews/open_project/enterprise_edition/banner_component_preview.rb b/lookbook/previews/open_project/enterprise_edition/banner_component_preview.rbindex 56183a64296..8dbfea56aeb 100644--- a/lookbook/previews/open_project/enterprise_edition/banner_component_preview.rb+++ b/lookbook/previews/open_project/enterprise_edition/banner_component_preview.rb@@ -58,7 +58,18 @@ module OpenProjectdef default(dismissable: false)render(::EnterpriseEdition::BannerComponent- .new(:customize_life_cycle, dismissable:)+ .new(:customize_life_cycle, dismissable:, show_always: true)+ )+ end++ # @display min_height 250px+ def medium+ render(+ ::EnterpriseEdition::BannerComponent+ .new(:customize_life_cycle,+ variant: :medium,+ image: "enterprise/internal-comments.png",+ show_always: true))end@@ -66,7 +77,7 @@ module OpenProjectdef dismissablerender(::EnterpriseEdition::BannerComponent- .new(:customize_life_cycle, dismiss_key: nil, dismissable: true)+ .new(:customize_life_cycle, dismiss_key: nil, dismissable: true, show_always: true))endend