This commit is contained in:
Oliver Günther
2025-04-01 15:51:20 +02:00
parent f82d262946
commit 4e7bf203ba
7 changed files with 90 additions and 13 deletions
@@ -62,8 +62,6 @@ module EnterpriseEdition
private
attr_reader :skip_render
def render?
!(EnterpriseToken.hide_banners? || feature_available? || dismissed?)
end
@@ -87,11 +87,11 @@ module EnterpriseEdition
end
def enterprise_link
href_value = OpenProject::Static::Links.links.dig(:enterprise_docs, feature_key, :href)
href_value = OpenProject::Static::Links.links.dig(:enterprise_features, 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]"
"in OpenProject::Static::Links.enterprise_features[#{feature_key}][:href]"
end
href_value
+1 -1
View File
@@ -130,7 +130,7 @@ pricing:
href: https://www.openproject.org/pricing/
progress_tracking_docs:
href: https://www.openproject.org/docs/user-guide/time-and-costs/progress-tracking/
enterprise_docs:
enterprise_features:
work_package_subject_generation:
href: https://www.openproject.org/docs/system-admin-guide/manage-work-packages/work-package-types/#work-package-subject-configuration-enterprise-add-on
form_configuration:
@@ -0,0 +1,79 @@
OpenProject provides multiple ways to render upsale components. This document describes the different components and how to use them.
# Requirements
## Token Gem
In order to add a new enterprise feature, you need to add it the [token gem](https://github.com/opf/openproject-token) `plans.rb` file,
so it gets distributed and associated to the correct plan.
## Translations
To use the banners below, you need to add translations and links.
**Translations**
You need to add translations for the feature and the upsale banner.
The feature translation is used in the feature list, the upsale translation is used in the upsale banner.
This is the default convention:
```yaml
en:
# ... other keys
ee:
feature:
# ...
your_feature_name: "Fancy EE feature!"
upsale:
# ...
your_feature_name:
title: "Title of the banner"
description: "My description"
features:
foo: "Has foo!"
bar: "Has bar!"
```
You can optionally provide a `i18n_scope` parameter to the components below to customize the place to look
for the upsale translation keys.
**docs/static_links.yml**
Every feature has a "More information" link going to the website, an enterprise landing page, or a documentation page.
You need to add a link to the [`docs/static_links.yml`](https://github.com/opf/openproject/blob/dev/config/static_links.yml)
file under the `enterprise_features` section.
## Full-page upsale pages
Use when: You have a feature video / image and a full page to fill
```ruby
render EnterpriseEdition::UpsalePageComponent.new(
:enterprise_feature,
video: "enterprise/some-video.mp4",
# or image: "enterprise/some-image.png"
)
```
<%= embed OpenProject::EnterpriseEdition::UpsalePageComponentPreview, :default, panels: %i[] %>
## Inline upsale banners
Use when: You want to show content below the banners, e.g. in administrative setting pages.
```ruby
render EnterpriseEdition::BannerComponent.new(:enterprise_feature)
```
<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :default, panels: %i[] %>
## Dismissible upsale banners
Use when: You want to show a feature to regular users, but allow them to hide it for good.
```ruby
render EnterpriseEdition::BannerComponent.new(:enterprise_feature, dismissable: true)
```
<%= embed OpenProject::EnterpriseEdition::BannerComponentPreview, :dismissable, panels: %i[] %>
@@ -54,8 +54,9 @@ module OpenProject
# You can also provide a custom i18n_scope to change the place where the component looks for
# title, description, and features.
#
# The href is inferred from `OpenProject::Static::Links.enterprise_docs[feature_key][:href]`.
# The href is inferred from `OpenProject::Static::Links.enterprise_features[feature_key][:href]`.
# @param dismissable toggle
# @display min_height 250px
def default(dismissable: false)
render(
::EnterpriseEdition::BannerComponent
@@ -63,6 +64,7 @@ module OpenProject
)
end
# @display min_height 250px
def dismissable
render(
::EnterpriseEdition::BannerComponent
@@ -60,12 +60,10 @@ module OpenProject
# To provide a video or image, use the respective `video:` or `image:` tags.
# If none or provided, a default image will be used.
#
# The href is inferred from `OpenProject::Static::Links.enterprise_docs[feature_key][:href]`.
# The href is inferred from `OpenProject::Static::Links.enterprise_features[feature_key][:href]`.
# @display min_height 450px
def default
render(
::EnterpriseEdition::UpsalePageComponent
.new(:customize_life_cycle)
)
render ::EnterpriseEdition::UpsalePageComponent.new(:customize_life_cycle)
end
def video
@@ -50,7 +50,7 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do
end
let(:static_links) do
{
enterprise_docs: {
enterprise_features: {
some_enterprise_feature: {
href:
}
@@ -244,7 +244,7 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do
context "without a link key in the static_link file" do
let(:static_links) do
{
enterprise_docs: {
enterprise_features: {
some_enterprise_feature: {}
}
}