Skip to content

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

Allow wrapping content in the banner

Oliver Günther2f451d70f0c1
diff --git a/app/components/enterprise_edition/banner_component.html.erb b/app/components/enterprise_edition/banner_component.html.erb
index 91c4fd6e3d4..53572d7b407 100644
--- a/app/components/enterprise_edition/banner_component.html.erb
+++ b/app/components/enterprise_edition/banner_component.html.erb
@@ -98,3 +98,4 @@
end
end
%>
+<%= content if feature_available? %>
diff --git a/app/views/custom_actions/index.html.erb b/app/views/custom_actions/index.html.erb
index 5f2b58cfaa5..56ca8ed0b82 100644
--- a/app/views/custom_actions/index.html.erb
+++ b/app/views/custom_actions/index.html.erb
@@ -1,5 +1,4 @@
<% html_title t(:label_administration), t("custom_actions.plural") -%>
-<% available = EnterpriseToken.allows_to?(:custom_actions) %>
<%=
render Primer::OpenProject::PageHeader.new do |header|
@@ -14,17 +13,16 @@
<%=
render(Primer::OpenProject::SubHeader.new) do |subheader|
- if available
- subheader.with_action_button(
- scheme: :primary,
- leading_icon: :plus,
- label: t("custom_actions.new"),
- test_selector: "op-admin-custom-actions--button-new",
- tag: :a,
- href: new_custom_action_path
- ) do
- CustomAction.model_name.human
- end
+ subheader.with_action_button(
+ scheme: :primary,
+ leading_icon: :plus,
+ label: t("custom_actions.new"),
+ test_selector: "op-admin-custom-actions--button-new",
+ tag: :a,
+ disabled: !EnterpriseToken.allows_to?(:custom_actions),
+ href: new_custom_action_path
+ ) do
+ CustomAction.model_name.human
end
end
%>
@@ -34,9 +32,6 @@
:custom_actions,
variant: :large,
video: "enterprise/custom-actions.mp4"
- )
-%>
-
-<% if available %>
+ ) do %>
<%= render(::CustomActions::TableComponent.new(rows: @custom_actions)) %>
<% end %>
diff --git a/app/views/custom_actions/upsell.html.erb b/app/views/custom_actions/upsell.html.erb
deleted file mode 100644
index 235de76d39f..00000000000
--- a/app/views/custom_actions/upsell.html.erb
+++ /dev/null
@@ -1,38 +0,0 @@
-<%#-- 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.
-
-++#%>
-
-<% html_title t(:label_administration), t("ee.upsell.custom_actions.title") %>
-
-<%=
- render EnterpriseEdition::BannerComponent.new(
- :custom_actions,
- variant: :large,
- video: "enterprise/custom-actions.mp4"
- )
-%>
diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erb
index f495b69d8eb..89fd91246a8 100644
--- a/app/views/custom_styles/show.html.erb
+++ b/app/views/custom_styles/show.html.erb
@@ -27,17 +27,12 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<% allowed = EnterpriseToken.allows_to?(:define_custom_style) %>
-<% tabs = allowed ? design_tabs : [] %>
-<%= render(Admin::DesignHeaderComponent.new(tabs:)) %>
-
<%= render EnterpriseEdition::BannerComponent.new(
:define_custom_style,
variant: :large,
video: "enterprise/custom-design.mp4"
-) %>
-
-<% if allowed %>
+) do %>
+ <%= render(Admin::DesignHeaderComponent.new(tabs: design_tabs)) %>
<%= error_messages_for "custom_style" %>
<%= form_tag update_design_themes_path, method: :post, class: "form" do %>
<section class="form--section">
diff --git a/lookbook/docs/components/enterprise.md.erb b/lookbook/docs/components/enterprise.md.erb
index 3ad98821c5c..ffe04de8bd0 100644
--- a/lookbook/docs/components/enterprise.md.erb
+++ b/lookbook/docs/components/enterprise.md.erb
@@ -21,6 +21,17 @@ For each banner, you can provide:
If you don't provide a title for the upsell banner, it will simply use the name of the feature.
+### Passing through content
+
+You can pass through additional content to the upsell banner, which will be rendered below the banner if the feature is available
+
+
+```erb
+<%%= render EnterpriseEdition::BannerComponent.new(:enterprise_feature) do %%>
+ Some additional content that will be rendered below the banner, only if the feature is available
+<%% end %%>
+```
+
### Defining the text
This is the default convention:
diff --git a/modules/team_planner/app/components/team_planner/add_button_component.rb b/modules/team_planner/app/components/team_planner/add_button_component.rb
index 19653b26861..c4c2ef4c605 100644
--- a/modules/team_planner/app/components/team_planner/add_button_component.rb
+++ b/modules/team_planner/app/components/team_planner/add_button_component.rb
@@ -32,6 +32,8 @@
module TeamPlanner
class AddButtonComponent < ::AddButtonComponent
def render?
+ return false unless EnterpriseToken.allows_to?(:team_planner_view)
+
if current_project
User.current.allowed_in_project?(:manage_team_planner, current_project)
else
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index afb7f4ab7dc..25e4de27a02 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -4,9 +4,12 @@ module ::TeamPlanner
include Layout
before_action :load_and_authorize_in_optional_project
before_action :build_plan_view, only: %i[new]
- before_action :require_ee_token, except: %i[upsell]
before_action :find_plan_view, only: %i[destroy]
+ guard_enterprise_feature(:team_planner_view, except: %i[index]) do
+ redirect_to action: :index
+ end
+
menu_item :team_planner_view
def index
@@ -50,12 +53,6 @@ module ::TeamPlanner
redirect_to action: :index
end
- def require_ee_token
- unless EnterpriseToken.allows_to?(:team_planner_view)
- redirect_to action: :upsell
- end
- end
-
current_menu_item :index do
:team_planner_view
end
diff --git a/modules/team_planner/app/views/team_planner/team_planner/index.html.erb b/modules/team_planner/app/views/team_planner/team_planner/index.html.erb
index e8aa444f5fe..301f72e714e 100644
--- a/modules/team_planner/app/views/team_planner/team_planner/index.html.erb
+++ b/modules/team_planner/app/views/team_planner/team_planner/index.html.erb
@@ -16,4 +16,13 @@
end
%>
+<%=
+ render(EnterpriseEdition::BannerComponent.new(
+ :team_planner_view,
+ variant: :large,
+ video: "enterprise/team-planner-animation.mp4"
+ )) do %>
+
<%= render ::TeamPlanner::TableComponent.new(rows: @views, current_user: current_user) %>
+
+<% end %>
diff --git a/modules/team_planner/app/views/team_planner/team_planner/upsell.html.erb b/modules/team_planner/app/views/team_planner/team_planner/upsell.html.erb
deleted file mode 100644
index af19c305c51..00000000000
--- a/modules/team_planner/app/views/team_planner/team_planner/upsell.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<% html_title(t(:label_administration), t("ee.upsell.team_planner_view.title")) -%>
-
-<%=
- render EnterpriseEdition::BannerComponent.new(
- :team_planner_view,
- variant: :large,
- video: "enterprise/team-planner-animation.mp4"
- )
-%>